@@ -38,24 +38,14 @@ void enabledWithReason() {
3838 .isEqualTo ("ConditionEvaluationResult [enabled = true, reason = 'reason']" );
3939 }
4040
41- @ EmptyReasonsTest
42- void enabledWithInvalidReason (String reason ) {
43- @ SuppressWarnings ("NullAway" )
41+ @ BlankReasonsTest
42+ void enabledWithBlankReason (String reason ) {
4443 var result = ConditionEvaluationResult .enabled (reason );
4544
4645 assertThat (result .isDisabled ()).isFalse ();
47-
48- if (reason == null ) {
49- assertThat (result .getReason ()).isEmpty ();
50- assertThat (result ).asString ()//
51- .isEqualTo ("ConditionEvaluationResult [enabled = true, reason = '<unknown>']" );
52- }
53- // TODO Remove else-block once issues are addressed.
54- else {
55- assertThat (result .getReason ()).contains (reason );
56- assertThat (result ).asString ()//
57- .isEqualTo ("ConditionEvaluationResult [enabled = true, reason = '%s']" , reason );
58- }
46+ assertThat (result .getReason ()).isEmpty ();
47+ assertThat (result ).asString ()//
48+ .isEqualTo ("ConditionEvaluationResult [enabled = true, reason = '<unknown>']" );
5949 }
6050
6151 @ Test
@@ -68,29 +58,18 @@ void disabledWithDefaultReason() {
6858 .isEqualTo ("ConditionEvaluationResult [enabled = false, reason = 'default']" );
6959 }
7060
71- @ EmptyReasonsTest
72- void disabledWithInvalidDefaultReason (String reason ) {
73- @ SuppressWarnings ("NullAway" )
61+ @ BlankReasonsTest
62+ void disabledWithBlankDefaultReason (String reason ) {
7463 var result = ConditionEvaluationResult .disabled (reason );
7564
7665 assertThat (result .isDisabled ()).isTrue ();
77-
78- if (reason == null ) {
79- assertThat (result .getReason ()).isEmpty ();
80- assertThat (result ).asString ()//
81- .isEqualTo ("ConditionEvaluationResult [enabled = false, reason = '<unknown>']" );
82- }
83- // TODO Remove else-block once issues are addressed.
84- else {
85- assertThat (result .getReason ()).contains (reason );
86- assertThat (result ).asString ()//
87- .isEqualTo ("ConditionEvaluationResult [enabled = false, reason = '%s']" , reason );
88- }
66+ assertThat (result .getReason ()).isEmpty ();
67+ assertThat (result ).asString ()//
68+ .isEqualTo ("ConditionEvaluationResult [enabled = false, reason = '<unknown>']" );
8969 }
9070
91- @ EmptyReasonsTest
92- void disabledWithValidDefaultReasonAndInvalidCustomReason (String customReason ) {
93- @ SuppressWarnings ("NullAway" )
71+ @ BlankReasonsTest
72+ void disabledWithDefaultReasonAndBlankCustomReason (String customReason ) {
9473 var result = ConditionEvaluationResult .disabled ("default" , customReason );
9574
9675 assertThat (result .isDisabled ()).isTrue ();
@@ -99,53 +78,28 @@ void disabledWithValidDefaultReasonAndInvalidCustomReason(String customReason) {
9978 .isEqualTo ("ConditionEvaluationResult [enabled = false, reason = 'default']" );
10079 }
10180
102- @ EmptyReasonsTest
103- void disabledWithInvalidDefaultReasonAndValidCustomReason (String reason ) {
104- @ SuppressWarnings ("NullAway" )
81+ @ BlankReasonsTest
82+ void disabledWithBlankDefaultReasonAndCustomReason (String reason ) {
10583 var result = ConditionEvaluationResult .disabled (reason , "custom" );
10684
10785 assertThat (result .isDisabled ()).isTrue ();
108-
109- // TODO Convert to single assertion once issues are addressed.
110- // The following should hold for all null/blank default reasons.
111- // assertThat(result).asString().isEqualTo("ConditionEvaluationResult [enabled = false, reason = 'custom']");
112-
113- if (reason == null ) {
114- assertThat (result .getReason ()).contains ("null ==> custom" );
115- assertThat (result ).asString ()//
116- .isEqualTo ("ConditionEvaluationResult [enabled = false, reason = 'null ==> custom']" );
117- }
118- else {
119- var generatedReason = reason + " ==> custom" ;
120- assertThat (result .getReason ()).contains (generatedReason );
121- assertThat (result ).asString ()//
122- .isEqualTo ("ConditionEvaluationResult [enabled = false, reason = '%s']" , generatedReason );
123- }
86+ assertThat (result .getReason ()).contains ("custom" );
87+ assertThat (result ).asString ().isEqualTo ("ConditionEvaluationResult [enabled = false, reason = 'custom']" );
12488 }
12589
126- @ EmptyReasonsTest
127- void disabledWithInvalidDefaultReasonAndInvalidCustomReason (String reason ) {
90+ @ BlankReasonsTest
91+ void disabledWithBlankDefaultReasonAndBlankCustomReason (String reason ) {
12892 // We intentionally use the reason as both the default and custom reason.
129- @ SuppressWarnings ("NullAway" )
13093 var result = ConditionEvaluationResult .disabled (reason , reason );
13194
13295 assertThat (result .isDisabled ()).isTrue ();
133-
134- if (reason == null ) {
135- assertThat (result .getReason ()).isEmpty ();
136- assertThat (result ).asString ()//
137- .isEqualTo ("ConditionEvaluationResult [enabled = false, reason = '<unknown>']" );
138- }
139- // TODO Remove else-block once issues are addressed.
140- else {
141- assertThat (result .getReason ()).contains (reason );
142- assertThat (result ).asString ()//
143- .isEqualTo ("ConditionEvaluationResult [enabled = false, reason = '%s']" , reason );
144- }
96+ assertThat (result .getReason ()).isEmpty ();
97+ assertThat (result ).asString ()//
98+ .isEqualTo ("ConditionEvaluationResult [enabled = false, reason = '<unknown>']" );
14599 }
146100
147101 @ Test
148- void disabledWithValidDefaultReasonAndCustomReason () {
102+ void disabledWithDefaultReasonAndCustomReason () {
149103 var result = ConditionEvaluationResult .disabled ("default" , "custom" );
150104
151105 assertThat (result .isDisabled ()).isTrue ();
@@ -158,7 +112,7 @@ void disabledWithValidDefaultReasonAndCustomReason() {
158112 @ ParameterizedTest (name = "[{index}] reason=\" {0}\" " )
159113 @ NullSource
160114 @ ValueSource (strings = { "" , " " , " " , "\t " , "\n " })
161- @interface EmptyReasonsTest {
115+ @interface BlankReasonsTest {
162116 }
163117
164118}
0 commit comments