38
38
*/
39
39
class OnEnabledLoggingExportConditionTests {
40
40
41
+ private static final String GLOBAL_PROPERTY_NAME = "management.logging.export.enabled" ;
42
+
43
+ private static final String OTLP_PROPERTY_NAME = "management.otlp.logging.export.enabled" ;
44
+
41
45
@ Test
42
46
void shouldMatchIfNoPropertyIsSet () {
43
47
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition ();
@@ -49,8 +53,8 @@ void shouldMatchIfNoPropertyIsSet() {
49
53
@ Test
50
54
void shouldNotMatchIfGlobalPropertyIsFalse () {
51
55
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition ();
52
- ConditionOutcome outcome = condition . getMatchOutcome (
53
- mockConditionContext (Map .of ("management.logging.export.enabled" , "false" )), mockMetadata ("" ));
56
+ ConditionOutcome outcome = condition
57
+ . getMatchOutcome ( mockConditionContext (Map .of (GLOBAL_PROPERTY_NAME , "false" )), mockMetadata ("" ));
54
58
assertThat (outcome .isMatch ()).isFalse ();
55
59
assertThat (outcome .getMessage ())
56
60
.isEqualTo ("@ConditionalOnEnabledLoggingExport management.logging.export.enabled is false" );
@@ -59,8 +63,8 @@ void shouldNotMatchIfGlobalPropertyIsFalse() {
59
63
@ Test
60
64
void shouldMatchIfGlobalPropertyIsTrue () {
61
65
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition ();
62
- ConditionOutcome outcome = condition .getMatchOutcome (
63
- mockConditionContext ( Map . of ( "management.logging.export.enabled" , "true" )), mockMetadata ("" ));
66
+ ConditionOutcome outcome = condition .getMatchOutcome (mockConditionContext ( Map . of ( GLOBAL_PROPERTY_NAME , "true" )),
67
+ mockMetadata ("" ));
64
68
assertThat (outcome .isMatch ()).isTrue ();
65
69
assertThat (outcome .getMessage ())
66
70
.isEqualTo ("@ConditionalOnEnabledLoggingExport management.logging.export.enabled is true" );
@@ -69,8 +73,8 @@ void shouldMatchIfGlobalPropertyIsTrue() {
69
73
@ Test
70
74
void shouldNotMatchIfExporterPropertyIsFalse () {
71
75
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition ();
72
- ConditionOutcome outcome = condition .getMatchOutcome (
73
- mockConditionContext ( Map . of ( "management.otlp.logging.export.enabled" , "false" )), mockMetadata ("otlp" ));
76
+ ConditionOutcome outcome = condition .getMatchOutcome (mockConditionContext ( Map . of ( OTLP_PROPERTY_NAME , "false" )),
77
+ mockMetadata ("otlp" ));
74
78
assertThat (outcome .isMatch ()).isFalse ();
75
79
assertThat (outcome .getMessage ())
76
80
.isEqualTo ("@ConditionalOnEnabledLoggingExport management.otlp.logging.export.enabled is false" );
@@ -79,8 +83,8 @@ void shouldNotMatchIfExporterPropertyIsFalse() {
79
83
@ Test
80
84
void shouldMatchIfExporterPropertyIsTrue () {
81
85
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition ();
82
- ConditionOutcome outcome = condition .getMatchOutcome (
83
- mockConditionContext ( Map . of ( "management.otlp.logging.export.enabled" , "true" )), mockMetadata ("otlp" ));
86
+ ConditionOutcome outcome = condition .getMatchOutcome (mockConditionContext ( Map . of ( OTLP_PROPERTY_NAME , "true" )),
87
+ mockMetadata ("otlp" ));
84
88
assertThat (outcome .isMatch ()).isTrue ();
85
89
assertThat (outcome .getMessage ())
86
90
.isEqualTo ("@ConditionalOnEnabledLoggingExport management.otlp.logging.export.enabled is true" );
@@ -89,8 +93,8 @@ void shouldMatchIfExporterPropertyIsTrue() {
89
93
@ Test
90
94
void exporterPropertyShouldOverrideGlobalPropertyIfTrue () {
91
95
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition ();
92
- ConditionOutcome outcome = condition .getMatchOutcome (mockConditionContext (
93
- Map .of ("management.logging.enabled" , "false" , "management.otlp.logging.export.enabled" , "true" )),
96
+ ConditionOutcome outcome = condition .getMatchOutcome (
97
+ mockConditionContext ( Map .of (GLOBAL_PROPERTY_NAME , "false" , OTLP_PROPERTY_NAME , "true" )),
94
98
mockMetadata ("otlp" ));
95
99
assertThat (outcome .isMatch ()).isTrue ();
96
100
assertThat (outcome .getMessage ())
@@ -100,8 +104,8 @@ void exporterPropertyShouldOverrideGlobalPropertyIfTrue() {
100
104
@ Test
101
105
void exporterPropertyShouldOverrideGlobalPropertyIfFalse () {
102
106
OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition ();
103
- ConditionOutcome outcome = condition .getMatchOutcome (mockConditionContext (
104
- Map .of ("management.logging.enabled" , "true" , "management.otlp.logging.export.enabled" , "false" )),
107
+ ConditionOutcome outcome = condition .getMatchOutcome (
108
+ mockConditionContext ( Map .of (GLOBAL_PROPERTY_NAME , "true" , OTLP_PROPERTY_NAME , "false" )),
105
109
mockMetadata ("otlp" ));
106
110
assertThat (outcome .isMatch ()).isFalse ();
107
111
assertThat (outcome .getMessage ())
0 commit comments