Merge pull request #42457 from izeye

* pr/42457:
  Polish

Closes gh-42457
This commit is contained in:
Moritz Halbritter
2024-09-27 12:25:26 +02:00
9 changed files with 32 additions and 34 deletions

View File

@@ -44,7 +44,7 @@ final class OtlpLoggingConfigurations {
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "management.otlp.logging", name = "endpoint")
OtlpLoggingConnectionDetails otlpLogsConnectionDetails(OtlpLoggingProperties properties) {
OtlpLoggingConnectionDetails otlpLoggingConnectionDetails(OtlpLoggingProperties properties) {
return new PropertiesOtlpLoggingConnectionDetails(properties);
}

View File

@@ -32,6 +32,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.boot.actuate.autoconfigure.opentelemetry.OpenTelemetryAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
@@ -50,9 +51,8 @@ class OpenTelemetryLoggingAutoConfigurationTests {
private final ApplicationContextRunner contextRunner;
OpenTelemetryLoggingAutoConfigurationTests() {
this.contextRunner = new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(
org.springframework.boot.actuate.autoconfigure.opentelemetry.OpenTelemetryAutoConfiguration.class,
OpenTelemetryLoggingAutoConfiguration.class));
this.contextRunner = new ApplicationContextRunner().withConfiguration(AutoConfigurations
.of(OpenTelemetryAutoConfiguration.class, OpenTelemetryLoggingAutoConfiguration.class));
}
@Test
@@ -82,8 +82,8 @@ class OpenTelemetryLoggingAutoConfigurationTests {
}
@Test
void shouldAllowMultipleLogRecordExporter() {
this.contextRunner.withUserConfiguration(MultipleLogRecordExporterConfig.class).run((context) -> {
void shouldAllowMultipleLogRecordExporters() {
this.contextRunner.withUserConfiguration(MultipleLogRecordExportersConfig.class).run((context) -> {
assertThat(context).hasSingleBean(BatchLogRecordProcessor.class);
assertThat(context.getBeansOfType(LogRecordExporter.class)).hasSize(2);
assertThat(context).hasBean("customLogRecordExporter1");
@@ -92,8 +92,8 @@ class OpenTelemetryLoggingAutoConfigurationTests {
}
@Test
void shouldAllowMultipleLogRecordProcessorInAdditionToBatchLogRecordProcessor() {
this.contextRunner.withUserConfiguration(MultipleLogRecordProcessorConfig.class).run((context) -> {
void shouldAllowMultipleLogRecordProcessorsInAdditionToBatchLogRecordProcessor() {
this.contextRunner.withUserConfiguration(MultipleLogRecordProcessorsConfig.class).run((context) -> {
assertThat(context).hasSingleBean(BatchLogRecordProcessor.class);
assertThat(context).hasSingleBean(SdkLoggerProvider.class);
assertThat(context.getBeansOfType(LogRecordProcessor.class)).hasSize(3);
@@ -104,11 +104,11 @@ class OpenTelemetryLoggingAutoConfigurationTests {
}
@Test
void shouldAllowMultipleSdkLoggerProviderBuilderCustomizer() {
this.contextRunner.withUserConfiguration(MultipleSdkLoggerProviderBuilderCustomizerConfig.class)
void shouldAllowMultipleSdkLoggerProviderBuilderCustomizers() {
this.contextRunner.withUserConfiguration(MultipleSdkLoggerProviderBuilderCustomizersConfig.class)
.run((context) -> {
assertThat(context).hasSingleBean(SdkLoggerProvider.class);
assertThat(context.getBeansOfType(NoopSdkLoggerProviderBuilderCustomizer.class)).hasSize(2);
assertThat(context.getBeansOfType(SdkLoggerProviderBuilderCustomizer.class)).hasSize(2);
assertThat(context).hasBean("customSdkLoggerProviderBuilderCustomizer1");
assertThat(context).hasBean("customSdkLoggerProviderBuilderCustomizer2");
assertThat(context
@@ -136,7 +136,7 @@ class OpenTelemetryLoggingAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
public static class MultipleLogRecordExporterConfig {
public static class MultipleLogRecordExportersConfig {
@Bean
public LogRecordExporter customLogRecordExporter1() {
@@ -151,7 +151,7 @@ class OpenTelemetryLoggingAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
public static class MultipleLogRecordProcessorConfig {
public static class MultipleLogRecordProcessorsConfig {
@Bean
public LogRecordProcessor customLogRecordProcessor1() {
@@ -166,7 +166,7 @@ class OpenTelemetryLoggingAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
public static class MultipleSdkLoggerProviderBuilderCustomizerConfig {
public static class MultipleSdkLoggerProviderBuilderCustomizersConfig {
@Bean
public SdkLoggerProviderBuilderCustomizer customSdkLoggerProviderBuilderCustomizer1() {

View File

@@ -89,8 +89,8 @@ class OtlpLoggingAutoConfigurationTests {
}
@Test
void shouldBackOffWhenCustomOtlpLogsConnectionDetailsIsDefined() {
this.contextRunner.withUserConfiguration(CustomOtlpLogsConnectionDetails.class).run((context) -> {
void shouldBackOffWhenCustomOtlpLoggingConnectionDetailsIsDefined() {
this.contextRunner.withUserConfiguration(CustomOtlpLoggingConnectionDetails.class).run((context) -> {
assertThat(context).hasSingleBean(OtlpLoggingConnectionDetails.class)
.doesNotHaveBean(PropertiesOtlpLoggingConnectionDetails.class);
OtlpHttpLogRecordExporter otlpHttpLogRecordExporter = context.getBean(OtlpHttpLogRecordExporter.class);
@@ -121,10 +121,10 @@ class OtlpLoggingAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
public static class CustomOtlpLogsConnectionDetails {
public static class CustomOtlpLoggingConnectionDetails {
@Bean
public OtlpLoggingConnectionDetails customOtlpLogsConnectionDetails() {
public OtlpLoggingConnectionDetails customOtlpLoggingConnectionDetails() {
return (transport) -> "https://otel.example.com/v1/logs";
}

View File

@@ -40,7 +40,7 @@ class OnEnabledTracingConditionTests {
@Test
void shouldMatchIfNoPropertyIsSet() {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(), mockMetaData(""));
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(), mockMetadata(""));
assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage()).isEqualTo("@ConditionalOnEnabledTracing tracing is enabled by default");
}
@@ -49,7 +49,7 @@ class OnEnabledTracingConditionTests {
void shouldNotMatchIfGlobalPropertyIsFalse() {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition
.getMatchOutcome(mockConditionContext(Map.of("management.tracing.enabled", "false")), mockMetaData(""));
.getMatchOutcome(mockConditionContext(Map.of("management.tracing.enabled", "false")), mockMetadata(""));
assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage()).isEqualTo("@ConditionalOnEnabledTracing management.tracing.enabled is false");
}
@@ -58,7 +58,7 @@ class OnEnabledTracingConditionTests {
void shouldMatchIfGlobalPropertyIsTrue() {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition
.getMatchOutcome(mockConditionContext(Map.of("management.tracing.enabled", "true")), mockMetaData(""));
.getMatchOutcome(mockConditionContext(Map.of("management.tracing.enabled", "true")), mockMetadata(""));
assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage()).isEqualTo("@ConditionalOnEnabledTracing management.tracing.enabled is true");
}
@@ -68,7 +68,7 @@ class OnEnabledTracingConditionTests {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition.getMatchOutcome(
mockConditionContext(Map.of("management.zipkin.tracing.export.enabled", "false")),
mockMetaData("zipkin"));
mockMetadata("zipkin"));
assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage())
.isEqualTo("@ConditionalOnEnabledTracing management.zipkin.tracing.export.enabled is false");
@@ -79,7 +79,7 @@ class OnEnabledTracingConditionTests {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition.getMatchOutcome(
mockConditionContext(Map.of("management.zipkin.tracing.export.enabled", "true")),
mockMetaData("zipkin"));
mockMetadata("zipkin"));
assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage())
.isEqualTo("@ConditionalOnEnabledTracing management.zipkin.tracing.export.enabled is true");
@@ -90,7 +90,7 @@ class OnEnabledTracingConditionTests {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(
Map.of("management.tracing.enabled", "false", "management.zipkin.tracing.export.enabled", "true")),
mockMetaData("zipkin"));
mockMetadata("zipkin"));
assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage())
.isEqualTo("@ConditionalOnEnabledTracing management.zipkin.tracing.export.enabled is true");
@@ -101,7 +101,7 @@ class OnEnabledTracingConditionTests {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(
Map.of("management.tracing.enabled", "true", "management.zipkin.tracing.export.enabled", "false")),
mockMetaData("zipkin"));
mockMetadata("zipkin"));
assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage())
.isEqualTo("@ConditionalOnEnabledTracing management.zipkin.tracing.export.enabled is false");
@@ -119,7 +119,7 @@ class OnEnabledTracingConditionTests {
return context;
}
private AnnotatedTypeMetadata mockMetaData(String exporter) {
private AnnotatedTypeMetadata mockMetadata(String exporter) {
AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
given(metadata.getAnnotationAttributes(ConditionalOnEnabledTracing.class.getName()))
.willReturn(Map.of("value", exporter));

View File

@@ -34,7 +34,6 @@ public interface JCachePropertiesCustomizer {
/**
* Customize the properties.
* @param properties the current properties
*
*/
void customize(Properties properties);

View File

@@ -84,7 +84,7 @@ public class SpringDataWebProperties {
private int maxPageSize = 2000;
/**
* Configures how to render spring data Pageable instances.
* Configures how to render Spring Data Pageable instances.
*/
private PageSerializationMode serializationMode = PageSerializationMode.DIRECT;

View File

@@ -65,12 +65,12 @@ class ConditionalOnExpressionTests {
MockEnvironment environment = new MockEnvironment();
ConditionContext conditionContext = mock(ConditionContext.class);
given(conditionContext.getEnvironment()).willReturn(environment);
ConditionOutcome outcome = condition.getMatchOutcome(conditionContext, mockMetaData("invalid-spel"));
ConditionOutcome outcome = condition.getMatchOutcome(conditionContext, mockMetadata("invalid-spel"));
assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage()).contains("invalid-spel").contains("no BeanFactory available");
}
private AnnotatedTypeMetadata mockMetaData(String value) {
private AnnotatedTypeMetadata mockMetadata(String value) {
AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
given(metadata.getAnnotationAttributes(ConditionalOnExpression.class.getName()))
.willReturn(Collections.singletonMap("value", value));

View File

@@ -101,14 +101,14 @@ class ConditionalOnJndiTests {
@Test
void jndiLocationNotFound() {
ConditionOutcome outcome = this.condition.getMatchOutcome(null, mockMetaData("java:/a"));
ConditionOutcome outcome = this.condition.getMatchOutcome(null, mockMetadata("java:/a"));
assertThat(outcome.isMatch()).isFalse();
}
@Test
void jndiLocationFound() {
this.condition.setFoundLocation("java:/b");
ConditionOutcome outcome = this.condition.getMatchOutcome(null, mockMetaData("java:/a", "java:/b"));
ConditionOutcome outcome = this.condition.getMatchOutcome(null, mockMetadata("java:/a", "java:/b"));
assertThat(outcome.isMatch()).isTrue();
}
@@ -117,7 +117,7 @@ class ConditionalOnJndiTests {
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, TestableInitialContextFactory.class.getName());
}
private AnnotatedTypeMetadata mockMetaData(String... value) {
private AnnotatedTypeMetadata mockMetadata(String... value) {
AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
Map<String, Object> attributes = new HashMap<>();
attributes.put("value", value);

View File

@@ -1489,7 +1489,6 @@ bom {
group("com.oracle.database.security") {
modules = [
"oraclepki"
]
}
group("com.oracle.database.xml") {