Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add language starter module back to sonar analysis #1816

Merged
merged 10 commits into from
May 15, 2023
Merged
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<integration-test.pattern>**/*IntegrationTest*</integration-test.pattern>
<!-- exclude preview module code from sonar cloud analysis -->
<sonar.exclusions>spring-cloud-previews/**/*</sonar.exclusions>
<sonar.exclusions>spring-cloud-previews/!(google-cloud-language-spring-starter)/**</sonar.exclusions>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}