31
31
import ch .qos .logback .core .AppenderBase ;
32
32
import java .util .LinkedList ;
33
33
import java .util .List ;
34
- import java .util .Optional ;
35
34
import org .junit .jupiter .api .AfterEach ;
36
35
import org .junit .jupiter .api .BeforeEach ;
37
36
import org .junit .jupiter .api .Test ;
@@ -62,32 +61,32 @@ void tearDown() {
62
61
private final V visitor ;
63
62
64
63
/**
65
- * The optional expected response when being visited by a commander.
64
+ * The expected response when being visited by a commander.
66
65
*/
67
- private final Optional < String > commanderResponse ;
66
+ private final String commanderResponse ;
68
67
69
68
/**
70
- * The optional expected response when being visited by a sergeant.
69
+ * The expected response when being visited by a sergeant.
71
70
*/
72
- private final Optional < String > sergeantResponse ;
71
+ private final String sergeantResponse ;
73
72
74
73
/**
75
- * The optional expected response when being visited by a soldier.
74
+ * The expected response when being visited by a soldier.
76
75
*/
77
- private final Optional < String > soldierResponse ;
76
+ private final String soldierResponse ;
78
77
79
78
/**
80
79
* Create a new test instance for the given visitor.
81
80
*
82
- * @param commanderResponse The optional expected response when being visited by a commander
83
- * @param sergeantResponse The optional expected response when being visited by a sergeant
84
- * @param soldierResponse The optional expected response when being visited by a soldier
81
+ * @param commanderResponse The expected response when being visited by a commander
82
+ * @param sergeantResponse The expected response when being visited by a sergeant
83
+ * @param soldierResponse The expected response when being visited by a soldier
85
84
*/
86
85
public VisitorTest (
87
86
final V visitor ,
88
- final Optional < String > commanderResponse ,
89
- final Optional < String > sergeantResponse ,
90
- final Optional < String > soldierResponse
87
+ final String commanderResponse ,
88
+ final String sergeantResponse ,
89
+ final String soldierResponse
91
90
) {
92
91
this .visitor = visitor ;
93
92
this .commanderResponse = commanderResponse ;
@@ -98,26 +97,26 @@ public VisitorTest(
98
97
@ Test
99
98
void testVisitCommander () {
100
99
this .visitor .visit (new Commander ());
101
- if (this .commanderResponse . isPresent () ) {
102
- assertEquals (this .commanderResponse . get () , appender .getLastMessage ());
100
+ if (this .commanderResponse != null ) {
101
+ assertEquals (this .commanderResponse , appender .getLastMessage ());
103
102
assertEquals (1 , appender .getLogSize ());
104
103
}
105
104
}
106
105
107
106
@ Test
108
107
void testVisitSergeant () {
109
108
this .visitor .visit (new Sergeant ());
110
- if (this .sergeantResponse . isPresent () ) {
111
- assertEquals (this .sergeantResponse . get () , appender .getLastMessage ());
109
+ if (this .sergeantResponse != null ) {
110
+ assertEquals (this .sergeantResponse , appender .getLastMessage ());
112
111
assertEquals (1 , appender .getLogSize ());
113
112
}
114
113
}
115
114
116
115
@ Test
117
116
void testVisitSoldier () {
118
117
this .visitor .visit (new Soldier ());
119
- if (this .soldierResponse . isPresent () ) {
120
- assertEquals (this .soldierResponse . get () , appender .getLastMessage ());
118
+ if (this .soldierResponse != null ) {
119
+ assertEquals (this .soldierResponse , appender .getLastMessage ());
121
120
assertEquals (1 , appender .getLogSize ());
122
121
}
123
122
}
0 commit comments