diff --git a/pom.xml b/pom.xml index b8ed3f1eed..01263c7116 100644 --- a/pom.xml +++ b/pom.xml @@ -75,7 +75,7 @@ UTF-8 **/*IntegrationTest* - spring-cloud-previews/**/* + spring-cloud-previews/!(google-cloud-language-spring-starter)/** diff --git a/spring-cloud-generator/spring-cloud-previews-template/google-cloud-language-spring-starter/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java b/spring-cloud-generator/spring-cloud-previews-template/google-cloud-language-spring-starter/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java index d3e9d4d6ad..ebb167d12e 100644 --- a/spring-cloud-generator/spring-cloud-previews-template/google-cloud-language-spring-starter/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java +++ b/spring-cloud-generator/spring-cloud-previews-template/google-cloud-language-spring-starter/src/test/java/com/google/cloud/language/v1/spring/LanguageAutoConfigurationTests.java @@ -384,4 +384,49 @@ void testRetrySettingsFromProperties_serviceAndMethodLevel_allRetrySettings() { .isEqualTo(customServiceMaxAttempts); }); } + + @Test + void testRetrySettingsFromProperties_methodLevel_totalTimeout() { + String customTimeoutString = "PT10S"; + Duration customTimeoutDuration = Duration.ofSeconds(10); + + this.contextRunner + .withPropertyValues( + // configure total timeout on method-level + "com.google.cloud.language.v1.language-service.analyze-sentiment-retry.total-timeout=" + + customTimeoutString, + "com.google.cloud.language.v1.language-service.analyze-entities-retry.total-timeout=" + + customTimeoutString, + "com.google.cloud.language.v1.language-service.analyze-entity-sentiment-retry.total-timeout=" + + customTimeoutString, + "com.google.cloud.language.v1.language-service.analyze-syntax-retry.total-timeout=" + + customTimeoutString, + "com.google.cloud.language.v1.language-service.classify-text-retry.total-timeout=" + + customTimeoutString, + "com.google.cloud.language.v1.language-service.annotate-text-retry.total-timeout=" + + customTimeoutString) + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + LanguageServiceSettings settings = client.getSettings(); + + // Method-level configurations + assertThat(settings.analyzeEntitiesSettings().getRetrySettings().getTotalTimeout()) + .isEqualTo(customTimeoutDuration); + assertThat(settings.analyzeEntitiesSettings().getRetrySettings().getTotalTimeout()) + .isEqualTo(customTimeoutDuration); + assertThat( + settings + .analyzeEntitySentimentSettings() + .getRetrySettings() + .getTotalTimeout()) + .isEqualTo(customTimeoutDuration); + assertThat(settings.analyzeSyntaxSettings().getRetrySettings().getTotalTimeout()) + .isEqualTo(customTimeoutDuration); + assertThat(settings.classifyTextSettings().getRetrySettings().getTotalTimeout()) + .isEqualTo(customTimeoutDuration); + assertThat(settings.annotateTextSettings().getRetrySettings().getTotalTimeout()) + .isEqualTo(customTimeoutDuration); + }); + } } diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/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 index d3e9d4d6ad..ebb167d12e 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/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 @@ -384,4 +384,49 @@ void testRetrySettingsFromProperties_serviceAndMethodLevel_allRetrySettings() { .isEqualTo(customServiceMaxAttempts); }); } + + @Test + void testRetrySettingsFromProperties_methodLevel_totalTimeout() { + String customTimeoutString = "PT10S"; + Duration customTimeoutDuration = Duration.ofSeconds(10); + + this.contextRunner + .withPropertyValues( + // configure total timeout on method-level + "com.google.cloud.language.v1.language-service.analyze-sentiment-retry.total-timeout=" + + customTimeoutString, + "com.google.cloud.language.v1.language-service.analyze-entities-retry.total-timeout=" + + customTimeoutString, + "com.google.cloud.language.v1.language-service.analyze-entity-sentiment-retry.total-timeout=" + + customTimeoutString, + "com.google.cloud.language.v1.language-service.analyze-syntax-retry.total-timeout=" + + customTimeoutString, + "com.google.cloud.language.v1.language-service.classify-text-retry.total-timeout=" + + customTimeoutString, + "com.google.cloud.language.v1.language-service.annotate-text-retry.total-timeout=" + + customTimeoutString) + .run( + ctx -> { + LanguageServiceClient client = ctx.getBean(LanguageServiceClient.class); + LanguageServiceSettings settings = client.getSettings(); + + // Method-level configurations + assertThat(settings.analyzeEntitiesSettings().getRetrySettings().getTotalTimeout()) + .isEqualTo(customTimeoutDuration); + assertThat(settings.analyzeEntitiesSettings().getRetrySettings().getTotalTimeout()) + .isEqualTo(customTimeoutDuration); + assertThat( + settings + .analyzeEntitySentimentSettings() + .getRetrySettings() + .getTotalTimeout()) + .isEqualTo(customTimeoutDuration); + assertThat(settings.analyzeSyntaxSettings().getRetrySettings().getTotalTimeout()) + .isEqualTo(customTimeoutDuration); + assertThat(settings.classifyTextSettings().getRetrySettings().getTotalTimeout()) + .isEqualTo(customTimeoutDuration); + assertThat(settings.annotateTextSettings().getRetrySettings().getTotalTimeout()) + .isEqualTo(customTimeoutDuration); + }); + } }