1 |
|
---|
2 | package de.ugoe.cs.quest.eventcore;
|
---|
3 |
|
---|
4 |
|
---|
5 | import org.junit.*;
|
---|
6 |
|
---|
7 | import de.ugoe.cs.quest.eventcore.Event;
|
---|
8 |
|
---|
9 | import static org.junit.Assert.*;
|
---|
10 | import static org.mockito.Mockito.*;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * The class <code>EventTest</code> contains tests for the class <code>{@link Event}</code>.
|
---|
14 | *
|
---|
15 | * @author Steffen Herbold
|
---|
16 | * @version 1.0
|
---|
17 | */
|
---|
18 | public class EventTest {
|
---|
19 |
|
---|
20 | @Test
|
---|
21 | public void testEvent_1() throws Exception {
|
---|
22 | Event result = new Event(mock(IEventType.class));
|
---|
23 |
|
---|
24 | assertNotNull(result);
|
---|
25 | }
|
---|
26 |
|
---|
27 | @Test(expected = java.security.InvalidParameterException.class)
|
---|
28 | public void testEvent_2() throws Exception {
|
---|
29 | new Event(null);
|
---|
30 | }
|
---|
31 |
|
---|
32 | /*
|
---|
33 | @Test
|
---|
34 | public void testEquals_1() throws Exception {
|
---|
35 | IEventType type1 = mock(IEventType.class);
|
---|
36 | IEventType type2 = mock(IEventType.class);
|
---|
37 | // when(type1.equals(type2)).thenReturn(true);
|
---|
38 | Event fixture = new Event(type1);
|
---|
39 | Event other = new Event(type2);
|
---|
40 |
|
---|
41 | boolean result = fixture.equals(other);
|
---|
42 |
|
---|
43 | assertTrue(result);
|
---|
44 | }
|
---|
45 |
|
---|
46 | @Test
|
---|
47 | public void testEquals_2() throws Exception {
|
---|
48 | String type1 = "typeString1";
|
---|
49 | String type2 = "typeString2";
|
---|
50 | Event fixture = new Event(type1);
|
---|
51 | Event other = new Event(type2);
|
---|
52 |
|
---|
53 | boolean result = fixture.equals(other);
|
---|
54 |
|
---|
55 | assertFalse(result);
|
---|
56 | }
|
---|
57 |
|
---|
58 | @Test
|
---|
59 | public void testEquals_3() throws Exception {
|
---|
60 | String type1 = "typeString";
|
---|
61 | String type2 = "typeString";
|
---|
62 | String target1 = "target";
|
---|
63 | String target2 = "target";
|
---|
64 | Event fixture = new Event(type1);
|
---|
65 | fixture.target = target1;
|
---|
66 | Event other = new Event(type2);
|
---|
67 | other.target = target2;
|
---|
68 |
|
---|
69 | boolean result = fixture.equals(other);
|
---|
70 |
|
---|
71 | assertTrue(result);
|
---|
72 | }
|
---|
73 |
|
---|
74 | @Test
|
---|
75 | public void testEquals_4() throws Exception {
|
---|
76 | String type1 = "typeString1";
|
---|
77 | String type2 = "typeString2";
|
---|
78 | String target1 = "target";
|
---|
79 | String target2 = "target";
|
---|
80 | Event fixture = new Event(type1);
|
---|
81 | fixture.target = target1;
|
---|
82 | Event other = new Event(type2);
|
---|
83 | other.target = target2;
|
---|
84 |
|
---|
85 | boolean result = fixture.equals(other);
|
---|
86 |
|
---|
87 | assertFalse(result);
|
---|
88 | }
|
---|
89 |
|
---|
90 | @Test
|
---|
91 | public void testEquals_5() throws Exception {
|
---|
92 | String type1 = "typeString";
|
---|
93 | String type2 = "typeString";
|
---|
94 | String target1 = "target1";
|
---|
95 | String target2 = "target2";
|
---|
96 | Event fixture = new Event(type1);
|
---|
97 | fixture.target = target1;
|
---|
98 | Event other = new Event(type2);
|
---|
99 | other.target = target2;
|
---|
100 |
|
---|
101 | boolean result = fixture.equals(other);
|
---|
102 |
|
---|
103 | assertFalse(result);
|
---|
104 | }
|
---|
105 |
|
---|
106 | @Test
|
---|
107 | public void testEquals_6() throws Exception {
|
---|
108 | String type = "typeString";
|
---|
109 | Event fixture = new Event(type);
|
---|
110 |
|
---|
111 | boolean result = fixture.equals(fixture);
|
---|
112 |
|
---|
113 | assertTrue(result);
|
---|
114 | }
|
---|
115 |
|
---|
116 | @Test
|
---|
117 | public void testEqualsContract() throws Exception {
|
---|
118 | EqualsVerifier.forClass(Event.class).suppress(Warning.NONFINAL_FIELDS)
|
---|
119 | .withRedefinedSubclass(ReplayableEvent.class).verify();
|
---|
120 | }
|
---|
121 | */
|
---|
122 |
|
---|
123 | @Test
|
---|
124 | public void testGetTarget_1() throws Exception {
|
---|
125 | IEventType type = mock(IEventType.class);
|
---|
126 | IEventTarget target = mock(IEventTarget.class);
|
---|
127 |
|
---|
128 | Event fixture = new Event(type);
|
---|
129 | fixture.setTarget(target);
|
---|
130 |
|
---|
131 | IEventTarget result = fixture.getTarget();
|
---|
132 |
|
---|
133 | assertSame(target, result);
|
---|
134 | }
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 | @Test
|
---|
139 | public void testGetTarget_2() throws Exception {
|
---|
140 | IEventType type = mock(IEventType.class);
|
---|
141 | IEventTarget target = mock(IEventTarget.class);
|
---|
142 |
|
---|
143 | Event fixture = new Event(type, target);
|
---|
144 |
|
---|
145 | IEventTarget result = fixture.getTarget();
|
---|
146 |
|
---|
147 | assertSame(target, result);
|
---|
148 | }
|
---|
149 |
|
---|
150 | @Test
|
---|
151 | public void testGetTarget_3() throws Exception {
|
---|
152 | IEventType type = mock(IEventType.class);
|
---|
153 |
|
---|
154 | Event fixture = new Event(type);
|
---|
155 |
|
---|
156 | IEventTarget result = fixture.getTarget();
|
---|
157 |
|
---|
158 | assertNull(result);
|
---|
159 | }
|
---|
160 |
|
---|
161 | @Test
|
---|
162 | public void testGetType_1() throws Exception {
|
---|
163 | IEventType type = mock(IEventType.class);
|
---|
164 |
|
---|
165 | Event fixture = new Event(type);
|
---|
166 |
|
---|
167 | IEventType result = fixture.getType();
|
---|
168 |
|
---|
169 | assertEquals(type, result);
|
---|
170 | }
|
---|
171 |
|
---|
172 | @Test
|
---|
173 | public void testSetTarget_1() throws Exception {
|
---|
174 | IEventType type = mock(IEventType.class);
|
---|
175 | IEventTarget target = mock(IEventTarget.class);
|
---|
176 |
|
---|
177 | Event fixture = new Event(type);
|
---|
178 |
|
---|
179 | boolean result = fixture.setTarget(target);
|
---|
180 |
|
---|
181 | assertTrue(result);
|
---|
182 | assertEquals(target, fixture.getTarget());
|
---|
183 | }
|
---|
184 |
|
---|
185 | @Test
|
---|
186 | public void testSetTarget_2() throws Exception {
|
---|
187 | IEventType type = mock(IEventType.class);
|
---|
188 | IEventTarget target1 = mock(IEventTarget.class);
|
---|
189 | IEventTarget target2 = mock(IEventTarget.class);
|
---|
190 |
|
---|
191 | Event fixture = new Event(type);
|
---|
192 |
|
---|
193 | fixture.setTarget(target1);
|
---|
194 | boolean result = fixture.setTarget(target2);
|
---|
195 |
|
---|
196 | assertFalse(result);
|
---|
197 | assertEquals(target1, fixture.target);
|
---|
198 | }
|
---|
199 |
|
---|
200 | @Test
|
---|
201 | public void testSetTarget_3() throws Exception {
|
---|
202 | IEventType type = mock(IEventType.class);
|
---|
203 | IEventTarget target1 = mock(IEventTarget.class);
|
---|
204 | IEventTarget target2 = mock(IEventTarget.class);
|
---|
205 |
|
---|
206 | Event fixture = new Event(type, target1);
|
---|
207 |
|
---|
208 | boolean result = fixture.setTarget(target2);
|
---|
209 |
|
---|
210 | assertFalse(result);
|
---|
211 | assertEquals(target1, fixture.target);
|
---|
212 | }
|
---|
213 |
|
---|
214 | @Test
|
---|
215 | public void testToString_1() throws Exception {
|
---|
216 | IEventType type = mock(IEventType.class);
|
---|
217 | when(type.toString()).thenReturn("typeString");
|
---|
218 | IEventTarget target = mock(IEventTarget.class);
|
---|
219 | when(target.toString()).thenReturn("targetString");
|
---|
220 |
|
---|
221 | Event fixture = new Event(type, target);
|
---|
222 |
|
---|
223 | String result = fixture.toString();
|
---|
224 |
|
---|
225 | assertEquals("(typeString;targetString)", result);
|
---|
226 | }
|
---|
227 |
|
---|
228 | public static void main(String[] args) {
|
---|
229 | new org.junit.runner.JUnitCore().run(EventTest.class);
|
---|
230 | }
|
---|
231 | }
|
---|