@@ -38,24 +38,14 @@ void enabledWithReason() {
38
38
.isEqualTo ("ConditionEvaluationResult [enabled = true, reason = 'reason']" );
39
39
}
40
40
41
- @ EmptyReasonsTest
42
- void enabledWithInvalidReason (String reason ) {
43
- @ SuppressWarnings ("NullAway" )
41
+ @ BlankReasonsTest
42
+ void enabledWithBlankReason (String reason ) {
44
43
var result = ConditionEvaluationResult .enabled (reason );
45
44
46
45
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>']" );
59
49
}
60
50
61
51
@ Test
@@ -68,29 +58,18 @@ void disabledWithDefaultReason() {
68
58
.isEqualTo ("ConditionEvaluationResult [enabled = false, reason = 'default']" );
69
59
}
70
60
71
- @ EmptyReasonsTest
72
- void disabledWithInvalidDefaultReason (String reason ) {
73
- @ SuppressWarnings ("NullAway" )
61
+ @ BlankReasonsTest
62
+ void disabledWithBlankDefaultReason (String reason ) {
74
63
var result = ConditionEvaluationResult .disabled (reason );
75
64
76
65
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>']" );
89
69
}
90
70
91
- @ EmptyReasonsTest
92
- void disabledWithValidDefaultReasonAndInvalidCustomReason (String customReason ) {
93
- @ SuppressWarnings ("NullAway" )
71
+ @ BlankReasonsTest
72
+ void disabledWithDefaultReasonAndBlankCustomReason (String customReason ) {
94
73
var result = ConditionEvaluationResult .disabled ("default" , customReason );
95
74
96
75
assertThat (result .isDisabled ()).isTrue ();
@@ -99,53 +78,28 @@ void disabledWithValidDefaultReasonAndInvalidCustomReason(String customReason) {
99
78
.isEqualTo ("ConditionEvaluationResult [enabled = false, reason = 'default']" );
100
79
}
101
80
102
- @ EmptyReasonsTest
103
- void disabledWithInvalidDefaultReasonAndValidCustomReason (String reason ) {
104
- @ SuppressWarnings ("NullAway" )
81
+ @ BlankReasonsTest
82
+ void disabledWithBlankDefaultReasonAndCustomReason (String reason ) {
105
83
var result = ConditionEvaluationResult .disabled (reason , "custom" );
106
84
107
85
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']" );
124
88
}
125
89
126
- @ EmptyReasonsTest
127
- void disabledWithInvalidDefaultReasonAndInvalidCustomReason (String reason ) {
90
+ @ BlankReasonsTest
91
+ void disabledWithBlankDefaultReasonAndBlankCustomReason (String reason ) {
128
92
// We intentionally use the reason as both the default and custom reason.
129
- @ SuppressWarnings ("NullAway" )
130
93
var result = ConditionEvaluationResult .disabled (reason , reason );
131
94
132
95
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>']" );
145
99
}
146
100
147
101
@ Test
148
- void disabledWithValidDefaultReasonAndCustomReason () {
102
+ void disabledWithDefaultReasonAndCustomReason () {
149
103
var result = ConditionEvaluationResult .disabled ("default" , "custom" );
150
104
151
105
assertThat (result .isDisabled ()).isTrue ();
@@ -158,7 +112,7 @@ void disabledWithValidDefaultReasonAndCustomReason() {
158
112
@ ParameterizedTest (name = "[{index}] reason=\" {0}\" " )
159
113
@ NullSource
160
114
@ ValueSource (strings = { "" , " " , " " , "\t " , "\n " })
161
- @interface EmptyReasonsTest {
115
+ @interface BlankReasonsTest {
162
116
}
163
117
164
118
}
0 commit comments