diff --git a/WORKSPACE b/WORKSPACE index f083537c2e..dc02fcb118 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -33,7 +33,7 @@ jvm_maven_import_external( # which in its turn, prioritizes actual generated clients runtime dependencies # over the generator dependencies. -_gax_java_version = "2.12.2" +_gax_java_version = "2.19.0" http_archive( name = "com_google_api_gax_java", diff --git a/rules_java_gapic/java_gapic.bzl b/rules_java_gapic/java_gapic.bzl index cf5f1f6d55..eb2cdee79a 100644 --- a/rules_java_gapic/java_gapic.bzl +++ b/rules_java_gapic/java_gapic.bzl @@ -189,6 +189,7 @@ def _java_gapic_srcjar( service_yaml, # possible values are: "grpc", "rest", "grpc+rest" transport, + rest_numeric_enums, # Can be used to provide a java_library with a customized generator, # like the one which dumps descriptor to a file for future debugging. java_generator_name = "java_gapic", @@ -213,6 +214,9 @@ def _java_gapic_srcjar( if transport: opt_args.append("transport=%s" % transport) + if rest_numeric_enums: + opt_args.append("rest-numeric-enums") + # Produces the GAPIC metadata file if this flag is set. to any value. # Protoc invocation: --java_gapic_opt=metadata plugin_args = ["metadata"] @@ -240,6 +244,7 @@ def java_gapic_library( test_deps = [], # possible values are: "grpc", "rest", "grpc+rest" transport = None, + rest_numeric_enums = False, **kwargs): srcjar_name = name + "_srcjar" raw_srcjar_name = srcjar_name + "_raw" @@ -251,6 +256,7 @@ def java_gapic_library( gapic_yaml = gapic_yaml, service_yaml = service_yaml, transport = transport, + rest_numeric_enums = rest_numeric_enums, java_generator_name = "java_gapic", **kwargs ) @@ -391,6 +397,7 @@ def java_generator_request_dump( gapic_yaml = None, service_yaml = None, transport = None, + rest_numeric_enums = False, **kwargs): _java_gapic_srcjar( name = name, @@ -399,6 +406,7 @@ def java_generator_request_dump( gapic_yaml = gapic_yaml, service_yaml = service_yaml, transport = transport, + rest_numeric_enums = rest_numeric_enums, java_generator_name = "code_generator_request_dumper", **kwargs ) diff --git a/src/main/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java index b2dc6969ce..c2f4fb7473 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java @@ -187,7 +187,8 @@ public GapicClass generate(GapicContext context, Service service) { protoMethodNameToDescriptorVarExprs, callableClassMemberVarExprs, classMemberVarExprs, - messageTypes); + messageTypes, + context.restNumericEnumsEnabled()); StubCommentComposer commentComposer = new StubCommentComposer(getTransportContext().transportNames().get(0)); @@ -225,7 +226,8 @@ protected abstract Statement createMethodDescriptorVariableDecl( Service service, Method protoMethod, VariableExpr methodDescriptorVarExpr, - Map messageTypes); + Map messageTypes, + boolean restNumericEnumsEnabled); protected boolean generateOperationsStubLogic(Service service) { return true; @@ -274,7 +276,8 @@ protected List createClassStatements( Map protoMethodNameToDescriptorVarExprs, Map callableClassMemberVarExprs, Map classMemberVarExprs, - Map messageTypes) { + Map messageTypes, + boolean restNumericEnumsEnabled) { List classStatements = new ArrayList<>(); classStatements.addAll(createTypeRegistry(service)); @@ -284,7 +287,7 @@ protected List createClassStatements( for (Statement statement : createMethodDescriptorVariableDecls( - service, protoMethodNameToDescriptorVarExprs, messageTypes)) { + service, protoMethodNameToDescriptorVarExprs, messageTypes, restNumericEnumsEnabled)) { classStatements.add(statement); classStatements.add(EMPTY_LINE_STATEMENT); } @@ -301,13 +304,18 @@ protected List createClassStatements( protected List createMethodDescriptorVariableDecls( Service service, Map protoMethodNameToDescriptorVarExprs, - Map messageTypes) { + Map messageTypes, + boolean restNumericEnumsEnabled) { return service.methods().stream() .filter(this::isSupportedMethod) .map( m -> createMethodDescriptorVariableDecl( - service, m, protoMethodNameToDescriptorVarExprs.get(m.name()), messageTypes)) + service, + m, + protoMethodNameToDescriptorVarExprs.get(m.name()), + messageTypes, + restNumericEnumsEnabled)) .collect(Collectors.toList()); } diff --git a/src/main/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposer.java index a33056dad4..d6eedb9987 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposer.java @@ -95,7 +95,8 @@ protected Statement createMethodDescriptorVariableDecl( Service service, Method protoMethod, VariableExpr methodDescriptorVarExpr, - Map messageTypes) { + Map messageTypes, + boolean restNumericEnumsEnabled) { MethodInvocationExpr methodDescriptorMaker = MethodInvocationExpr.builder() .setMethodName("newBuilder") diff --git a/src/main/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposer.java index 01a0f65009..fa4d71498c 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposer.java @@ -129,7 +129,8 @@ protected Statement createMethodDescriptorVariableDecl( Service service, Method protoMethod, VariableExpr methodDescriptorVarExpr, - Map messageTypes) { + Map messageTypes, + boolean restNumericEnumsEnabled) { MethodInvocationExpr expr = MethodInvocationExpr.builder() .setMethodName("newBuilder") @@ -152,7 +153,11 @@ protected Statement createMethodDescriptorVariableDecl( expr = methodMaker.apply("setHttpMethod", getHttpMethodTypeExpr(protoMethod)).apply(expr); expr = methodMaker.apply("setType", getMethodTypeExpr(protoMethod)).apply(expr); expr = - methodMaker.apply("setRequestFormatter", getRequestFormatterExpr(protoMethod)).apply(expr); + methodMaker + .apply( + "setRequestFormatter", + getRequestFormatterExpr(protoMethod, restNumericEnumsEnabled)) + .apply(expr); expr = methodMaker.apply("setResponseParser", setResponseParserExpr(protoMethod)).apply(expr); if (protoMethod.isOperationPollingMethod() || protoMethod.hasLro()) { @@ -320,7 +325,7 @@ protected List createGetMethodDescriptorsMethod( .build(); } - private List getRequestFormatterExpr(Method protoMethod) { + private List getRequestFormatterExpr(Method protoMethod, boolean restNumericEnumsEnabled) { BiFunction, Function> methodMaker = getMethodMaker(); @@ -351,7 +356,8 @@ private List getRequestFormatterExpr(Method protoMethod) { protoMethod, extractorVarType, protoMethod.httpBindings().pathParameters(), - "putPathParam"))) + "putPathParam", + restNumericEnumsEnabled))) .apply(expr); if (!protoMethod.httpBindings().lowerCamelAdditionalPatterns().isEmpty()) { @@ -387,7 +393,8 @@ private List getRequestFormatterExpr(Method protoMethod) { protoMethod, extractorVarType, protoMethod.httpBindings().queryParameters(), - "putQueryParam"))) + "putQueryParam", + restNumericEnumsEnabled))) .apply(expr); extractorVarType = TypeNode.STRING; @@ -404,7 +411,8 @@ private List getRequestFormatterExpr(Method protoMethod) { ? protoMethod.httpBindings().pathParameters() : protoMethod.httpBindings().bodyParameters(), "toBody", - asteriskBody))) + asteriskBody, + restNumericEnumsEnabled))) .apply(expr); expr = methodMaker.apply("build", Collections.emptyList()).apply(expr); @@ -771,7 +779,8 @@ private Expr createBodyFieldsExtractorClassInstance( TypeNode extractorReturnType, Set httpBindingFieldNames, String serializerMethodName, - boolean asteriskBody) { + boolean asteriskBody, + boolean restNumericEnumEnabled) { List bodyStatements = new ArrayList<>(); Expr returnExpr = null; @@ -844,6 +853,13 @@ private Expr createBodyFieldsExtractorClassInstance( paramsPutArgs.add(ValueExpr.withValue(StringObjectValue.withValue(bodyParamName))); paramsPutArgs.add(prevExpr); + PrimitiveValue primitiveValue = + PrimitiveValue.builder() + .setType(TypeNode.BOOLEAN) + .setValue(String.valueOf(restNumericEnumEnabled)) + .build(); + paramsPutArgs.add(ValueExpr.withValue(primitiveValue)); + returnExpr = MethodInvocationExpr.builder() .setExprReferenceExpr(serializerExpr) @@ -866,7 +882,8 @@ private Expr createFieldsExtractorClassInstance( Method method, TypeNode extractorReturnType, Set httpBindingFieldNames, - String serializerMethodName) { + String serializerMethodName, + boolean restNumericEnumsEnabled) { List bodyStatements = new ArrayList<>(); VariableExpr fieldsVarExpr = @@ -980,6 +997,23 @@ private Expr createFieldsExtractorClassInstance( } } + if (restNumericEnumsEnabled && serializerMethodName.equals("putQueryParam")) { + ImmutableList.Builder paramsPutArgs = ImmutableList.builder(); + + paramsPutArgs.add(fieldsVarExpr); + paramsPutArgs.add(ValueExpr.withValue(StringObjectValue.withValue("$alt"))); + paramsPutArgs.add(ValueExpr.withValue(StringObjectValue.withValue("json;enum-encoding=int"))); + + Expr paramsPutExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(serializerVarExpr) + .setMethodName(serializerMethodName) + .setArguments(paramsPutArgs.build()) + .setReturnType(extractorReturnType) + .build(); + bodyStatements.add(ExprStatement.withExpr(paramsPutExpr)); + } + // Overrides FieldsExtractor // (https://github.com/googleapis/gax-java/blob/12b18ee255d3fabe13bb3969df40753b29f830d5/gax-httpjson/src/main/java/com/google/api/gax/httpjson/FieldsExtractor.java). return LambdaExpr.builder() diff --git a/src/main/java/com/google/api/generator/gapic/model/GapicContext.java b/src/main/java/com/google/api/generator/gapic/model/GapicContext.java index 6d891b6256..8fdba8d3ee 100644 --- a/src/main/java/com/google/api/generator/gapic/model/GapicContext.java +++ b/src/main/java/com/google/api/generator/gapic/model/GapicContext.java @@ -47,6 +47,8 @@ public abstract class GapicContext { public abstract boolean gapicMetadataEnabled(); + public abstract boolean restNumericEnumsEnabled(); + public GapicMetadata gapicMetadata() { return gapicMetadata; } @@ -81,7 +83,8 @@ static GapicMetadata defaultGapicMetadata() { public static Builder builder() { return new AutoValue_GapicContext.Builder() .setMixinServices(Collections.emptyList()) - .setGapicMetadataEnabled(false); + .setGapicMetadataEnabled(false) + .setRestNumericEnumsEnabled(false); } @AutoValue.Builder @@ -108,6 +111,8 @@ public Builder setHelperResourceNames(Set helperResourceNames) { public abstract Builder setGapicMetadataEnabled(boolean gapicMetadataEnabled); + public abstract Builder setRestNumericEnumsEnabled(boolean restNumericEnumsEnabled); + public abstract Builder setTransport(Transport transport); abstract ImmutableMap resourceNames(); diff --git a/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java b/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java index 30cdc6a690..35ba86dcc6 100644 --- a/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java +++ b/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java @@ -120,6 +120,7 @@ public static GapicContext parse(CodeGeneratorRequest request) { Optional transportOpt = PluginArgumentParser.parseTransport(request); boolean willGenerateMetadata = PluginArgumentParser.hasMetadataFlag(request); + boolean willGenerateNumericEnum = PluginArgumentParser.hasNumericEnumFlag(request); Optional serviceConfigPathOpt = PluginArgumentParser.parseJsonConfigPath(request); Optional serviceConfigOpt = @@ -216,6 +217,7 @@ public static GapicContext parse(CodeGeneratorRequest request) { .setGapicMetadataEnabled(willGenerateMetadata) .setServiceYamlProto(serviceYamlProtoOpt.orElse(null)) .setTransport(transport) + .setRestNumericEnumsEnabled(willGenerateNumericEnum) .build(); } diff --git a/src/main/java/com/google/api/generator/gapic/protoparser/PluginArgumentParser.java b/src/main/java/com/google/api/generator/gapic/protoparser/PluginArgumentParser.java index d5a7de1f79..f56e0621a9 100644 --- a/src/main/java/com/google/api/generator/gapic/protoparser/PluginArgumentParser.java +++ b/src/main/java/com/google/api/generator/gapic/protoparser/PluginArgumentParser.java @@ -29,6 +29,7 @@ public class PluginArgumentParser { @VisibleForTesting static final String KEY_GRPC_SERVICE_CONFIG = "grpc-service-config"; @VisibleForTesting static final String KEY_GAPIC_CONFIG = "gapic-config"; @VisibleForTesting static final String KEY_METADATA = "metadata"; + @VisibleForTesting static final String KEY_NUMERIC_ENUM = "rest-numeric-enums"; @VisibleForTesting static final String KEY_SERVICE_YAML_CONFIG = "api-service-config"; @VisibleForTesting static final String KEY_TRANSPORT = "transport"; @@ -53,7 +54,11 @@ static Optional parseTransport(CodeGeneratorRequest request) { } static boolean hasMetadataFlag(CodeGeneratorRequest request) { - return hasMetadataFlag(request.getParameter()); + return hasFlag(request.getParameter(), KEY_METADATA); + } + + static boolean hasNumericEnumFlag(CodeGeneratorRequest request) { + return hasFlag(request.getParameter(), KEY_NUMERIC_ENUM); } /** Expects a comma-separated list of file paths. */ @@ -89,8 +94,8 @@ private static Optional parseConfigArgument(String pluginProtocArgument, } @VisibleForTesting - static boolean hasMetadataFlag(String pluginProtocArgument) { - return Arrays.stream(pluginProtocArgument.split(COMMA)).anyMatch(s -> s.equals(KEY_METADATA)); + static boolean hasFlag(String pluginProtocArgument, String flagKey) { + return Arrays.stream(pluginProtocArgument.split(COMMA)).anyMatch(s -> s.equals(flagKey)); } private static Optional parseFileArgument( diff --git a/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/HttpJsonEchoStub.golden b/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/HttpJsonEchoStub.golden index 567b4b404a..6d6d179d9b 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/HttpJsonEchoStub.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/HttpJsonEchoStub.golden @@ -78,7 +78,8 @@ public class HttpJsonEchoStub extends EchoStub { }) .setRequestBodyExtractor( request -> - ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().build(), false)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -112,7 +113,8 @@ public class HttpJsonEchoStub extends EchoStub { return fields; }) .setRequestBodyExtractor( - request -> ProtoRestSerializer.create().toBody("error", request.getError())) + request -> + ProtoRestSerializer.create().toBody("error", request.getError(), false)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -146,7 +148,8 @@ public class HttpJsonEchoStub extends EchoStub { }) .setRequestBodyExtractor( request -> - ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().build(), false)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -180,7 +183,8 @@ public class HttpJsonEchoStub extends EchoStub { }) .setRequestBodyExtractor( request -> - ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().build(), false)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -211,7 +215,8 @@ public class HttpJsonEchoStub extends EchoStub { }) .setRequestBodyExtractor( request -> - ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().build(), false)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -245,7 +250,8 @@ public class HttpJsonEchoStub extends EchoStub { }) .setRequestBodyExtractor( request -> - ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().build(), false)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -276,7 +282,8 @@ public class HttpJsonEchoStub extends EchoStub { }) .setRequestBodyExtractor( request -> - ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().build(), false)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -312,7 +319,8 @@ public class HttpJsonEchoStub extends EchoStub { }) .setRequestBodyExtractor( request -> - ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().build(), false)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() diff --git a/src/test/java/com/google/api/generator/gapic/composer/rest/RestTestProtoLoader.java b/src/test/java/com/google/api/generator/gapic/composer/rest/RestTestProtoLoader.java index 85aef15244..3713242c1f 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/rest/RestTestProtoLoader.java +++ b/src/test/java/com/google/api/generator/gapic/composer/rest/RestTestProtoLoader.java @@ -73,6 +73,7 @@ public GapicContext parseCompliance() { .setServiceConfig(config) .setHelperResourceNames(outputResourceNames) .setTransport(getTransport()) + .setRestNumericEnumsEnabled(true) .build(); } } diff --git a/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/HttpJsonComplianceStub.golden b/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/HttpJsonComplianceStub.golden index b4def23fc8..f2836caf50 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/HttpJsonComplianceStub.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/HttpJsonComplianceStub.golden @@ -55,11 +55,13 @@ public class HttpJsonComplianceStub extends ComplianceStub { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> - ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -92,10 +94,12 @@ public class HttpJsonComplianceStub extends ComplianceStub { serializer.putQueryParam(fields, "name", request.getName()); serializer.putQueryParam( fields, "serverVerify", request.getServerVerify()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( - request -> ProtoRestSerializer.create().toBody("info", request.getInfo())) + request -> + ProtoRestSerializer.create().toBody("info", request.getInfo(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -129,6 +133,7 @@ public class HttpJsonComplianceStub extends ComplianceStub { serializer.putQueryParam(fields, "name", request.getName()); serializer.putQueryParam( fields, "serverVerify", request.getServerVerify()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) @@ -177,6 +182,7 @@ public class HttpJsonComplianceStub extends ComplianceStub { serializer.putQueryParam(fields, "name", request.getName()); serializer.putQueryParam( fields, "serverVerify", request.getServerVerify()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) @@ -223,6 +229,7 @@ public class HttpJsonComplianceStub extends ComplianceStub { serializer.putQueryParam(fields, "name", request.getName()); serializer.putQueryParam( fields, "serverVerify", request.getServerVerify()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) @@ -266,6 +273,7 @@ public class HttpJsonComplianceStub extends ComplianceStub { serializer.putQueryParam(fields, "name", request.getName()); serializer.putQueryParam( fields, "serverVerify", request.getServerVerify()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) diff --git a/src/test/java/com/google/api/generator/gapic/protoparser/PluginArgumentParserTest.java b/src/test/java/com/google/api/generator/gapic/protoparser/PluginArgumentParserTest.java index 2dcaa298cf..bebe828f71 100644 --- a/src/test/java/com/google/api/generator/gapic/protoparser/PluginArgumentParserTest.java +++ b/src/test/java/com/google/api/generator/gapic/protoparser/PluginArgumentParserTest.java @@ -14,10 +14,13 @@ package com.google.api.generator.gapic.protoparser; +import static com.google.api.generator.gapic.protoparser.PluginArgumentParser.KEY_METADATA; +import static com.google.api.generator.gapic.protoparser.PluginArgumentParser.KEY_NUMERIC_ENUM; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest; import java.util.Arrays; import org.junit.Test; @@ -226,26 +229,44 @@ public void parseServiceYamlPath_noneFound() { } @Test - public void parseMetadataFlag_noneFound() { + public void hasMetadataFlag() { + CodeGeneratorRequest request = + CodeGeneratorRequest.newBuilder() + .setParameter(String.join(",", KEY_METADATA, "does-not-matter")) + .build(); + assertTrue(PluginArgumentParser.hasMetadataFlag(request)); + } + + @Test + public void hasNumericEnumFlag() { + CodeGeneratorRequest request = + CodeGeneratorRequest.newBuilder() + .setParameter(String.join(",", KEY_NUMERIC_ENUM, "does-not-matter")) + .build(); + assertTrue(PluginArgumentParser.hasNumericEnumFlag(request)); + } + + @Test + public void hasFlag_noneFound() { String jsonPath = "/tmp/foo_grpc_service_config.json"; String gapicPath = ""; String rawArgument = String.join(",", Arrays.asList(createGrpcServiceConfig(jsonPath), gapicPath)); - assertFalse(PluginArgumentParser.hasMetadataFlag(rawArgument)); + assertFalse(PluginArgumentParser.hasFlag(rawArgument, KEY_METADATA)); // Wrong casing. rawArgument = String.join(",", Arrays.asList("Metadata", createGrpcServiceConfig(jsonPath), gapicPath)); - assertFalse(PluginArgumentParser.hasMetadataFlag(rawArgument)); + assertFalse(PluginArgumentParser.hasFlag(rawArgument, KEY_METADATA)); } @Test - public void parseMetadataFlag_flagFound() { + public void hasFlag_flagFound() { String jsonPath = "/tmp/foo_grpc_service_config.json"; String gapicPath = ""; String rawArgument = String.join(",", Arrays.asList("metadata", createGrpcServiceConfig(jsonPath), gapicPath)); - assertTrue(PluginArgumentParser.hasMetadataFlag(rawArgument)); + assertTrue(PluginArgumentParser.hasFlag(rawArgument, KEY_METADATA)); } private static String createGrpcServiceConfig(String path) { diff --git a/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/stub/HttpJsonAddressesStub.java b/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/stub/HttpJsonAddressesStub.java index 03127d39c6..b040b1a5d8 100644 --- a/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/stub/HttpJsonAddressesStub.java +++ b/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/stub/HttpJsonAddressesStub.java @@ -193,7 +193,7 @@ public class HttpJsonAddressesStub extends AddressesStub { .setRequestBodyExtractor( request -> ProtoRestSerializer.create() - .toBody("addressResource", request.getAddressResource())) + .toBody("addressResource", request.getAddressResource(), false)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder()