diff --git a/.githooks/pre-commit b/.githooks/pre-commit index ae98e89e1a..43fd1adbd4 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -147,6 +147,21 @@ then fi fi +# Check integration tests. +if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] \ + || [ $NUM_INTEGRATION_GOLDEN_FILES_CHANGED -gt 0 ] \ + || [ $NUM_INTEGRATION_BAZEL_FILES_CHANGED -gt 0 ] +then + echo_status "Checking integration tests..." + bazel --batch test --disk_cache="$BAZEL_CACHE_DIR" //test/integration/... + TEST_STATUS=$? + if [ $TEST_STATUS != 0 ] + then + echo_error "Tests failed." "Please fix them and try again." + exit 1 + fi +fi + # Check and fix Bazel format. if [ $NUM_BAZEL_FILES_CHANGED -gt 0 ] then diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java index fca8c84ee9..d36f6c3ac6 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java @@ -39,10 +39,6 @@ class ServiceClientCommentComposer { private static final String SERVICE_DESCRIPTION_INTRO_STRING = "This class provides the ability to make remote calls to the backing service through method " + "calls that map to API methods. Sample code to get started:"; - private static final String SERVICE_DESCRIPTION_CLOSE_STRING = - "Note: close() needs to be called on the echoClient object to clean up resources such as " - + "threads. In the example above, try-with-resources is used, which automatically calls " - + "close()."; private static final String SERVICE_DESCRIPTION_SURFACE_SUMMARY_STRING = "The surface of this class includes several types of Java methods for each of the API's " + "methods:"; @@ -77,6 +73,11 @@ class ServiceClientCommentComposer { "Constructs an instance of %sClient, using the given stub for making calls. This is for" + " advanced usage - prefer using create(%s)."; + private static final String SERVICE_DESCRIPTION_CLOSE_PATTERN = + "Note: close() needs to be called on the %sClient object to clean up resources such as " + + "threads. In the example above, try-with-resources is used, which automatically calls " + + "close()."; + private static final String SERVICE_DESCRIPTION_CUSTOMIZE_SUMMARY_PATTERN = "This class can be customized by passing in a custom instance of %s to create(). For" + " example:"; @@ -117,7 +118,9 @@ static List createClassHeaderComments(Service service) { // TODO(summerji): Add sample code here. // API surface description. - classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_CLOSE_STRING); + classHeaderJavadocBuilder.addParagraph( + String.format( + SERVICE_DESCRIPTION_CLOSE_PATTERN, JavaStyle.toLowerCamelCase(service.name()))); classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_SURFACE_SUMMARY_STRING); classHeaderJavadocBuilder.addOrderedList(SERVICE_DESCRIPTION_SURFACE_DESCRIPTION); classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_SURFACE_CODA_STRING); diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden index f509765142..0f48757f2b 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden @@ -25,7 +25,7 @@ import javax.annotation.Generated; * This class provides the ability to make remote calls to the backing service through method calls * that map to API methods. Sample code to get started: * - *

Note: close() needs to be called on the echoClient object to clean up resources such as + *

Note: close() needs to be called on the identityClient object to clean up resources such as * threads. In the example above, try-with-resources is used, which automatically calls close(). * *

The surface of this class includes several types of Java methods for each of the API's diff --git a/test/integration/goldens/asset/AssetServiceClient.java b/test/integration/goldens/asset/AssetServiceClient.java index c45dcbdabd..9c2ed0b961 100644 --- a/test/integration/goldens/asset/AssetServiceClient.java +++ b/test/integration/goldens/asset/AssetServiceClient.java @@ -47,8 +47,8 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * - *

Note: close() needs to be called on the echoClient object to clean up resources such as - * threads. In the example above, try-with-resources is used, which automatically calls close(). + *

Note: close() needs to be called on the assetServiceClient object to clean up resources such + * as threads. In the example above, try-with-resources is used, which automatically calls close(). * *

The surface of this class includes several types of Java methods for each of the API's * methods: diff --git a/test/integration/goldens/logging/ConfigServiceV2Client.java b/test/integration/goldens/logging/ConfigServiceV2Client.java index 7e0b805328..bfecf0d814 100644 --- a/test/integration/goldens/logging/ConfigServiceV2Client.java +++ b/test/integration/goldens/logging/ConfigServiceV2Client.java @@ -44,8 +44,9 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * - *

Note: close() needs to be called on the echoClient object to clean up resources such as - * threads. In the example above, try-with-resources is used, which automatically calls close(). + *

Note: close() needs to be called on the configServiceV2Client object to clean up resources + * such as threads. In the example above, try-with-resources is used, which automatically calls + * close(). * *

The surface of this class includes several types of Java methods for each of the API's * methods: diff --git a/test/integration/goldens/logging/LoggingServiceV2Client.java b/test/integration/goldens/logging/LoggingServiceV2Client.java index 838256ea3a..9f9406c0d2 100644 --- a/test/integration/goldens/logging/LoggingServiceV2Client.java +++ b/test/integration/goldens/logging/LoggingServiceV2Client.java @@ -46,8 +46,9 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * - *

Note: close() needs to be called on the echoClient object to clean up resources such as - * threads. In the example above, try-with-resources is used, which automatically calls close(). + *

Note: close() needs to be called on the loggingServiceV2Client object to clean up resources + * such as threads. In the example above, try-with-resources is used, which automatically calls + * close(). * *

The surface of this class includes several types of Java methods for each of the API's * methods: diff --git a/test/integration/goldens/logging/MetricsServiceV2Client.java b/test/integration/goldens/logging/MetricsServiceV2Client.java index 2a1fefb209..01fb3da302 100644 --- a/test/integration/goldens/logging/MetricsServiceV2Client.java +++ b/test/integration/goldens/logging/MetricsServiceV2Client.java @@ -43,8 +43,9 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * - *

Note: close() needs to be called on the echoClient object to clean up resources such as - * threads. In the example above, try-with-resources is used, which automatically calls close(). + *

Note: close() needs to be called on the metricsServiceV2Client object to clean up resources + * such as threads. In the example above, try-with-resources is used, which automatically calls + * close(). * *

The surface of this class includes several types of Java methods for each of the API's * methods: diff --git a/test/integration/goldens/redis/CloudRedisClient.java b/test/integration/goldens/redis/CloudRedisClient.java index 305a9d0e8f..158d71fc5b 100644 --- a/test/integration/goldens/redis/CloudRedisClient.java +++ b/test/integration/goldens/redis/CloudRedisClient.java @@ -67,7 +67,7 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * - *

Note: close() needs to be called on the echoClient object to clean up resources such as + *

Note: close() needs to be called on the cloudRedisClient object to clean up resources such as * threads. In the example above, try-with-resources is used, which automatically calls close(). * *

The surface of this class includes several types of Java methods for each of the API's