Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ggj][codegen] feat: add service.yaml and proto comments to package-info.java #416

Merged
merged 21 commits into from
Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ceaaddb
fix: refactor requestBuilder into separate method in ServiceClientCla…
miraleung Oct 7, 2020
fba69cb
Merge branch 'master' of github.com:googleapis/gapic-generator-java i…
miraleung Oct 8, 2020
32672f2
fix: merge master
miraleung Oct 21, 2020
bdcb62e
feat: add varargs to AnonClass and ref setter methods
miraleung Oct 21, 2020
e15e115
feat: add HTTP annotation parsing/validation
miraleung Oct 21, 2020
28d3b3c
feat: Generate RequestParamsExtractor in GrpcServiceStub
miraleung Oct 21, 2020
5293551
feat: add GrpcPublisherStub test to exercise HTTP subfields
miraleung Oct 21, 2020
2a50453
fix: add ByteString to DefaultValueComposer
miraleung Oct 21, 2020
e4684f3
fix: Use repeated field name for paged RPC unit tests
miraleung Oct 21, 2020
7829850
fix: refactor exception field, use paged repeated field name, add pub…
miraleung Oct 22, 2020
11c38bd
fix: ensure all testgen methods throw Exceptions
miraleung Oct 22, 2020
d3ec180
fix: Fix resname helper method names for of* and format*
miraleung Oct 22, 2020
6416984
fix: use only generated resnames in codegen
miraleung Oct 22, 2020
96046a6
fix: propagate of*Name changes to resname codegen
miraleung Oct 22, 2020
297f64a
fix: fix method arg resname mappings, add logging test
miraleung Oct 23, 2020
2691d8c
fix: ensure paged tests use the right repeated resp. type
miraleung Oct 23, 2020
01b8051
feat: add PackageInfoDefinition AST node
miraleung Oct 23, 2020
0d83a14
feat: add package-info.java codegen
miraleung Oct 23, 2020
d1e4335
feat: add Service.yaml parsing
miraleung Oct 24, 2020
9b86c03
feat: add service.yaml and proto comments to package-info.java
miraleung Oct 24, 2020
bfda0f9
Merge branch 'master' into gp/g16
miraleung Oct 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: ensure paged tests use the right repeated resp. type
  • Loading branch information
miraleung committed Oct 23, 2020
commit 2691d8c63a21bb0630aeff392138fa78cefc9bc8
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ java_library(
"@com_google_auto_value_auto_value_annotations//jar",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_guava_guava//jar",
"@com_google_protobuf//:protobuf_java",
"@javax_validation_javax_validation_api//jar",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.protobuf.ByteString;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -64,6 +65,9 @@ public enum TypeKind {
public static final TypeNode SHORT_OBJECT =
withReference(ConcreteReference.withClazz(Short.class));

public static final TypeNode BYTESTRING =
TypeNode.withReference(ConcreteReference.withClazz(ByteString.class));

private static final Map<TypeNode, TypeNode> BOXED_TYPE_MAP = createBoxedTypeMap();

public static final TypeNode VOID = builder().setTypeKind(TypeKind.VOID).build();
Expand Down Expand Up @@ -187,7 +191,7 @@ public boolean isPrimitiveType() {
}

public boolean isProtoPrimitiveType() {
return isPrimitiveType() || this.equals(TypeNode.STRING);
return isPrimitiveType() || this.equals(TypeNode.STRING) || this.equals(TypeNode.BYTESTRING);
}

public boolean isSupertypeOrEquals(TypeNode other) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.google.common.base.Preconditions;
import com.google.longrunning.Operation;
import com.google.protobuf.Any;
import com.google.protobuf.ByteString;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -46,8 +45,6 @@ public class DefaultValueComposer {
private static TypeNode OPERATION_TYPE =
TypeNode.withReference(ConcreteReference.withClazz(Operation.class));
private static TypeNode ANY_TYPE = TypeNode.withReference(ConcreteReference.withClazz(Any.class));
private static TypeNode BYTESTRING_TYPE =
TypeNode.withReference(ConcreteReference.withClazz(ByteString.class));

static Expr createDefaultValue(
MethodArgument methodArg, Map<String, ResourceName> resourceNames) {
Expand Down Expand Up @@ -126,10 +123,10 @@ static Expr createDefaultValue(Field f) {
PrimitiveValue.builder().setType(f.type()).setValue("true").build());
}

if (f.type().equals(BYTESTRING_TYPE)) {
if (f.type().equals(TypeNode.BYTESTRING)) {
return VariableExpr.builder()
.setStaticReferenceType(BYTESTRING_TYPE)
.setVariable(Variable.builder().setName("EMPTY").setType(BYTESTRING_TYPE).build())
.setStaticReferenceType(TypeNode.BYTESTRING)
.setVariable(Variable.builder().setName("EMPTY").setType(TypeNode.BYTESTRING).build())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ private static MethodDefinition createRpcTestMethod(
"No repeated field found for paged method %s with output message type %s",
method.name(), methodOutputMessage.name()));

// Must be a non-repeated type.
repeatedResponseType = repeatedPagedResultsField.type();
responsesElementVarExpr =
VariableExpr.withVariable(
Expand All @@ -506,7 +507,7 @@ private static MethodDefinition createRpcTestMethod(
Field.builder()
.setType(repeatedResponseType)
.setName("responsesElement")
.setIsMessage(true)
.setIsMessage(!repeatedResponseType.isProtoPrimitiveType())
.build()))
.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public class LoggingServiceV2ClientTest {

@Test
public void listLogsTest() throws Exception {
String responsesElement = String.newBuilder().build();
String responsesElement = "responsesElement-318365110";
ListLogsResponse expectedResponse =
ListLogsResponse.newBuilder()
.setNextPageToken("")
Expand Down Expand Up @@ -387,7 +387,7 @@ public class LoggingServiceV2ClientTest {

@Test
public void listLogsTest2() throws Exception {
String responsesElement = String.newBuilder().build();
String responsesElement = "responsesElement-318365110";
ListLogsResponse expectedResponse =
ListLogsResponse.newBuilder()
.setNextPageToken("")
Expand Down Expand Up @@ -431,7 +431,7 @@ public class LoggingServiceV2ClientTest {

@Test
public void listLogsTest3() throws Exception {
String responsesElement = String.newBuilder().build();
String responsesElement = "responsesElement-318365110";
ListLogsResponse expectedResponse =
ListLogsResponse.newBuilder()
.setNextPageToken("")
Expand Down Expand Up @@ -475,7 +475,7 @@ public class LoggingServiceV2ClientTest {

@Test
public void listLogsTest4() throws Exception {
String responsesElement = String.newBuilder().build();
String responsesElement = "responsesElement-318365110";
ListLogsResponse expectedResponse =
ListLogsResponse.newBuilder()
.setNextPageToken("")
Expand Down Expand Up @@ -519,7 +519,7 @@ public class LoggingServiceV2ClientTest {

@Test
public void listLogsTest5() throws Exception {
String responsesElement = String.newBuilder().build();
String responsesElement = "responsesElement-318365110";
ListLogsResponse expectedResponse =
ListLogsResponse.newBuilder()
.setNextPageToken("")
Expand Down