-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ggj][codegen][ast] fix: solidify codegen method order with AST Compa…
…rables (#311) * feat: add protobuf comment parser util * fix: add basic proto build rules * feat: add header comments to ServiceClient * fix: build protoc at test time * fix!: wrap protobuf location and process comments * fix: solidify codegen method order with TypeNode/MethodArg and Comparable * fix: clean up tests
- Loading branch information
Showing
7 changed files
with
155 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/test/java/com/google/api/generator/gapic/model/MethodArgumentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2020 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.api.generator.gapic.model; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
import com.google.api.generator.engine.ast.TypeNode; | ||
import java.util.function.BiFunction; | ||
import java.util.function.Function; | ||
import org.junit.Test; | ||
|
||
public class MethodArgumentTest { | ||
@Test | ||
public void compareMethodArguments() { | ||
BiFunction<String, TypeNode, MethodArgument> methodArgFn = | ||
(name, type) -> MethodArgument.builder().setName(name).setType(type).build(); | ||
|
||
// Cursory sanity-check of type-only differences, since these are already covered in the | ||
// TypeNode test. | ||
assertThat( | ||
methodArgFn | ||
.apply("foo", TypeNode.INT) | ||
.compareTo(methodArgFn.apply("foo", TypeNode.BOOLEAN))) | ||
.isGreaterThan(0); | ||
assertThat( | ||
methodArgFn | ||
.apply("foo", TypeNode.INT) | ||
.compareTo(methodArgFn.apply("foo", TypeNode.INT_OBJECT))) | ||
.isLessThan(0); | ||
|
||
// Non-type-based differences. | ||
Function<String, MethodArgument> simpleMethodArgFn = | ||
(name) -> methodArgFn.apply(name, TypeNode.INT); | ||
assertThat(simpleMethodArgFn.apply("foo").compareTo(simpleMethodArgFn.apply("bar"))) | ||
.isGreaterThan(0); | ||
assertThat(simpleMethodArgFn.apply("bar").compareTo(simpleMethodArgFn.apply("foo"))) | ||
.isLessThan(0); | ||
} | ||
} |