Skip to content

Commit

Permalink
Merge pull request #43331 from izeye
Browse files Browse the repository at this point in the history
* pr/43331:
  Polish "Fix property name in OnEnabledLoggingExportConditionTests"
  Fix property name in OnEnabledLoggingExportConditionTests

Closes gh-43331
  • Loading branch information
mhalbritter committed Dec 2, 2024
2 parents 32b3995 + d5344e3 commit 4421fa4
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
*/
class OnEnabledLoggingExportConditionTests {

private static final String GLOBAL_PROPERTY_NAME = "management.logging.export.enabled";

private static final String OTLP_PROPERTY_NAME = "management.otlp.logging.export.enabled";

@Test
void shouldMatchIfNoPropertyIsSet() {
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
Expand All @@ -49,8 +53,8 @@ void shouldMatchIfNoPropertyIsSet() {
@Test
void shouldNotMatchIfGlobalPropertyIsFalse() {
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
ConditionOutcome outcome = condition.getMatchOutcome(
mockConditionContext(Map.of("management.logging.export.enabled", "false")), mockMetadata(""));
ConditionOutcome outcome = condition
.getMatchOutcome(mockConditionContext(Map.of(GLOBAL_PROPERTY_NAME, "false")), mockMetadata(""));
assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage())
.isEqualTo("@ConditionalOnEnabledLoggingExport management.logging.export.enabled is false");
Expand All @@ -59,8 +63,8 @@ void shouldNotMatchIfGlobalPropertyIsFalse() {
@Test
void shouldMatchIfGlobalPropertyIsTrue() {
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
ConditionOutcome outcome = condition.getMatchOutcome(
mockConditionContext(Map.of("management.logging.export.enabled", "true")), mockMetadata(""));
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(Map.of(GLOBAL_PROPERTY_NAME, "true")),
mockMetadata(""));
assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage())
.isEqualTo("@ConditionalOnEnabledLoggingExport management.logging.export.enabled is true");
Expand All @@ -69,8 +73,8 @@ void shouldMatchIfGlobalPropertyIsTrue() {
@Test
void shouldNotMatchIfExporterPropertyIsFalse() {
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
ConditionOutcome outcome = condition.getMatchOutcome(
mockConditionContext(Map.of("management.otlp.logging.export.enabled", "false")), mockMetadata("otlp"));
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(Map.of(OTLP_PROPERTY_NAME, "false")),
mockMetadata("otlp"));
assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage())
.isEqualTo("@ConditionalOnEnabledLoggingExport management.otlp.logging.export.enabled is false");
Expand All @@ -79,8 +83,8 @@ void shouldNotMatchIfExporterPropertyIsFalse() {
@Test
void shouldMatchIfExporterPropertyIsTrue() {
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
ConditionOutcome outcome = condition.getMatchOutcome(
mockConditionContext(Map.of("management.otlp.logging.export.enabled", "true")), mockMetadata("otlp"));
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(Map.of(OTLP_PROPERTY_NAME, "true")),
mockMetadata("otlp"));
assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage())
.isEqualTo("@ConditionalOnEnabledLoggingExport management.otlp.logging.export.enabled is true");
Expand All @@ -89,8 +93,8 @@ void shouldMatchIfExporterPropertyIsTrue() {
@Test
void exporterPropertyShouldOverrideGlobalPropertyIfTrue() {
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(
Map.of("management.logging.enabled", "false", "management.otlp.logging.export.enabled", "true")),
ConditionOutcome outcome = condition.getMatchOutcome(
mockConditionContext(Map.of(GLOBAL_PROPERTY_NAME, "false", OTLP_PROPERTY_NAME, "true")),
mockMetadata("otlp"));
assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage())
Expand All @@ -100,8 +104,8 @@ void exporterPropertyShouldOverrideGlobalPropertyIfTrue() {
@Test
void exporterPropertyShouldOverrideGlobalPropertyIfFalse() {
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(
Map.of("management.logging.enabled", "true", "management.otlp.logging.export.enabled", "false")),
ConditionOutcome outcome = condition.getMatchOutcome(
mockConditionContext(Map.of(GLOBAL_PROPERTY_NAME, "true", OTLP_PROPERTY_NAME, "false")),
mockMetadata("otlp"));
assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage())
Expand Down

0 comments on commit 4421fa4

Please sign in to comment.