From fe4046c7e382ed562c793374612fcab30625d9ae Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 8 May 2023 12:01:15 -0400 Subject: [PATCH 01/10] test: try adding language starter module back to sonar analysis --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bfd73fb3a4..a66f0b35c8 100644 --- a/pom.xml +++ b/pom.xml @@ -75,7 +75,7 @@ UTF-8 **/*IntegrationTest* - spring-cloud-previews/**/* + spring-cloud-previews/**/!(LanguageServiceSpring*).java From 71b6f95a30e4e10d3b5d1df5a33b238512b1cc2e Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 8 May 2023 13:12:47 -0400 Subject: [PATCH 02/10] temp: introduce generated code changes from removing classifyText method --- .../LanguageServiceSpringAutoConfiguration.java | 15 --------------- .../spring/LanguageServiceSpringProperties.java | 13 ------------- 2 files changed, 28 deletions(-) diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java index 7607eb4343..91b339cf78 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java @@ -184,11 +184,6 @@ public LanguageServiceSettings languageServiceSettings( clientSettingsBuilder.analyzeSyntaxSettings().getRetrySettings(), serviceRetry); clientSettingsBuilder.analyzeSyntaxSettings().setRetrySettings(analyzeSyntaxRetrySettings); - RetrySettings classifyTextRetrySettings = - RetryUtil.updateRetrySettings( - clientSettingsBuilder.classifyTextSettings().getRetrySettings(), serviceRetry); - clientSettingsBuilder.classifyTextSettings().setRetrySettings(classifyTextRetrySettings); - RetrySettings annotateTextRetrySettings = RetryUtil.updateRetrySettings( clientSettingsBuilder.annotateTextSettings().getRetrySettings(), serviceRetry); @@ -249,16 +244,6 @@ public LanguageServiceSettings languageServiceSettings( LOGGER.trace("Configured method-level retry settings for analyzeSyntax from properties."); } } - Retry classifyTextRetry = clientProperties.getClassifyTextRetry(); - if (classifyTextRetry != null) { - RetrySettings classifyTextRetrySettings = - RetryUtil.updateRetrySettings( - clientSettingsBuilder.classifyTextSettings().getRetrySettings(), classifyTextRetry); - clientSettingsBuilder.classifyTextSettings().setRetrySettings(classifyTextRetrySettings); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Configured method-level retry settings for classifyText from properties."); - } - } Retry annotateTextRetry = clientProperties.getAnnotateTextRetry(); if (annotateTextRetry != null) { RetrySettings annotateTextRetrySettings = diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java index 2dc3ba178f..c1c2d62d45 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java @@ -64,11 +64,6 @@ public class LanguageServiceSpringProperties implements CredentialsSupplier { * precedence over service-level retry configurations for that RPC method. */ @NestedConfigurationProperty private Retry analyzeSyntaxRetry; - /** - * Allow override of retry settings at method-level for classifyText. If defined, this takes - * precedence over service-level retry configurations for that RPC method. - */ - @NestedConfigurationProperty private Retry classifyTextRetry; /** * Allow override of retry settings at method-level for annotateText. If defined, this takes * precedence over service-level retry configurations for that RPC method. @@ -144,14 +139,6 @@ public void setAnalyzeSyntaxRetry(Retry analyzeSyntaxRetry) { this.analyzeSyntaxRetry = analyzeSyntaxRetry; } - public Retry getClassifyTextRetry() { - return this.classifyTextRetry; - } - - public void setClassifyTextRetry(Retry classifyTextRetry) { - this.classifyTextRetry = classifyTextRetry; - } - public Retry getAnnotateTextRetry() { return this.annotateTextRetry; } From a683a99124ca0107bcdd2db694c10cf6d4823b20 Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 8 May 2023 14:43:07 -0400 Subject: [PATCH 03/10] Revert "temp: introduce generated code changes from removing classifyText method" This reverts commit 71b6f95a30e4e10d3b5d1df5a33b238512b1cc2e. --- .../LanguageServiceSpringAutoConfiguration.java | 15 +++++++++++++++ .../spring/LanguageServiceSpringProperties.java | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java index 91b339cf78..7607eb4343 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java @@ -184,6 +184,11 @@ public LanguageServiceSettings languageServiceSettings( clientSettingsBuilder.analyzeSyntaxSettings().getRetrySettings(), serviceRetry); clientSettingsBuilder.analyzeSyntaxSettings().setRetrySettings(analyzeSyntaxRetrySettings); + RetrySettings classifyTextRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.classifyTextSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.classifyTextSettings().setRetrySettings(classifyTextRetrySettings); + RetrySettings annotateTextRetrySettings = RetryUtil.updateRetrySettings( clientSettingsBuilder.annotateTextSettings().getRetrySettings(), serviceRetry); @@ -244,6 +249,16 @@ public LanguageServiceSettings languageServiceSettings( LOGGER.trace("Configured method-level retry settings for analyzeSyntax from properties."); } } + Retry classifyTextRetry = clientProperties.getClassifyTextRetry(); + if (classifyTextRetry != null) { + RetrySettings classifyTextRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.classifyTextSettings().getRetrySettings(), classifyTextRetry); + clientSettingsBuilder.classifyTextSettings().setRetrySettings(classifyTextRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for classifyText from properties."); + } + } Retry annotateTextRetry = clientProperties.getAnnotateTextRetry(); if (annotateTextRetry != null) { RetrySettings annotateTextRetrySettings = diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java index c1c2d62d45..2dc3ba178f 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java @@ -64,6 +64,11 @@ public class LanguageServiceSpringProperties implements CredentialsSupplier { * precedence over service-level retry configurations for that RPC method. */ @NestedConfigurationProperty private Retry analyzeSyntaxRetry; + /** + * Allow override of retry settings at method-level for classifyText. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry classifyTextRetry; /** * Allow override of retry settings at method-level for annotateText. If defined, this takes * precedence over service-level retry configurations for that RPC method. @@ -139,6 +144,14 @@ public void setAnalyzeSyntaxRetry(Retry analyzeSyntaxRetry) { this.analyzeSyntaxRetry = analyzeSyntaxRetry; } + public Retry getClassifyTextRetry() { + return this.classifyTextRetry; + } + + public void setClassifyTextRetry(Retry classifyTextRetry) { + this.classifyTextRetry = classifyTextRetry; + } + public Retry getAnnotateTextRetry() { return this.annotateTextRetry; } From 44bab393db8b20284ca3633e91ef9d8709a66611 Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 8 May 2023 14:48:46 -0400 Subject: [PATCH 04/10] temp: mock generate code changes from additional method-level retry --- .../LanguageServiceSpringAutoConfiguration.java | 14 ++++++++++++++ .../v1/spring/LanguageServiceSpringProperties.java | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java index 7607eb4343..9cbfcf7668 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java @@ -212,6 +212,20 @@ public LanguageServiceSettings languageServiceSettings( "Configured method-level retry settings for analyzeSentiment from properties."); } } + Retry analyzeSentimentRetryCopy = clientProperties.getAnalyzeSentimentRetryCopy(); + if (analyzeSentimentRetryCopy != null) { + RetrySettings analyzeSentimentRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.analyzeSentimentSettings().getRetrySettings(), + analyzeSentimentRetryCopy); + clientSettingsBuilder + .analyzeSentimentSettings() + .setRetrySettings(analyzeSentimentRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for analyzeSentiment from properties (copy)."); + } + } Retry analyzeEntitiesRetry = clientProperties.getAnalyzeEntitiesRetry(); if (analyzeEntitiesRetry != null) { RetrySettings analyzeEntitiesRetrySettings = diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java index 2dc3ba178f..a6706b1f3b 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java @@ -49,6 +49,11 @@ public class LanguageServiceSpringProperties implements CredentialsSupplier { * precedence over service-level retry configurations for that RPC method. */ @NestedConfigurationProperty private Retry analyzeSentimentRetry; + /** + * Allow override of retry settings at method-level for analyzeSentiment. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry analyzeSentimentRetryCopy; /** * Allow override of retry settings at method-level for analyzeEntities. If defined, this takes * precedence over service-level retry configurations for that RPC method. @@ -120,6 +125,14 @@ public void setAnalyzeSentimentRetry(Retry analyzeSentimentRetry) { this.analyzeSentimentRetry = analyzeSentimentRetry; } + public Retry getAnalyzeSentimentRetryCopy() { + return this.analyzeSentimentRetryCopy; + } + + public void setAnalyzeSentimentRetryCopy(Retry analyzeSentimentRetryCopy) { + this.analyzeSentimentRetryCopy = analyzeSentimentRetryCopy; + } + public Retry getAnalyzeEntitiesRetry() { return this.analyzeEntitiesRetry; } From ed7fee897a0660568c997e1bcfabb071531e51c1 Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 8 May 2023 15:47:07 -0400 Subject: [PATCH 05/10] test: add unit test for coverage of all method-level generated code --- .../LanguageAutoConfigurationTests.java | 42 +++++++++++++++++++ .../LanguageAutoConfigurationTests.java | 42 +++++++++++++++++++ 2 files changed, 84 insertions(+) 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..23c479c0b5 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,46 @@ 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..23c479c0b5 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,46 @@ 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); + }); + } } From 95be37846095c3ea39b4649d7be1e432f0a62cb5 Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 8 May 2023 16:09:34 -0400 Subject: [PATCH 06/10] test: fix formatting for added unit test --- .../LanguageAutoConfigurationTests.java | 81 ++++++++++--------- .../LanguageAutoConfigurationTests.java | 81 ++++++++++--------- 2 files changed, 84 insertions(+), 78 deletions(-) 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 23c479c0b5..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 @@ -385,45 +385,48 @@ void testRetrySettingsFromProperties_serviceAndMethodLevel_allRetrySettings() { }); } - @Test - void testRetrySettingsFromProperties_methodLevel_totalTimeout() { - String customTimeoutString = "PT10S"; - Duration customTimeoutDuration = Duration.ofSeconds(10); + @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(); + 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); - }); - } + // 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 23c479c0b5..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 @@ -385,45 +385,48 @@ void testRetrySettingsFromProperties_serviceAndMethodLevel_allRetrySettings() { }); } - @Test - void testRetrySettingsFromProperties_methodLevel_totalTimeout() { - String customTimeoutString = "PT10S"; - Duration customTimeoutDuration = Duration.ofSeconds(10); + @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(); + 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); - }); - } + // 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); + }); + } } From 9edf5024998fe540776e36f96c5b265f5ac058fc Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 8 May 2023 16:56:07 -0400 Subject: [PATCH 07/10] Revert "temp: mock generate code changes from additional method-level retry" This reverts commit 44bab393db8b20284ca3633e91ef9d8709a66611. --- .../LanguageServiceSpringAutoConfiguration.java | 14 -------------- .../v1/spring/LanguageServiceSpringProperties.java | 13 ------------- 2 files changed, 27 deletions(-) diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java index 9cbfcf7668..7607eb4343 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java @@ -212,20 +212,6 @@ public LanguageServiceSettings languageServiceSettings( "Configured method-level retry settings for analyzeSentiment from properties."); } } - Retry analyzeSentimentRetryCopy = clientProperties.getAnalyzeSentimentRetryCopy(); - if (analyzeSentimentRetryCopy != null) { - RetrySettings analyzeSentimentRetrySettings = - RetryUtil.updateRetrySettings( - clientSettingsBuilder.analyzeSentimentSettings().getRetrySettings(), - analyzeSentimentRetryCopy); - clientSettingsBuilder - .analyzeSentimentSettings() - .setRetrySettings(analyzeSentimentRetrySettings); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace( - "Configured method-level retry settings for analyzeSentiment from properties (copy)."); - } - } Retry analyzeEntitiesRetry = clientProperties.getAnalyzeEntitiesRetry(); if (analyzeEntitiesRetry != null) { RetrySettings analyzeEntitiesRetrySettings = diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java index a6706b1f3b..2dc3ba178f 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java @@ -49,11 +49,6 @@ public class LanguageServiceSpringProperties implements CredentialsSupplier { * precedence over service-level retry configurations for that RPC method. */ @NestedConfigurationProperty private Retry analyzeSentimentRetry; - /** - * Allow override of retry settings at method-level for analyzeSentiment. If defined, this takes - * precedence over service-level retry configurations for that RPC method. - */ - @NestedConfigurationProperty private Retry analyzeSentimentRetryCopy; /** * Allow override of retry settings at method-level for analyzeEntities. If defined, this takes * precedence over service-level retry configurations for that RPC method. @@ -125,14 +120,6 @@ public void setAnalyzeSentimentRetry(Retry analyzeSentimentRetry) { this.analyzeSentimentRetry = analyzeSentimentRetry; } - public Retry getAnalyzeSentimentRetryCopy() { - return this.analyzeSentimentRetryCopy; - } - - public void setAnalyzeSentimentRetryCopy(Retry analyzeSentimentRetryCopy) { - this.analyzeSentimentRetryCopy = analyzeSentimentRetryCopy; - } - public Retry getAnalyzeEntitiesRetry() { return this.analyzeEntitiesRetry; } From 2a0ed5a77732a377cab044369eb51d847a7c4b86 Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 8 May 2023 17:13:14 -0400 Subject: [PATCH 08/10] chore: update sonar exclusion logic by directory name --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a66f0b35c8..6831f4a7a8 100644 --- a/pom.xml +++ b/pom.xml @@ -75,7 +75,7 @@ UTF-8 **/*IntegrationTest* - spring-cloud-previews/**/!(LanguageServiceSpring*).java + spring-cloud-previews/!(google-cloud-language-spring-starter)/** From b7acf97456a63812f7e07a792c4c4627c2a95d87 Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 8 May 2023 17:24:10 -0400 Subject: [PATCH 09/10] temp: mock generate code changes from additional method-level retry This reverts commit 9edf5024998fe540776e36f96c5b265f5ac058fc. --- .../LanguageServiceSpringAutoConfiguration.java | 14 ++++++++++++++ .../v1/spring/LanguageServiceSpringProperties.java | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java index 7607eb4343..9cbfcf7668 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java @@ -212,6 +212,20 @@ public LanguageServiceSettings languageServiceSettings( "Configured method-level retry settings for analyzeSentiment from properties."); } } + Retry analyzeSentimentRetryCopy = clientProperties.getAnalyzeSentimentRetryCopy(); + if (analyzeSentimentRetryCopy != null) { + RetrySettings analyzeSentimentRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.analyzeSentimentSettings().getRetrySettings(), + analyzeSentimentRetryCopy); + clientSettingsBuilder + .analyzeSentimentSettings() + .setRetrySettings(analyzeSentimentRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for analyzeSentiment from properties (copy)."); + } + } Retry analyzeEntitiesRetry = clientProperties.getAnalyzeEntitiesRetry(); if (analyzeEntitiesRetry != null) { RetrySettings analyzeEntitiesRetrySettings = diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java index 2dc3ba178f..a6706b1f3b 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java @@ -49,6 +49,11 @@ public class LanguageServiceSpringProperties implements CredentialsSupplier { * precedence over service-level retry configurations for that RPC method. */ @NestedConfigurationProperty private Retry analyzeSentimentRetry; + /** + * Allow override of retry settings at method-level for analyzeSentiment. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry analyzeSentimentRetryCopy; /** * Allow override of retry settings at method-level for analyzeEntities. If defined, this takes * precedence over service-level retry configurations for that RPC method. @@ -120,6 +125,14 @@ public void setAnalyzeSentimentRetry(Retry analyzeSentimentRetry) { this.analyzeSentimentRetry = analyzeSentimentRetry; } + public Retry getAnalyzeSentimentRetryCopy() { + return this.analyzeSentimentRetryCopy; + } + + public void setAnalyzeSentimentRetryCopy(Retry analyzeSentimentRetryCopy) { + this.analyzeSentimentRetryCopy = analyzeSentimentRetryCopy; + } + public Retry getAnalyzeEntitiesRetry() { return this.analyzeEntitiesRetry; } From bd1367c06ca5eda377af6a7edc16bbe03237f89f Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 8 May 2023 17:55:34 -0400 Subject: [PATCH 10/10] Revert "temp: mock generate code changes from additional method-level retry" This reverts commit b7acf97456a63812f7e07a792c4c4627c2a95d87. --- .../LanguageServiceSpringAutoConfiguration.java | 14 -------------- .../v1/spring/LanguageServiceSpringProperties.java | 13 ------------- 2 files changed, 27 deletions(-) diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java index 9cbfcf7668..7607eb4343 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java @@ -212,20 +212,6 @@ public LanguageServiceSettings languageServiceSettings( "Configured method-level retry settings for analyzeSentiment from properties."); } } - Retry analyzeSentimentRetryCopy = clientProperties.getAnalyzeSentimentRetryCopy(); - if (analyzeSentimentRetryCopy != null) { - RetrySettings analyzeSentimentRetrySettings = - RetryUtil.updateRetrySettings( - clientSettingsBuilder.analyzeSentimentSettings().getRetrySettings(), - analyzeSentimentRetryCopy); - clientSettingsBuilder - .analyzeSentimentSettings() - .setRetrySettings(analyzeSentimentRetrySettings); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace( - "Configured method-level retry settings for analyzeSentiment from properties (copy)."); - } - } Retry analyzeEntitiesRetry = clientProperties.getAnalyzeEntitiesRetry(); if (analyzeEntitiesRetry != null) { RetrySettings analyzeEntitiesRetrySettings = diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java index a6706b1f3b..2dc3ba178f 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java @@ -49,11 +49,6 @@ public class LanguageServiceSpringProperties implements CredentialsSupplier { * precedence over service-level retry configurations for that RPC method. */ @NestedConfigurationProperty private Retry analyzeSentimentRetry; - /** - * Allow override of retry settings at method-level for analyzeSentiment. If defined, this takes - * precedence over service-level retry configurations for that RPC method. - */ - @NestedConfigurationProperty private Retry analyzeSentimentRetryCopy; /** * Allow override of retry settings at method-level for analyzeEntities. If defined, this takes * precedence over service-level retry configurations for that RPC method. @@ -125,14 +120,6 @@ public void setAnalyzeSentimentRetry(Retry analyzeSentimentRetry) { this.analyzeSentimentRetry = analyzeSentimentRetry; } - public Retry getAnalyzeSentimentRetryCopy() { - return this.analyzeSentimentRetryCopy; - } - - public void setAnalyzeSentimentRetryCopy(Retry analyzeSentimentRetryCopy) { - this.analyzeSentimentRetryCopy = analyzeSentimentRetryCopy; - } - public Retry getAnalyzeEntitiesRetry() { return this.analyzeEntitiesRetry; }