From dc542b304cec05ba1b4fee5c8a400670630de1c8 Mon Sep 17 00:00:00 2001 From: Diego Alonso Marquez Palacios Date: Tue, 28 May 2024 20:24:58 -0400 Subject: [PATCH] improve coverage --- .../com/google/api/generator/gapic/protowriter/Writer.java | 6 +++--- .../google/api/generator/gapic/composer/ComposerTest.java | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protowriter/Writer.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protowriter/Writer.java index 3fc6f8d361..93daab29b7 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protowriter/Writer.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protowriter/Writer.java @@ -77,13 +77,13 @@ protected static CodeGeneratorResponse write( jos.finish(); jos.flush(); - CodeGeneratorResponse.Builder responseBuilder = CodeGeneratorResponse.newBuilder(); - responseBuilder + CodeGeneratorResponse.Builder response = CodeGeneratorResponse.newBuilder(); + response .setSupportedFeatures(CodeGeneratorResponse.Feature.FEATURE_PROTO3_OPTIONAL_VALUE) .addFileBuilder() .setName(outputFilePath) .setContentBytes(output.toByteString()); - return responseBuilder.build(); + return response.build(); } public static CodeGeneratorResponse write( diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java index 77e16c2c24..e7a2193e7d 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java @@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import com.google.api.generator.engine.ast.ClassDefinition; @@ -166,6 +167,11 @@ public void testEmptyGapicContext_doesNotThrow() { Composer.composeServiceClasses(GapicContext.EMPTY); } + @Test + public void testComposePackageInfo_emptyGapicContext_returnsNull() { + assertNull(Composer.composePackageInfo(GapicContext.EMPTY)); + } + private List getTestClassListFromService(Service testService) { GapicClass testClass = GrpcServiceCallableFactoryClassComposer.instance()