From 022e60370b4e2f7767f3add37ea857f6e3bdc481 Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 21 Nov 2022 16:05:30 -0500 Subject: [PATCH 01/11] test: add unit tests for autogenerated module for language --- .../LanguageAutoConfigurationTests.java | 150 ++++++++++++++++++ .../test/resources/fake-credential-key.json | 12 ++ 2 files changed, 162 insertions(+) create mode 100644 generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java create mode 100644 generated/language/src/test/resources/fake-credential-key.json diff --git a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java new file mode 100644 index 0000000000..2a06f8053a --- /dev/null +++ b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java @@ -0,0 +1,150 @@ +/* + * Copyright 2022 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 + * + * https://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.cloud.language.v1.spring; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.auth.Credentials; +import com.google.auth.oauth2.ServiceAccountCredentials; +import com.google.cloud.language.v1.LanguageServiceClient; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.AutoConfigurations; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.threeten.bp.Duration; + +class LanguageAutoConfigurationTests { + + private static final String SERVICE_CREDENTIAL_LOCATION = + "src/test/resources/fake-credential-key.json"; + private static final String SERVICE_CREDENTIAL_CLIENT_ID = "45678"; + private static final String SERVICE_OVERRIDE_CLIENT_ID = "56789"; + + private ApplicationContextRunner contextRunner = + new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(LanguageServiceSpringAutoConfiguration.class)); + + @Test + void testLanguageServiceClientCreated() { + this.contextRunner + .withPropertyValues( + "com.google.cloud.language.v1.spring.auto.language-service.enabled=true") + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + assertThat(client).isNotNull(); + }); + } + + @Test + void testShouldTakeServiceCredentials() { + this.contextRunner + .withPropertyValues( + "com.google.cloud.language.v1.spring.auto.language-service.enabled=true", + "com.google.cloud.language.v1.spring.auto.language-service.credentials.location=file:" + + SERVICE_CREDENTIAL_LOCATION) + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + Credentials credentials = + client.getSettings().getCredentialsProvider().getCredentials(); + assertThat(((ServiceAccountCredentials) credentials).getClientId()) + .isEqualTo(SERVICE_CREDENTIAL_CLIENT_ID); + }); + } + + @Test + void testShouldUseDefaultGrpcTransport() { + this.contextRunner + .withPropertyValues( + "com.google.cloud.language.v1.spring.auto.language-service.enabled=true") + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + String transportName = + client.getSettings().getTransportChannelProvider().getTransportName(); + assertThat(transportName).isEqualTo("grpc"); + }); + } + + @Test + void testQuotaProjectIdFromProperties() { + this.contextRunner + .withPropertyValues( + "com.google.cloud.language.v1.spring.auto.language-service.enabled=true", + "com.google.cloud.language.v1.spring.auto.language-service.quota-project-id=" + + SERVICE_OVERRIDE_CLIENT_ID) + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + String quotaProjectId = client.getSettings().getQuotaProjectId(); + assertThat(quotaProjectId).isEqualTo(SERVICE_OVERRIDE_CLIENT_ID); + }); + } + + @Test + void testExecutorThreadCountFromProperties() { + this.contextRunner + .withPropertyValues( + "com.google.cloud.language.v1.spring.auto.language-service.enabled=true", + "com.google.cloud.language.v1.spring.auto.language-service.executor-thread-count=3") + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + InstantiatingExecutorProvider backgroundExecutorProvider = + ((InstantiatingExecutorProvider) + client.getSettings().getBackgroundExecutorProvider()); + assertThat(backgroundExecutorProvider.toBuilder().getExecutorThreadCount()) + .isEqualTo(3); + }); + } + + @Test + void testRetrySettingsFromProperties() { + this.contextRunner + .withPropertyValues( + "com.google.cloud.language.v1.spring.auto.language-service.enabled=true", + "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-retry-delay-multiplier=" + + "2", + "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-rpc-timeout-multiplier=" + + "2", + "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-initial-retry-delay=" + + "PT0.5S", + "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-max-retry-delay=" + + "PT30S", + "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-initial-rpc-timeout=" + + "PT5M", + "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-max-rpc-timeout=" + + "PT15M", + "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-total-timeout=" + + "PT10M") + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + RetrySettings retrySettings = + client.getSettings().analyzeSentimentSettings().getRetrySettings(); + assertThat(retrySettings.getRetryDelayMultiplier()).isEqualTo(2); + assertThat(retrySettings.getRpcTimeoutMultiplier()).isEqualTo(2); + assertThat(retrySettings.getInitialRetryDelay()).isEqualTo(Duration.ofMillis(500)); + assertThat(retrySettings.getMaxRetryDelay()).isEqualTo(Duration.ofSeconds(30)); + assertThat(retrySettings.getInitialRpcTimeout()).isEqualTo(Duration.ofMinutes(5)); + assertThat(retrySettings.getMaxRpcTimeout()).isEqualTo(Duration.ofMinutes(15)); + assertThat(retrySettings.getTotalTimeout()).isEqualTo(Duration.ofMinutes(10)); + }); + } +} diff --git a/generated/language/src/test/resources/fake-credential-key.json b/generated/language/src/test/resources/fake-credential-key.json new file mode 100644 index 0000000000..c326210852 --- /dev/null +++ b/generated/language/src/test/resources/fake-credential-key.json @@ -0,0 +1,12 @@ +{ + "type": "service_account", + "project_id": "fake-project-id", + "private_key_id": "fake-key", + "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEugIBADANBgkqhkiG9w0BAQEFAASCBKQwggSgAgEAAoIBAQCh/y7v8lk1Ko79\nWVbQZCtmd0PXZr8WrUmmdEv2aaQQF/ed/KL2M/T2dbTlQ4EeOP+aK/5T8JSuxxZ5\na6e8TsovKXJz2qjeBLpzNFbx2xSyldYziC6v+bRCPKWCQLRNVdz/iYmOqjOu1/Ri\n8njOF7gG3XMQxryl9pmpJbVXj38Zw1n8mefT/g/+l6fObsVIgLs9WjGE9HDMKzx8\n9Ph7f+Ru1EuBrFOgHfKvWeIjVtQWqr3Dz+M1KyLFezYtXGB5HLg02sPJM+tMdcMj\nL9xpuodc6noBBeKvijEfTErLIaO1cJS5AgFHDyEsspaRdgXpJroM4w8ZSj3J0Wp7\ntJ7PeaG/AgMBAAECgf9ubAMSi59DHj9Zcgw7AAyVS7ZynRaj3nrVe3BMBrZOQggH\nKK3sJH5VgOZNYDYi47dW36X8kYDHoe0v1rH/KbWncBkT33g73f05ifO56Buzn27i\nsXEhgpPckno+ztwX2u9JP/cDyAByrcFnsN+nm4NVKp3EUbNFbVJQeeOiS63XYLvO\nuIUGlYJrnqa2zWp/YwhOmvZz5fNhfN/Js+V8kaA/xK/Dk0xhgvAqv73lgYZyL5pg\nlImHgHIm5alAMpchu4bInv2CjhKsgyPvHZU0Wihdm5it58hME0gN3ekD6lbdsp+1\nEwZ50JXALUPvzeMGXWorxuBUe9hpMcDmugR6rjECgYEAzpELFjiX2sNZPDX7cTM0\nYwWCdcvJUVTEapnpWuU2OhDreGMlBAWO6hkTIq6kmBZ0c30o10FNhXBrg0AyesgG\nheY6wO+v4e5hnVIdud2ih7AWDaKXVrb63Z/aF3EUhxcVk0wmnJtQ605cjMjeJOJF\nEyQCGsaiLbsEBsEKrXfLL08CgYEAyMOlz8dCNrEm16rbTE7NZpqql7IJhcAcXB5Z\nGUZicK98W4HnT6r5qPePgCjHnxjXl+/T6siH1B8CxQwtzETI8bu0Jd3ZvL7HZnIS\nHDWiGn72OJnYOvxvq1SvIqdTvlCMKqRQancp8wWP9oubzjS5ZZLGemaqvVL2Occp\nsfUZSpECgYBXPdz/2pEQHNcwXeA/VA/5DlemJpZ1GicGmtB6yjnX1lOM+dqlUy+j\n4Uk6qaXscfdm22KHXxY9mFhgC5oGTzqqDK2d1N1kv4hMqGTTni7Jve3iflwKjKdx\nONUkd2bjEzXSiyP3moVXjDX8Y82mqEXiKqAU7PWL+ONfcuJulxyicwKBgAcPoohR\nSMnlpykUsEvZxa2jKPbW4zDaFeVDh/y0lgfClEwfoIQTzl4b/ucSCBtXY1XLsJdk\nYCqcwJsvl3jEvpCJ+ocOa3cQ+rBmuK5XUJE//+bzukAw2ria7OH6Ip7h9FwXlWB5\nOnd6rZqNRHiXMCIbbHGnpL+t6E0V7Sh+J1qRAoGALRlR4TpW+UQvJIs5iBuF4/vg\n9iWLVOY8QoDYQ1k755EY53Q8tk3fO2ESUyV7A35zu/TQWm7z5PTFCl9R5dpWywMU\nTG7xr3tNVP7oDUN9ofN2ipB99EavN81k3co+nnWwhniJn0zHEpTq9IvGozwGuUjN\nIkiy17wHSSocTzvLDNk=\n-----END PRIVATE KEY-----\n", + "client_email": "test@fake-project.iam.gserviceaccount.com", + "client_id": "45678", + "auth_uri": "https://fake.auth.url.com/o/oauth2/auth", + "token_uri": "https://fake.token.url.com/token", + "auth_provider_x509_cert_url": "https://fake.auth.provider.cert.url.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www.fake.client.cert.com/robot/v1/metadata/x509/test@fake-project.iam.gserviceaccount.com" +} \ No newline at end of file From 3e98009768d7f9891a1b8b6368f957a17dfe775d Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Fri, 16 Dec 2022 16:37:13 -0500 Subject: [PATCH 02/11] WIP: add unit tests for bean and property overrides --- .../LanguageAutoConfigurationTests.java | 146 ++++++++++++------ 1 file changed, 101 insertions(+), 45 deletions(-) diff --git a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java index 2a06f8053a..39f1bc8603 100644 --- a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java +++ b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java @@ -28,6 +28,7 @@ import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.threeten.bp.Duration; +@ExtendWith(MockitoExtension.class) class LanguageAutoConfigurationTests { private static final String SERVICE_CREDENTIAL_LOCATION = @@ -35,27 +36,28 @@ class LanguageAutoConfigurationTests { private static final String SERVICE_CREDENTIAL_CLIENT_ID = "45678"; private static final String SERVICE_OVERRIDE_CLIENT_ID = "56789"; + @Mock private TransportChannel mockTransportChannel; + @Mock private ApiCallContext mockApiCallContext; + @Mock private TransportChannelProvider mockTransportChannelProvider; + @Mock private CredentialsProvider mockCredentialsProvider; + private ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(LanguageServiceSpringAutoConfiguration.class)); @Test void testLanguageServiceClientCreated() { - this.contextRunner - .withPropertyValues( - "com.google.cloud.language.v1.spring.auto.language-service.enabled=true") - .run( - ctx -> { - LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); - assertThat(client).isNotNull(); - }); + this.contextRunner.run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + assertThat(client).isNotNull(); + }); } @Test void testShouldTakeServiceCredentials() { this.contextRunner .withPropertyValues( - "com.google.cloud.language.v1.spring.auto.language-service.enabled=true", "com.google.cloud.language.v1.spring.auto.language-service.credentials.location=file:" + SERVICE_CREDENTIAL_LOCATION) .run( @@ -70,23 +72,19 @@ void testShouldTakeServiceCredentials() { @Test void testShouldUseDefaultGrpcTransport() { - this.contextRunner - .withPropertyValues( - "com.google.cloud.language.v1.spring.auto.language-service.enabled=true") - .run( - ctx -> { - LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); - String transportName = - client.getSettings().getTransportChannelProvider().getTransportName(); - assertThat(transportName).isEqualTo("grpc"); - }); + this.contextRunner.run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + String transportName = + client.getSettings().getTransportChannelProvider().getTransportName(); + assertThat(transportName).isEqualTo("grpc"); + }); } @Test void testQuotaProjectIdFromProperties() { this.contextRunner .withPropertyValues( - "com.google.cloud.language.v1.spring.auto.language-service.enabled=true", "com.google.cloud.language.v1.spring.auto.language-service.quota-project-id=" + SERVICE_OVERRIDE_CLIENT_ID) .run( @@ -101,7 +99,6 @@ void testQuotaProjectIdFromProperties() { void testExecutorThreadCountFromProperties() { this.contextRunner .withPropertyValues( - "com.google.cloud.language.v1.spring.auto.language-service.enabled=true", "com.google.cloud.language.v1.spring.auto.language-service.executor-thread-count=3") .run( ctx -> { @@ -115,36 +112,95 @@ void testExecutorThreadCountFromProperties() { } @Test - void testRetrySettingsFromProperties() { + void customTransportChannelProviderUsedWhenProvided() throws IOException { + when(mockTransportChannelProvider.getTransportName()).thenReturn("grpc"); + when(mockTransportChannelProvider.getTransportChannel()).thenReturn(mockTransportChannel); + when(mockTransportChannel.getEmptyCallContext()).thenReturn(mockApiCallContext); + when(mockApiCallContext.withCredentials(any())).thenReturn(mockApiCallContext); + when(mockApiCallContext.withTransportChannel(any())).thenReturn(mockApiCallContext); + + contextRunner + .withBean( + "defaultLanguageTransportChannelProvider", + TransportChannelProvider.class, + () -> mockTransportChannelProvider) + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + assertThat(client.getSettings().getTransportChannelProvider()) + .isSameAs(mockTransportChannelProvider); + }); + } + + @Test + void customServiceSettingsUsedWhenProvided() throws IOException { + String mockQuotaProjectId = "mockQuotaProjectId"; + LanguageServiceSettings customLanguageServiceSettings = + LanguageServiceSettings.newBuilder() + .setCredentialsProvider(mockCredentialsProvider) + .setQuotaProjectId(mockQuotaProjectId) + .build(); + contextRunner + .withBean( + "languageServiceSettings", + LanguageServiceSettings.class, + () -> customLanguageServiceSettings) + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + assertThat(client.getSettings().getCredentialsProvider()) + .isSameAs(mockCredentialsProvider); + assertThat(client.getSettings().getQuotaProjectId()).isSameAs(mockQuotaProjectId); + }); + } + + @Test + void testServiceRetrySettingsFromProperties() { this.contextRunner .withPropertyValues( - "com.google.cloud.language.v1.spring.auto.language-service.enabled=true", - "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-retry-delay-multiplier=" - + "2", - "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-rpc-timeout-multiplier=" - + "2", - "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-initial-retry-delay=" - + "PT0.5S", - "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-max-retry-delay=" - + "PT30S", - "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-initial-rpc-timeout=" - + "PT5M", - "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-max-rpc-timeout=" - + "PT15M", - "com.google.cloud.language.v1.spring.auto.language-service.analyze-sentiment-total-timeout=" - + "PT10M") + "spring.cloud.gcp.language.language-service.enabled=true", + "spring.cloud.gcp.language.language-service.retry-settings.retry-delay-multiplier=2", + "spring.cloud.gcp.language.language-service.retry-settings.max-retry-delay=PT0.9S") .run( ctx -> { LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); - RetrySettings retrySettings = + + RetrySettings analyzeSentimentRetrySettings = client.getSettings().analyzeSentimentSettings().getRetrySettings(); - assertThat(retrySettings.getRetryDelayMultiplier()).isEqualTo(2); - assertThat(retrySettings.getRpcTimeoutMultiplier()).isEqualTo(2); - assertThat(retrySettings.getInitialRetryDelay()).isEqualTo(Duration.ofMillis(500)); - assertThat(retrySettings.getMaxRetryDelay()).isEqualTo(Duration.ofSeconds(30)); - assertThat(retrySettings.getInitialRpcTimeout()).isEqualTo(Duration.ofMinutes(5)); - assertThat(retrySettings.getMaxRpcTimeout()).isEqualTo(Duration.ofMinutes(15)); - assertThat(retrySettings.getTotalTimeout()).isEqualTo(Duration.ofMinutes(10)); + assertThat(analyzeSentimentRetrySettings.getRetryDelayMultiplier()).isEqualTo(2); + assertThat(analyzeSentimentRetrySettings.getMaxRetryDelay()) + .isEqualTo(Duration.ofMillis(900)); + // if properties only override certain retry settings, others should still take on + // client library defaults + assertThat(analyzeSentimentRetrySettings.getInitialRetryDelay()) + .isEqualTo(Duration.ofMillis(100)); // default + }); + } + + @Test + void testMethodRetrySettingsFromProperties() { + this.contextRunner + .withPropertyValues( + "spring.cloud.gcp.language.language-service.enabled=true", + "spring.cloud.gcp.language.language-service.retry-settings.retry-delay-multiplier=2", + "spring.cloud.gcp.language.language-service.retry-settings.max-retry-delay=PT0.9S", + "spring.cloud.gcp.language.language-service.annotate-text-retry-settings.retry-delay-multiplier=3") + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + + RetrySettings annotateTextRetrySettings = + client.getSettings().annotateTextSettings().getRetrySettings(); + // Method-level override should take precedence over service-level + assertThat(annotateTextRetrySettings.getRetryDelayMultiplier()).isEqualTo(3); + // For settings without method-level overrides but when service-level is provided, + // fall back to that + assertThat(annotateTextRetrySettings.getMaxRetryDelay()) + .isEqualTo(Duration.ofMillis(900)); + // Settings with neither method not service-level overrides should still take on + // client library defaults + assertThat(annotateTextRetrySettings.getInitialRetryDelay()) + .isEqualTo(Duration.ofMillis(100)); // default }); } } From 0f8922ca6533c8ad655a6a2c805eae5a54b161b6 Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 19 Dec 2022 09:35:39 -0500 Subject: [PATCH 03/11] test: update unit tests for bean and property overrides --- .../LanguageAutoConfigurationTests.java | 132 ++++++++++++++++-- 1 file changed, 118 insertions(+), 14 deletions(-) diff --git a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java index 39f1bc8603..af78384651 100644 --- a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java +++ b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java @@ -17,13 +17,25 @@ package com.google.cloud.language.v1.spring; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; +import com.google.api.gax.core.CredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.TransportChannel; +import com.google.api.gax.rpc.TransportChannelProvider; import com.google.auth.Credentials; import com.google.auth.oauth2.ServiceAccountCredentials; import com.google.cloud.language.v1.LanguageServiceClient; +import com.google.cloud.language.v1.LanguageServiceSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import java.io.IOException; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.threeten.bp.Duration; @@ -43,7 +55,9 @@ class LanguageAutoConfigurationTests { private ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(LanguageServiceSpringAutoConfiguration.class)); + .withConfiguration( + AutoConfigurations.of( + GcpContextAutoConfiguration.class, LanguageServiceSpringAutoConfiguration.class)); @Test void testLanguageServiceClientCreated() { @@ -55,7 +69,7 @@ void testLanguageServiceClientCreated() { } @Test - void testShouldTakeServiceCredentials() { + void testServiceCredentialsFromProperties() { this.contextRunner .withPropertyValues( "com.google.cloud.language.v1.spring.auto.language-service.credentials.location=file:" @@ -70,6 +84,15 @@ void testShouldTakeServiceCredentials() { }); } + @Test + void testShouldUseCredentialsBeanWhenPropertiesNotProvided() { + this.contextRunner.run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + assertThat(client.getSettings().getCredentialsProvider()).isNotNull(); + }); + } + @Test void testShouldUseDefaultGrpcTransport() { this.contextRunner.run( @@ -112,7 +135,7 @@ void testExecutorThreadCountFromProperties() { } @Test - void customTransportChannelProviderUsedWhenProvided() throws IOException { + void testCustomTransportChannelProviderUsedWhenProvided() throws IOException { when(mockTransportChannelProvider.getTransportName()).thenReturn("grpc"); when(mockTransportChannelProvider.getTransportChannel()).thenReturn(mockTransportChannel); when(mockTransportChannel.getEmptyCallContext()).thenReturn(mockApiCallContext); @@ -121,7 +144,7 @@ void customTransportChannelProviderUsedWhenProvided() throws IOException { contextRunner .withBean( - "defaultLanguageTransportChannelProvider", + "defaultLanguageServiceTransportChannelProvider", TransportChannelProvider.class, () -> mockTransportChannelProvider) .run( @@ -133,7 +156,7 @@ void customTransportChannelProviderUsedWhenProvided() throws IOException { } @Test - void customServiceSettingsUsedWhenProvided() throws IOException { + void testCustomServiceSettingsUsedWhenProvided() throws IOException { String mockQuotaProjectId = "mockQuotaProjectId"; LanguageServiceSettings customLanguageServiceSettings = LanguageServiceSettings.newBuilder() @@ -155,12 +178,13 @@ void customServiceSettingsUsedWhenProvided() throws IOException { } @Test - void testServiceRetrySettingsFromProperties() { + void testRetrySettingsFromProperties_serviceLevel() { this.contextRunner .withPropertyValues( - "spring.cloud.gcp.language.language-service.enabled=true", - "spring.cloud.gcp.language.language-service.retry-settings.retry-delay-multiplier=2", - "spring.cloud.gcp.language.language-service.retry-settings.max-retry-delay=PT0.9S") + "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.retry-delay-multiplier=" + + "2", + "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-retry-delay=" + + "PT0.9S") .run( ctx -> { LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); @@ -178,13 +202,15 @@ void testServiceRetrySettingsFromProperties() { } @Test - void testMethodRetrySettingsFromProperties() { + void testRetrySettingsFromProperties_serviceAndMethodLevel() { this.contextRunner .withPropertyValues( - "spring.cloud.gcp.language.language-service.enabled=true", - "spring.cloud.gcp.language.language-service.retry-settings.retry-delay-multiplier=2", - "spring.cloud.gcp.language.language-service.retry-settings.max-retry-delay=PT0.9S", - "spring.cloud.gcp.language.language-service.annotate-text-retry-settings.retry-delay-multiplier=3") + "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.retry-delay-multiplier=" + + "2", + "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-retry-delay=" + + "PT0.9S", + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.retry-delay-multiplier=" + + "3") .run( ctx -> { LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); @@ -203,4 +229,82 @@ void testMethodRetrySettingsFromProperties() { .isEqualTo(Duration.ofMillis(100)); // default }); } + + @Test + void testRetrySettingsFromProperties_serviceAndMethodLevel_allRetrySettings() { + this.contextRunner + .withPropertyValues( + // service-level, all configurable settings + "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.retry-delay-multiplier=" + + "2", + "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.rpc-timeout-multiplier=" + + "2", + "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.initial-retry-delay=" + + "PT0.5S", + "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-retry-delay=" + + "PT5S", + "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.initial-rpc-timeout=" + + "PT0.5S", + "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-rpc-timeout=" + + "PT5S", + "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.total-timeout=" + + "PT5M", + "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-attempts=" + + "2", + // method-level, all configurable settings + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.retry-delay-multiplier=" + + "3", + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.rpc-timeout-multiplier=" + + "3", + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.initial-retry-delay=" + + "PT0.6S", + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.max-retry-delay=" + + "PT6S", + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.initial-rpc-timeout=" + + "PT0.6S", + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.max-rpc-timeout=" + + "PT6S", + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.total-timeout=" + + "PT6M", + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.max-attempts=" + + "3") + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + RetrySettings annotateTextRetrySettings = + client.getSettings().annotateTextSettings().getRetrySettings(); + RetrySettings analyzeSentimentRetrySettings = + client.getSettings().analyzeSentimentSettings().getRetrySettings(); + + // Method-level overrides should be used for annotateText + assertThat(annotateTextRetrySettings.getRetryDelayMultiplier()).isEqualTo(3); + assertThat(annotateTextRetrySettings.getRpcTimeoutMultiplier()).isEqualTo(3); + assertThat(annotateTextRetrySettings.getInitialRetryDelay()) + .isEqualTo(Duration.ofMillis(600)); + assertThat(annotateTextRetrySettings.getInitialRpcTimeout()) + .isEqualTo(Duration.ofMillis(600)); + assertThat(annotateTextRetrySettings.getMaxRetryDelay()) + .isEqualTo(Duration.ofSeconds(6)); + assertThat(annotateTextRetrySettings.getMaxRpcTimeout()) + .isEqualTo(Duration.ofSeconds(6)); + assertThat(annotateTextRetrySettings.getTotalTimeout()) + .isEqualTo(Duration.ofMinutes(6)); + assertThat(annotateTextRetrySettings.getMaxAttempts()).isEqualTo(3); + + // Service-level overrides should be used for analyzeSentiment + assertThat(analyzeSentimentRetrySettings.getRetryDelayMultiplier()).isEqualTo(2); + assertThat(analyzeSentimentRetrySettings.getRpcTimeoutMultiplier()).isEqualTo(2); + assertThat(analyzeSentimentRetrySettings.getInitialRetryDelay()) + .isEqualTo(Duration.ofMillis(500)); + assertThat(analyzeSentimentRetrySettings.getInitialRpcTimeout()) + .isEqualTo(Duration.ofMillis(500)); + assertThat(analyzeSentimentRetrySettings.getMaxRetryDelay()) + .isEqualTo(Duration.ofSeconds(5)); + assertThat(analyzeSentimentRetrySettings.getMaxRpcTimeout()) + .isEqualTo(Duration.ofSeconds(5)); + assertThat(analyzeSentimentRetrySettings.getTotalTimeout()) + .isEqualTo(Duration.ofMinutes(5)); + assertThat(analyzeSentimentRetrySettings.getMaxAttempts()).isEqualTo(2); + }); + } } From 152d8a34d6a8a8922ff7b6f0af700999186dfab4 Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 19 Dec 2022 17:17:54 -0500 Subject: [PATCH 04/11] test: update assertion for custom service settings bean --- .../language/v1/spring/LanguageAutoConfigurationTests.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java index af78384651..6d4a288d4c 100644 --- a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java +++ b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java @@ -157,11 +157,10 @@ void testCustomTransportChannelProviderUsedWhenProvided() throws IOException { @Test void testCustomServiceSettingsUsedWhenProvided() throws IOException { - String mockQuotaProjectId = "mockQuotaProjectId"; LanguageServiceSettings customLanguageServiceSettings = LanguageServiceSettings.newBuilder() .setCredentialsProvider(mockCredentialsProvider) - .setQuotaProjectId(mockQuotaProjectId) + .setQuotaProjectId(SERVICE_OVERRIDE_CLIENT_ID) .build(); contextRunner .withBean( @@ -171,9 +170,7 @@ void testCustomServiceSettingsUsedWhenProvided() throws IOException { .run( ctx -> { LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); - assertThat(client.getSettings().getCredentialsProvider()) - .isSameAs(mockCredentialsProvider); - assertThat(client.getSettings().getQuotaProjectId()).isSameAs(mockQuotaProjectId); + assertThat(client.getSettings()).isSameAs(customLanguageServiceSettings); }); } From 164b8c063f6f6fe1cd3e4d33e9f0ca1c56c6794f Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 19 Dec 2022 20:36:25 -0500 Subject: [PATCH 05/11] test: update tests for service vs top-level credentials --- .../LanguageAutoConfigurationTests.java | 24 +++++++++++++------ .../test/resources/fake-credential-key-2.json | 12 ++++++++++ 2 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 generated/language/src/test/resources/fake-credential-key-2.json diff --git a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java index 6d4a288d4c..3f4965c52a 100644 --- a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java +++ b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java @@ -45,7 +45,10 @@ class LanguageAutoConfigurationTests { private static final String SERVICE_CREDENTIAL_LOCATION = "src/test/resources/fake-credential-key.json"; + private static final String TOP_LEVEL_CREDENTIAL_LOCATION = + "src/test/resources/fake-credential-key-2.json"; private static final String SERVICE_CREDENTIAL_CLIENT_ID = "45678"; + private static final String TOP_LEVEL_CREDENTIAL_CLIENT_ID = "12345"; private static final String SERVICE_OVERRIDE_CLIENT_ID = "56789"; @Mock private TransportChannel mockTransportChannel; @@ -69,9 +72,10 @@ void testLanguageServiceClientCreated() { } @Test - void testServiceCredentialsFromProperties() { + void testCredentials_fromServicePropertiesIfSpecified() { this.contextRunner .withPropertyValues( + "spring.cloud.gcp.credentials.location=file:" + TOP_LEVEL_CREDENTIAL_LOCATION, "com.google.cloud.language.v1.spring.auto.language-service.credentials.location=file:" + SERVICE_CREDENTIAL_LOCATION) .run( @@ -85,12 +89,18 @@ void testServiceCredentialsFromProperties() { } @Test - void testShouldUseCredentialsBeanWhenPropertiesNotProvided() { - this.contextRunner.run( - ctx -> { - LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); - assertThat(client.getSettings().getCredentialsProvider()).isNotNull(); - }); + void testCredentials_fromTopLevelIfNoServiceProperties() { + this.contextRunner + .withPropertyValues( + "spring.cloud.gcp.credentials.location=file:" + TOP_LEVEL_CREDENTIAL_LOCATION) + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + Credentials credentials = + client.getSettings().getCredentialsProvider().getCredentials(); + assertThat(((ServiceAccountCredentials) credentials).getClientId()) + .isEqualTo(TOP_LEVEL_CREDENTIAL_CLIENT_ID); + }); } @Test diff --git a/generated/language/src/test/resources/fake-credential-key-2.json b/generated/language/src/test/resources/fake-credential-key-2.json new file mode 100644 index 0000000000..a64bb70158 --- /dev/null +++ b/generated/language/src/test/resources/fake-credential-key-2.json @@ -0,0 +1,12 @@ +{ + "type": "service_account", + "project_id": "fake-project-id-2", + "private_key_id": "fake-key", + "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEugIBADANBgkqhkiG9w0BAQEFAASCBKQwggSgAgEAAoIBAQCh/y7v8lk1Ko79\nWVbQZCtmd0PXZr8WrUmmdEv2aaQQF/ed/KL2M/T2dbTlQ4EeOP+aK/5T8JSuxxZ5\na6e8TsovKXJz2qjeBLpzNFbx2xSyldYziC6v+bRCPKWCQLRNVdz/iYmOqjOu1/Ri\n8njOF7gG3XMQxryl9pmpJbVXj38Zw1n8mefT/g/+l6fObsVIgLs9WjGE9HDMKzx8\n9Ph7f+Ru1EuBrFOgHfKvWeIjVtQWqr3Dz+M1KyLFezYtXGB5HLg02sPJM+tMdcMj\nL9xpuodc6noBBeKvijEfTErLIaO1cJS5AgFHDyEsspaRdgXpJroM4w8ZSj3J0Wp7\ntJ7PeaG/AgMBAAECgf9ubAMSi59DHj9Zcgw7AAyVS7ZynRaj3nrVe3BMBrZOQggH\nKK3sJH5VgOZNYDYi47dW36X8kYDHoe0v1rH/KbWncBkT33g73f05ifO56Buzn27i\nsXEhgpPckno+ztwX2u9JP/cDyAByrcFnsN+nm4NVKp3EUbNFbVJQeeOiS63XYLvO\nuIUGlYJrnqa2zWp/YwhOmvZz5fNhfN/Js+V8kaA/xK/Dk0xhgvAqv73lgYZyL5pg\nlImHgHIm5alAMpchu4bInv2CjhKsgyPvHZU0Wihdm5it58hME0gN3ekD6lbdsp+1\nEwZ50JXALUPvzeMGXWorxuBUe9hpMcDmugR6rjECgYEAzpELFjiX2sNZPDX7cTM0\nYwWCdcvJUVTEapnpWuU2OhDreGMlBAWO6hkTIq6kmBZ0c30o10FNhXBrg0AyesgG\nheY6wO+v4e5hnVIdud2ih7AWDaKXVrb63Z/aF3EUhxcVk0wmnJtQ605cjMjeJOJF\nEyQCGsaiLbsEBsEKrXfLL08CgYEAyMOlz8dCNrEm16rbTE7NZpqql7IJhcAcXB5Z\nGUZicK98W4HnT6r5qPePgCjHnxjXl+/T6siH1B8CxQwtzETI8bu0Jd3ZvL7HZnIS\nHDWiGn72OJnYOvxvq1SvIqdTvlCMKqRQancp8wWP9oubzjS5ZZLGemaqvVL2Occp\nsfUZSpECgYBXPdz/2pEQHNcwXeA/VA/5DlemJpZ1GicGmtB6yjnX1lOM+dqlUy+j\n4Uk6qaXscfdm22KHXxY9mFhgC5oGTzqqDK2d1N1kv4hMqGTTni7Jve3iflwKjKdx\nONUkd2bjEzXSiyP3moVXjDX8Y82mqEXiKqAU7PWL+ONfcuJulxyicwKBgAcPoohR\nSMnlpykUsEvZxa2jKPbW4zDaFeVDh/y0lgfClEwfoIQTzl4b/ucSCBtXY1XLsJdk\nYCqcwJsvl3jEvpCJ+ocOa3cQ+rBmuK5XUJE//+bzukAw2ria7OH6Ip7h9FwXlWB5\nOnd6rZqNRHiXMCIbbHGnpL+t6E0V7Sh+J1qRAoGALRlR4TpW+UQvJIs5iBuF4/vg\n9iWLVOY8QoDYQ1k755EY53Q8tk3fO2ESUyV7A35zu/TQWm7z5PTFCl9R5dpWywMU\nTG7xr3tNVP7oDUN9ofN2ipB99EavN81k3co+nnWwhniJn0zHEpTq9IvGozwGuUjN\nIkiy17wHSSocTzvLDNk=\n-----END PRIVATE KEY-----\n", + "client_email": "test@fake-project.iam.gserviceaccount.com", + "client_id": "12345", + "auth_uri": "https://fake.auth.url.com/o/oauth2/auth", + "token_uri": "https://fake.token.url.com/token", + "auth_provider_x509_cert_url": "https://fake.auth.provider.cert.url.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www.fake.client.cert.com/robot/v1/metadata/x509/test@fake-project.iam.gserviceaccount.com" +} \ No newline at end of file From d8516fdaa0935aa549aae0457a406e62bc62917a Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 19 Dec 2022 21:12:08 -0500 Subject: [PATCH 06/11] test: update test for default transport channel provider --- .../v1/spring/LanguageAutoConfigurationTests.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java index 3f4965c52a..6e14d18eac 100644 --- a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java +++ b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java @@ -22,6 +22,7 @@ import com.google.api.gax.core.CredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.TransportChannel; @@ -104,13 +105,17 @@ void testCredentials_fromTopLevelIfNoServiceProperties() { } @Test - void testShouldUseDefaultGrpcTransport() { + void testShouldUseDefaultTransportChannelProvider() { this.contextRunner.run( ctx -> { LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); - String transportName = - client.getSettings().getTransportChannelProvider().getTransportName(); - assertThat(transportName).isEqualTo("grpc"); + TransportChannelProvider transportChannelProvider = + client.getSettings().getTransportChannelProvider(); + TransportChannelProvider defaultTransportChannelprovider = + LanguageServiceSettings.defaultTransportChannelProvider(); + assertThat(transportChannelProvider) + .usingRecursiveComparison() + .isEqualTo(defaultTransportChannelprovider); }); } From d34fa0c60723724c17318c9602c6c350f4061297 Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Tue, 20 Dec 2022 11:51:40 -0500 Subject: [PATCH 07/11] test: adjust and define local variables for inline values --- .../LanguageAutoConfigurationTests.java | 120 +++++++++++------- 1 file changed, 74 insertions(+), 46 deletions(-) diff --git a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java index 6e14d18eac..97b98abe29 100644 --- a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java +++ b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java @@ -135,9 +135,11 @@ void testQuotaProjectIdFromProperties() { @Test void testExecutorThreadCountFromProperties() { + Integer customExecutorThreadCount = 3; this.contextRunner .withPropertyValues( - "com.google.cloud.language.v1.spring.auto.language-service.executor-thread-count=3") + "com.google.cloud.language.v1.spring.auto.language-service.executor-thread-count=" + + customExecutorThreadCount.toString()) .run( ctx -> { LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); @@ -145,7 +147,7 @@ void testExecutorThreadCountFromProperties() { ((InstantiatingExecutorProvider) client.getSettings().getBackgroundExecutorProvider()); assertThat(backgroundExecutorProvider.toBuilder().getExecutorThreadCount()) - .isEqualTo(3); + .isEqualTo(customExecutorThreadCount); }); } @@ -191,38 +193,48 @@ void testCustomServiceSettingsUsedWhenProvided() throws IOException { @Test void testRetrySettingsFromProperties_serviceLevel() { + Double customMultiplier = 2.0; + String customDurationString = "PT0.9S"; + Duration customDuration = Duration.ofMillis(900); + Duration defaultDurationExpected = Duration.ofMillis(100); this.contextRunner .withPropertyValues( "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.retry-delay-multiplier=" - + "2", + + customMultiplier.toString(), "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-retry-delay=" - + "PT0.9S") + + customDurationString) .run( ctx -> { LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); RetrySettings analyzeSentimentRetrySettings = client.getSettings().analyzeSentimentSettings().getRetrySettings(); - assertThat(analyzeSentimentRetrySettings.getRetryDelayMultiplier()).isEqualTo(2); + assertThat(analyzeSentimentRetrySettings.getRetryDelayMultiplier()) + .isEqualTo(customMultiplier); assertThat(analyzeSentimentRetrySettings.getMaxRetryDelay()) - .isEqualTo(Duration.ofMillis(900)); + .isEqualTo(customDuration); // if properties only override certain retry settings, others should still take on // client library defaults assertThat(analyzeSentimentRetrySettings.getInitialRetryDelay()) - .isEqualTo(Duration.ofMillis(100)); // default + .isEqualTo(defaultDurationExpected); }); } @Test void testRetrySettingsFromProperties_serviceAndMethodLevel() { + Double customServiceMultiplier = 2.0; + Double customMethodMultiplier = 3.0; + String customDurationString = "PT0.9S"; + Duration customDuration = Duration.ofMillis(900); + Duration defaultDurationExpected = Duration.ofMillis(100); this.contextRunner .withPropertyValues( "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.retry-delay-multiplier=" - + "2", + + customServiceMultiplier.toString(), "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-retry-delay=" - + "PT0.9S", + + customDurationString, "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.retry-delay-multiplier=" - + "3") + + customMethodMultiplier.toString()) .run( ctx -> { LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); @@ -230,56 +242,66 @@ void testRetrySettingsFromProperties_serviceAndMethodLevel() { RetrySettings annotateTextRetrySettings = client.getSettings().annotateTextSettings().getRetrySettings(); // Method-level override should take precedence over service-level - assertThat(annotateTextRetrySettings.getRetryDelayMultiplier()).isEqualTo(3); + assertThat(annotateTextRetrySettings.getRetryDelayMultiplier()) + .isEqualTo(customMethodMultiplier); // For settings without method-level overrides but when service-level is provided, // fall back to that - assertThat(annotateTextRetrySettings.getMaxRetryDelay()) - .isEqualTo(Duration.ofMillis(900)); + assertThat(annotateTextRetrySettings.getMaxRetryDelay()).isEqualTo(customDuration); // Settings with neither method not service-level overrides should still take on // client library defaults assertThat(annotateTextRetrySettings.getInitialRetryDelay()) - .isEqualTo(Duration.ofMillis(100)); // default + .isEqualTo(defaultDurationExpected); // default }); } @Test void testRetrySettingsFromProperties_serviceAndMethodLevel_allRetrySettings() { + Double customServiceMultiplier = 2.0; + String customServiceDurationString = "PT0.5S"; + Duration customServiceDuration = Duration.ofMillis(500); + Integer customServiceMaxAttempts = 2; + + Double customMethodMultiplier = 3.0; + String customMethodDurationString = "PT0.6S"; + Duration customMethodDuration = Duration.ofMillis(600); + Integer customMethodMaxAttempts = 3; + this.contextRunner .withPropertyValues( // service-level, all configurable settings "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.retry-delay-multiplier=" - + "2", + + customServiceMultiplier.toString(), "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.rpc-timeout-multiplier=" - + "2", + + customServiceMultiplier.toString(), "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.initial-retry-delay=" - + "PT0.5S", + + customServiceDurationString, "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-retry-delay=" - + "PT5S", + + customServiceDurationString, "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.initial-rpc-timeout=" - + "PT0.5S", + + customServiceDurationString, "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-rpc-timeout=" - + "PT5S", + + customServiceDurationString, "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.total-timeout=" - + "PT5M", + + customServiceDurationString, "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-attempts=" - + "2", + + customServiceMaxAttempts.toString(), // method-level, all configurable settings "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.retry-delay-multiplier=" - + "3", + + customMethodMultiplier.toString(), "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.rpc-timeout-multiplier=" - + "3", + + customMethodMultiplier.toString(), "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.initial-retry-delay=" - + "PT0.6S", + + customMethodDurationString, "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.max-retry-delay=" - + "PT6S", + + customMethodDurationString, "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.initial-rpc-timeout=" - + "PT0.6S", + + customMethodDurationString, "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.max-rpc-timeout=" - + "PT6S", + + customMethodDurationString, "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.total-timeout=" - + "PT6M", + + customMethodDurationString, "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.max-attempts=" - + "3") + + customMethodMaxAttempts.toString()) .run( ctx -> { LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); @@ -289,34 +311,40 @@ void testRetrySettingsFromProperties_serviceAndMethodLevel_allRetrySettings() { client.getSettings().analyzeSentimentSettings().getRetrySettings(); // Method-level overrides should be used for annotateText - assertThat(annotateTextRetrySettings.getRetryDelayMultiplier()).isEqualTo(3); - assertThat(annotateTextRetrySettings.getRpcTimeoutMultiplier()).isEqualTo(3); + assertThat(annotateTextRetrySettings.getRetryDelayMultiplier()) + .isEqualTo(customMethodMultiplier); + assertThat(annotateTextRetrySettings.getRpcTimeoutMultiplier()) + .isEqualTo(customMethodMultiplier); assertThat(annotateTextRetrySettings.getInitialRetryDelay()) - .isEqualTo(Duration.ofMillis(600)); + .isEqualTo(customMethodDuration); assertThat(annotateTextRetrySettings.getInitialRpcTimeout()) - .isEqualTo(Duration.ofMillis(600)); + .isEqualTo(customMethodDuration); assertThat(annotateTextRetrySettings.getMaxRetryDelay()) - .isEqualTo(Duration.ofSeconds(6)); + .isEqualTo(customMethodDuration); assertThat(annotateTextRetrySettings.getMaxRpcTimeout()) - .isEqualTo(Duration.ofSeconds(6)); + .isEqualTo(customMethodDuration); assertThat(annotateTextRetrySettings.getTotalTimeout()) - .isEqualTo(Duration.ofMinutes(6)); - assertThat(annotateTextRetrySettings.getMaxAttempts()).isEqualTo(3); + .isEqualTo(customMethodDuration); + assertThat(annotateTextRetrySettings.getMaxAttempts()) + .isEqualTo(customMethodMaxAttempts); // Service-level overrides should be used for analyzeSentiment - assertThat(analyzeSentimentRetrySettings.getRetryDelayMultiplier()).isEqualTo(2); - assertThat(analyzeSentimentRetrySettings.getRpcTimeoutMultiplier()).isEqualTo(2); + assertThat(analyzeSentimentRetrySettings.getRetryDelayMultiplier()) + .isEqualTo(customServiceMultiplier); + assertThat(analyzeSentimentRetrySettings.getRpcTimeoutMultiplier()) + .isEqualTo(customServiceMultiplier); assertThat(analyzeSentimentRetrySettings.getInitialRetryDelay()) - .isEqualTo(Duration.ofMillis(500)); + .isEqualTo(customServiceDuration); assertThat(analyzeSentimentRetrySettings.getInitialRpcTimeout()) - .isEqualTo(Duration.ofMillis(500)); + .isEqualTo(customServiceDuration); assertThat(analyzeSentimentRetrySettings.getMaxRetryDelay()) - .isEqualTo(Duration.ofSeconds(5)); + .isEqualTo(customServiceDuration); assertThat(analyzeSentimentRetrySettings.getMaxRpcTimeout()) - .isEqualTo(Duration.ofSeconds(5)); + .isEqualTo(customServiceDuration); assertThat(analyzeSentimentRetrySettings.getTotalTimeout()) - .isEqualTo(Duration.ofMinutes(5)); - assertThat(analyzeSentimentRetrySettings.getMaxAttempts()).isEqualTo(2); + .isEqualTo(customServiceDuration); + assertThat(analyzeSentimentRetrySettings.getMaxAttempts()) + .isEqualTo(customServiceMaxAttempts); }); } } From 1b40a2c04c13f2ff08a8626b0c985ce8e9cf6225 Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Tue, 20 Dec 2022 11:55:34 -0500 Subject: [PATCH 08/11] test: property name change from retry-settings to retry --- .../LanguageAutoConfigurationTests.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java index 97b98abe29..a943605d30 100644 --- a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java +++ b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java @@ -199,9 +199,9 @@ void testRetrySettingsFromProperties_serviceLevel() { Duration defaultDurationExpected = Duration.ofMillis(100); this.contextRunner .withPropertyValues( - "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.retry-delay-multiplier=" + "com.google.cloud.language.v1.spring.auto.language-service.retry.retry-delay-multiplier=" + customMultiplier.toString(), - "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-retry-delay=" + "com.google.cloud.language.v1.spring.auto.language-service.retry.max-retry-delay=" + customDurationString) .run( ctx -> { @@ -229,11 +229,11 @@ void testRetrySettingsFromProperties_serviceAndMethodLevel() { Duration defaultDurationExpected = Duration.ofMillis(100); this.contextRunner .withPropertyValues( - "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.retry-delay-multiplier=" + "com.google.cloud.language.v1.spring.auto.language-service.retry.retry-delay-multiplier=" + customServiceMultiplier.toString(), - "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-retry-delay=" + "com.google.cloud.language.v1.spring.auto.language-service.retry.max-retry-delay=" + customDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.retry-delay-multiplier=" + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.retry-delay-multiplier=" + customMethodMultiplier.toString()) .run( ctx -> { @@ -269,38 +269,38 @@ void testRetrySettingsFromProperties_serviceAndMethodLevel_allRetrySettings() { this.contextRunner .withPropertyValues( // service-level, all configurable settings - "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.retry-delay-multiplier=" + "com.google.cloud.language.v1.spring.auto.language-service.retry.retry-delay-multiplier=" + customServiceMultiplier.toString(), - "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.rpc-timeout-multiplier=" + "com.google.cloud.language.v1.spring.auto.language-service.retry.rpc-timeout-multiplier=" + customServiceMultiplier.toString(), - "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.initial-retry-delay=" + "com.google.cloud.language.v1.spring.auto.language-service.retry.initial-retry-delay=" + customServiceDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-retry-delay=" + "com.google.cloud.language.v1.spring.auto.language-service.retry.max-retry-delay=" + customServiceDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.initial-rpc-timeout=" + "com.google.cloud.language.v1.spring.auto.language-service.retry.initial-rpc-timeout=" + customServiceDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-rpc-timeout=" + "com.google.cloud.language.v1.spring.auto.language-service.retry.max-rpc-timeout=" + customServiceDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.total-timeout=" + "com.google.cloud.language.v1.spring.auto.language-service.retry.total-timeout=" + customServiceDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.retry-settings.max-attempts=" + "com.google.cloud.language.v1.spring.auto.language-service.retry.max-attempts=" + customServiceMaxAttempts.toString(), // method-level, all configurable settings - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.retry-delay-multiplier=" + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.retry-delay-multiplier=" + customMethodMultiplier.toString(), - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.rpc-timeout-multiplier=" + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.rpc-timeout-multiplier=" + customMethodMultiplier.toString(), - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.initial-retry-delay=" + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.initial-retry-delay=" + customMethodDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.max-retry-delay=" + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.max-retry-delay=" + customMethodDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.initial-rpc-timeout=" + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.initial-rpc-timeout=" + customMethodDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.max-rpc-timeout=" + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.max-rpc-timeout=" + customMethodDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.total-timeout=" + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.total-timeout=" + customMethodDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry-settings.max-attempts=" + "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.max-attempts=" + customMethodMaxAttempts.toString()) .run( ctx -> { From a4affd57b743c2cf1c13dd977f5bd8bed7dfe316 Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Wed, 21 Dec 2022 11:32:54 -0500 Subject: [PATCH 09/11] test: remove spring.auto from property prefix --- .../LanguageAutoConfigurationTests.java | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java index a943605d30..f44b2a7925 100644 --- a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java +++ b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java @@ -77,7 +77,7 @@ void testCredentials_fromServicePropertiesIfSpecified() { this.contextRunner .withPropertyValues( "spring.cloud.gcp.credentials.location=file:" + TOP_LEVEL_CREDENTIAL_LOCATION, - "com.google.cloud.language.v1.spring.auto.language-service.credentials.location=file:" + "com.google.cloud.language.v1.language-service.credentials.location=file:" + SERVICE_CREDENTIAL_LOCATION) .run( ctx -> { @@ -123,7 +123,7 @@ void testShouldUseDefaultTransportChannelProvider() { void testQuotaProjectIdFromProperties() { this.contextRunner .withPropertyValues( - "com.google.cloud.language.v1.spring.auto.language-service.quota-project-id=" + "com.google.cloud.language.v1.language-service.quota-project-id=" + SERVICE_OVERRIDE_CLIENT_ID) .run( ctx -> { @@ -138,7 +138,7 @@ void testExecutorThreadCountFromProperties() { Integer customExecutorThreadCount = 3; this.contextRunner .withPropertyValues( - "com.google.cloud.language.v1.spring.auto.language-service.executor-thread-count=" + "com.google.cloud.language.v1.language-service.executor-thread-count=" + customExecutorThreadCount.toString()) .run( ctx -> { @@ -199,9 +199,9 @@ void testRetrySettingsFromProperties_serviceLevel() { Duration defaultDurationExpected = Duration.ofMillis(100); this.contextRunner .withPropertyValues( - "com.google.cloud.language.v1.spring.auto.language-service.retry.retry-delay-multiplier=" + "com.google.cloud.language.v1.language-service.retry.retry-delay-multiplier=" + customMultiplier.toString(), - "com.google.cloud.language.v1.spring.auto.language-service.retry.max-retry-delay=" + "com.google.cloud.language.v1.language-service.retry.max-retry-delay=" + customDurationString) .run( ctx -> { @@ -229,11 +229,11 @@ void testRetrySettingsFromProperties_serviceAndMethodLevel() { Duration defaultDurationExpected = Duration.ofMillis(100); this.contextRunner .withPropertyValues( - "com.google.cloud.language.v1.spring.auto.language-service.retry.retry-delay-multiplier=" + "com.google.cloud.language.v1.language-service.retry.retry-delay-multiplier=" + customServiceMultiplier.toString(), - "com.google.cloud.language.v1.spring.auto.language-service.retry.max-retry-delay=" + "com.google.cloud.language.v1.language-service.retry.max-retry-delay=" + customDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.retry-delay-multiplier=" + "com.google.cloud.language.v1.language-service.annotate-text-retry.retry-delay-multiplier=" + customMethodMultiplier.toString()) .run( ctx -> { @@ -269,38 +269,38 @@ void testRetrySettingsFromProperties_serviceAndMethodLevel_allRetrySettings() { this.contextRunner .withPropertyValues( // service-level, all configurable settings - "com.google.cloud.language.v1.spring.auto.language-service.retry.retry-delay-multiplier=" + "com.google.cloud.language.v1.language-service.retry.retry-delay-multiplier=" + customServiceMultiplier.toString(), - "com.google.cloud.language.v1.spring.auto.language-service.retry.rpc-timeout-multiplier=" + "com.google.cloud.language.v1.language-service.retry.rpc-timeout-multiplier=" + customServiceMultiplier.toString(), - "com.google.cloud.language.v1.spring.auto.language-service.retry.initial-retry-delay=" + "com.google.cloud.language.v1.language-service.retry.initial-retry-delay=" + customServiceDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.retry.max-retry-delay=" + "com.google.cloud.language.v1.language-service.retry.max-retry-delay=" + customServiceDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.retry.initial-rpc-timeout=" + "com.google.cloud.language.v1.language-service.retry.initial-rpc-timeout=" + customServiceDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.retry.max-rpc-timeout=" + "com.google.cloud.language.v1.language-service.retry.max-rpc-timeout=" + customServiceDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.retry.total-timeout=" + "com.google.cloud.language.v1.language-service.retry.total-timeout=" + customServiceDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.retry.max-attempts=" + "com.google.cloud.language.v1.language-service.retry.max-attempts=" + customServiceMaxAttempts.toString(), // method-level, all configurable settings - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.retry-delay-multiplier=" + "com.google.cloud.language.v1.language-service.annotate-text-retry.retry-delay-multiplier=" + customMethodMultiplier.toString(), - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.rpc-timeout-multiplier=" + "com.google.cloud.language.v1.language-service.annotate-text-retry.rpc-timeout-multiplier=" + customMethodMultiplier.toString(), - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.initial-retry-delay=" + "com.google.cloud.language.v1.language-service.annotate-text-retry.initial-retry-delay=" + customMethodDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.max-retry-delay=" + "com.google.cloud.language.v1.language-service.annotate-text-retry.max-retry-delay=" + customMethodDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.initial-rpc-timeout=" + "com.google.cloud.language.v1.language-service.annotate-text-retry.initial-rpc-timeout=" + customMethodDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.max-rpc-timeout=" + "com.google.cloud.language.v1.language-service.annotate-text-retry.max-rpc-timeout=" + customMethodDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.total-timeout=" + "com.google.cloud.language.v1.language-service.annotate-text-retry.total-timeout=" + customMethodDurationString, - "com.google.cloud.language.v1.spring.auto.language-service.annotate-text-retry.max-attempts=" + "com.google.cloud.language.v1.language-service.annotate-text-retry.max-attempts=" + customMethodMaxAttempts.toString()) .run( ctx -> { From 6762a16c921f5bc903bae2853acc73cf56f1cacd Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Tue, 3 Jan 2023 09:50:15 -0500 Subject: [PATCH 10/11] test: add test for rest transport channel provider configuration --- .../spring/LanguageAutoConfigurationTests.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java index f44b2a7925..2f1c1e1a0a 100644 --- a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java +++ b/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java @@ -119,6 +119,23 @@ void testShouldUseDefaultTransportChannelProvider() { }); } + @Test + void testCustomTransportChannelProviderSetToRest() { + this.contextRunner + .withPropertyValues("com.google.cloud.language.v1.language-service.use-rest=true") + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + TransportChannelProvider transportChannelProvider = + client.getSettings().getTransportChannelProvider(); + TransportChannelProvider defaultHttpJsonTransportChannelprovider = + LanguageServiceSettings.defaultHttpJsonTransportProviderBuilder().build(); + assertThat(transportChannelProvider) + .usingRecursiveComparison() + .isEqualTo(defaultHttpJsonTransportChannelprovider); + }); + } + @Test void testQuotaProjectIdFromProperties() { this.contextRunner From 24433cfaff550ed1925ed70c59ae519c772d540e Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Tue, 3 Jan 2023 10:22:34 -0500 Subject: [PATCH 11/11] test: update test file location given module restructure --- .../cloud/language/v1/spring/LanguageAutoConfigurationTests.java | 0 .../src/test/resources/fake-credential-key-2.json | 0 .../src/test/resources/fake-credential-key.json | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {generated/language => spring-cloud-previews/google-cloud-language-spring-starter}/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java (100%) rename {generated/language => spring-cloud-previews/google-cloud-language-spring-starter}/src/test/resources/fake-credential-key-2.json (100%) rename {generated/language => spring-cloud-previews/google-cloud-language-spring-starter}/src/test/resources/fake-credential-key.json (100%) diff --git a/generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java similarity index 100% rename from generated/language/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java rename to spring-cloud-previews/google-cloud-language-spring-starter/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java diff --git a/generated/language/src/test/resources/fake-credential-key-2.json b/spring-cloud-previews/google-cloud-language-spring-starter/src/test/resources/fake-credential-key-2.json similarity index 100% rename from generated/language/src/test/resources/fake-credential-key-2.json rename to spring-cloud-previews/google-cloud-language-spring-starter/src/test/resources/fake-credential-key-2.json diff --git a/generated/language/src/test/resources/fake-credential-key.json b/spring-cloud-previews/google-cloud-language-spring-starter/src/test/resources/fake-credential-key.json similarity index 100% rename from generated/language/src/test/resources/fake-credential-key.json rename to spring-cloud-previews/google-cloud-language-spring-starter/src/test/resources/fake-credential-key.json