Merge pull request #43331 from izeye
* pr/43331: Polish "Fix property name in OnEnabledLoggingExportConditionTests" Fix property name in OnEnabledLoggingExportConditionTests Closes gh-43331
This commit is contained in:
commit
4421fa4178
|
@ -38,6 +38,10 @@ import static org.mockito.Mockito.mock;
|
||||||
*/
|
*/
|
||||||
class OnEnabledLoggingExportConditionTests {
|
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
|
@Test
|
||||||
void shouldMatchIfNoPropertyIsSet() {
|
void shouldMatchIfNoPropertyIsSet() {
|
||||||
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
||||||
|
@ -49,8 +53,8 @@ class OnEnabledLoggingExportConditionTests {
|
||||||
@Test
|
@Test
|
||||||
void shouldNotMatchIfGlobalPropertyIsFalse() {
|
void shouldNotMatchIfGlobalPropertyIsFalse() {
|
||||||
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
||||||
ConditionOutcome outcome = condition.getMatchOutcome(
|
ConditionOutcome outcome = condition
|
||||||
mockConditionContext(Map.of("management.logging.export.enabled", "false")), mockMetadata(""));
|
.getMatchOutcome(mockConditionContext(Map.of(GLOBAL_PROPERTY_NAME, "false")), mockMetadata(""));
|
||||||
assertThat(outcome.isMatch()).isFalse();
|
assertThat(outcome.isMatch()).isFalse();
|
||||||
assertThat(outcome.getMessage())
|
assertThat(outcome.getMessage())
|
||||||
.isEqualTo("@ConditionalOnEnabledLoggingExport management.logging.export.enabled is false");
|
.isEqualTo("@ConditionalOnEnabledLoggingExport management.logging.export.enabled is false");
|
||||||
|
@ -59,8 +63,8 @@ class OnEnabledLoggingExportConditionTests {
|
||||||
@Test
|
@Test
|
||||||
void shouldMatchIfGlobalPropertyIsTrue() {
|
void shouldMatchIfGlobalPropertyIsTrue() {
|
||||||
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
||||||
ConditionOutcome outcome = condition.getMatchOutcome(
|
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(Map.of(GLOBAL_PROPERTY_NAME, "true")),
|
||||||
mockConditionContext(Map.of("management.logging.export.enabled", "true")), mockMetadata(""));
|
mockMetadata(""));
|
||||||
assertThat(outcome.isMatch()).isTrue();
|
assertThat(outcome.isMatch()).isTrue();
|
||||||
assertThat(outcome.getMessage())
|
assertThat(outcome.getMessage())
|
||||||
.isEqualTo("@ConditionalOnEnabledLoggingExport management.logging.export.enabled is true");
|
.isEqualTo("@ConditionalOnEnabledLoggingExport management.logging.export.enabled is true");
|
||||||
|
@ -69,8 +73,8 @@ class OnEnabledLoggingExportConditionTests {
|
||||||
@Test
|
@Test
|
||||||
void shouldNotMatchIfExporterPropertyIsFalse() {
|
void shouldNotMatchIfExporterPropertyIsFalse() {
|
||||||
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
||||||
ConditionOutcome outcome = condition.getMatchOutcome(
|
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(Map.of(OTLP_PROPERTY_NAME, "false")),
|
||||||
mockConditionContext(Map.of("management.otlp.logging.export.enabled", "false")), mockMetadata("otlp"));
|
mockMetadata("otlp"));
|
||||||
assertThat(outcome.isMatch()).isFalse();
|
assertThat(outcome.isMatch()).isFalse();
|
||||||
assertThat(outcome.getMessage())
|
assertThat(outcome.getMessage())
|
||||||
.isEqualTo("@ConditionalOnEnabledLoggingExport management.otlp.logging.export.enabled is false");
|
.isEqualTo("@ConditionalOnEnabledLoggingExport management.otlp.logging.export.enabled is false");
|
||||||
|
@ -79,8 +83,8 @@ class OnEnabledLoggingExportConditionTests {
|
||||||
@Test
|
@Test
|
||||||
void shouldMatchIfExporterPropertyIsTrue() {
|
void shouldMatchIfExporterPropertyIsTrue() {
|
||||||
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
||||||
ConditionOutcome outcome = condition.getMatchOutcome(
|
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(Map.of(OTLP_PROPERTY_NAME, "true")),
|
||||||
mockConditionContext(Map.of("management.otlp.logging.export.enabled", "true")), mockMetadata("otlp"));
|
mockMetadata("otlp"));
|
||||||
assertThat(outcome.isMatch()).isTrue();
|
assertThat(outcome.isMatch()).isTrue();
|
||||||
assertThat(outcome.getMessage())
|
assertThat(outcome.getMessage())
|
||||||
.isEqualTo("@ConditionalOnEnabledLoggingExport management.otlp.logging.export.enabled is true");
|
.isEqualTo("@ConditionalOnEnabledLoggingExport management.otlp.logging.export.enabled is true");
|
||||||
|
@ -89,8 +93,8 @@ class OnEnabledLoggingExportConditionTests {
|
||||||
@Test
|
@Test
|
||||||
void exporterPropertyShouldOverrideGlobalPropertyIfTrue() {
|
void exporterPropertyShouldOverrideGlobalPropertyIfTrue() {
|
||||||
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
||||||
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(
|
ConditionOutcome outcome = condition.getMatchOutcome(
|
||||||
Map.of("management.logging.enabled", "false", "management.otlp.logging.export.enabled", "true")),
|
mockConditionContext(Map.of(GLOBAL_PROPERTY_NAME, "false", OTLP_PROPERTY_NAME, "true")),
|
||||||
mockMetadata("otlp"));
|
mockMetadata("otlp"));
|
||||||
assertThat(outcome.isMatch()).isTrue();
|
assertThat(outcome.isMatch()).isTrue();
|
||||||
assertThat(outcome.getMessage())
|
assertThat(outcome.getMessage())
|
||||||
|
@ -100,8 +104,8 @@ class OnEnabledLoggingExportConditionTests {
|
||||||
@Test
|
@Test
|
||||||
void exporterPropertyShouldOverrideGlobalPropertyIfFalse() {
|
void exporterPropertyShouldOverrideGlobalPropertyIfFalse() {
|
||||||
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition();
|
||||||
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(
|
ConditionOutcome outcome = condition.getMatchOutcome(
|
||||||
Map.of("management.logging.enabled", "true", "management.otlp.logging.export.enabled", "false")),
|
mockConditionContext(Map.of(GLOBAL_PROPERTY_NAME, "true", OTLP_PROPERTY_NAME, "false")),
|
||||||
mockMetadata("otlp"));
|
mockMetadata("otlp"));
|
||||||
assertThat(outcome.isMatch()).isFalse();
|
assertThat(outcome.isMatch()).isFalse();
|
||||||
assertThat(outcome.getMessage())
|
assertThat(outcome.getMessage())
|
||||||
|
|
Loading…
Reference in New Issue