1 | package de.ugoe.cs.quest.data;
|
---|
2 |
|
---|
3 | import nl.jqno.equalsverifier.EqualsVerifier;
|
---|
4 | import nl.jqno.equalsverifier.Warning;
|
---|
5 |
|
---|
6 | import org.junit.*;
|
---|
7 |
|
---|
8 | import de.ugoe.cs.quest.data.Event;
|
---|
9 | import de.ugoe.cs.quest.data.ReplayableEvent;
|
---|
10 |
|
---|
11 | import static org.junit.Assert.*;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * The class <code>EventTest</code> contains tests for the class
|
---|
15 | * <code>{@link Event}</code>.
|
---|
16 | *
|
---|
17 | * @author Steffen Herbold
|
---|
18 | * @version 1.0
|
---|
19 | */
|
---|
20 | public class EventTest {
|
---|
21 |
|
---|
22 | @Test
|
---|
23 | public void testEvent_1() throws Exception {
|
---|
24 | String type = "typeString";
|
---|
25 |
|
---|
26 | Event<String> result = new Event<String>(type);
|
---|
27 |
|
---|
28 | assertNotNull(result);
|
---|
29 | assertEquals(type, result.type);
|
---|
30 | assertNull(result.target);
|
---|
31 | assertNull(result.targetShort);
|
---|
32 | assertEquals("", result.idInfo);
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Test(expected = java.security.InvalidParameterException.class)
|
---|
36 | public void testEvent_2() throws Exception {
|
---|
37 | new Event<String>(null);
|
---|
38 | }
|
---|
39 |
|
---|
40 | @Test
|
---|
41 | public void testEquals_1() throws Exception {
|
---|
42 | String type1 = "typeString";
|
---|
43 | String type2 = "typeString";
|
---|
44 | Event<String> fixture = new Event<String>(type1);
|
---|
45 | Event<String> other = new Event<String>(type2);
|
---|
46 |
|
---|
47 | boolean result = fixture.equals(other);
|
---|
48 |
|
---|
49 | assertTrue(result);
|
---|
50 | }
|
---|
51 |
|
---|
52 | @Test
|
---|
53 | public void testEquals_2() throws Exception {
|
---|
54 | String type1 = "typeString1";
|
---|
55 | String type2 = "typeString2";
|
---|
56 | Event<String> fixture = new Event<String>(type1);
|
---|
57 | Event<String> other = new Event<String>(type2);
|
---|
58 |
|
---|
59 | boolean result = fixture.equals(other);
|
---|
60 |
|
---|
61 | assertFalse(result);
|
---|
62 | }
|
---|
63 |
|
---|
64 | @Test
|
---|
65 | public void testEquals_3() throws Exception {
|
---|
66 | String type1 = "typeString";
|
---|
67 | String type2 = "typeString";
|
---|
68 | String target1 = "target";
|
---|
69 | String target2 = "target";
|
---|
70 | Event<String> fixture = new Event<String>(type1);
|
---|
71 | fixture.target = target1;
|
---|
72 | Event<String> other = new Event<String>(type2);
|
---|
73 | other.target = target2;
|
---|
74 |
|
---|
75 | boolean result = fixture.equals(other);
|
---|
76 |
|
---|
77 | assertTrue(result);
|
---|
78 | }
|
---|
79 |
|
---|
80 | @Test
|
---|
81 | public void testEquals_4() throws Exception {
|
---|
82 | String type1 = "typeString1";
|
---|
83 | String type2 = "typeString2";
|
---|
84 | String target1 = "target";
|
---|
85 | String target2 = "target";
|
---|
86 | Event<String> fixture = new Event<String>(type1);
|
---|
87 | fixture.target = target1;
|
---|
88 | Event<String> other = new Event<String>(type2);
|
---|
89 | other.target = target2;
|
---|
90 |
|
---|
91 | boolean result = fixture.equals(other);
|
---|
92 |
|
---|
93 | assertFalse(result);
|
---|
94 | }
|
---|
95 |
|
---|
96 | @Test
|
---|
97 | public void testEquals_5() throws Exception {
|
---|
98 | String type1 = "typeString";
|
---|
99 | String type2 = "typeString";
|
---|
100 | String target1 = "target1";
|
---|
101 | String target2 = "target2";
|
---|
102 | Event<String> fixture = new Event<String>(type1);
|
---|
103 | fixture.target = target1;
|
---|
104 | Event<String> other = new Event<String>(type2);
|
---|
105 | other.target = target2;
|
---|
106 |
|
---|
107 | boolean result = fixture.equals(other);
|
---|
108 |
|
---|
109 | assertFalse(result);
|
---|
110 | }
|
---|
111 |
|
---|
112 | @Test
|
---|
113 | public void testEquals_6() throws Exception {
|
---|
114 | String type = "typeString";
|
---|
115 | Event<String> fixture = new Event<String>(type);
|
---|
116 |
|
---|
117 | boolean result = fixture.equals(fixture);
|
---|
118 |
|
---|
119 | assertTrue(result);
|
---|
120 | }
|
---|
121 |
|
---|
122 | @Test
|
---|
123 | public void testEqualsContract() throws Exception {
|
---|
124 | EqualsVerifier.forClass(Event.class)
|
---|
125 | .suppress(Warning.NONFINAL_FIELDS).withRedefinedSubclass(ReplayableEvent.class)
|
---|
126 | .verify();
|
---|
127 | }
|
---|
128 |
|
---|
129 | @Test
|
---|
130 | public void testGetIdInfo_fixture_1() throws Exception {
|
---|
131 | String type = "typeString";
|
---|
132 | String idInfo = "idInfoString";
|
---|
133 | Event<String> fixture = new Event<String>(type);
|
---|
134 | fixture.idInfo = idInfo;
|
---|
135 |
|
---|
136 | String result = fixture.getIdInfo();
|
---|
137 |
|
---|
138 | assertEquals(idInfo, result);
|
---|
139 | }
|
---|
140 |
|
---|
141 | @Test
|
---|
142 | public void testGetShortId_1() throws Exception {
|
---|
143 | String type = "typeString";
|
---|
144 | String targetShort = "targetShortString";
|
---|
145 | Event<String> fixture = new Event<String>(type);
|
---|
146 | fixture.targetShort = targetShort;
|
---|
147 |
|
---|
148 | String result = fixture.getShortId();
|
---|
149 |
|
---|
150 | assertEquals("targetShortString.typeString", result);
|
---|
151 | }
|
---|
152 |
|
---|
153 | @Test
|
---|
154 | public void testGetShortId_2() throws Exception {
|
---|
155 | String type = "typeString";
|
---|
156 | String targetShort = "targetShortString";
|
---|
157 | String idInfo = "idInfoString";
|
---|
158 | Event<String> fixture = new Event<String>(type);
|
---|
159 | fixture.targetShort = targetShort;
|
---|
160 | fixture.idInfo = idInfo;
|
---|
161 |
|
---|
162 | String result = fixture.getShortId();
|
---|
163 |
|
---|
164 | assertEquals("targetShortString.typeString.idInfoString", result);
|
---|
165 | }
|
---|
166 |
|
---|
167 | @Test
|
---|
168 | public void testGetShortId_3() throws Exception {
|
---|
169 | String type = "typeString";
|
---|
170 | String target = "targetString";
|
---|
171 | Event<String> fixture = new Event<String>(type);
|
---|
172 | fixture.target = target;
|
---|
173 |
|
---|
174 | String result = fixture.getShortId();
|
---|
175 |
|
---|
176 | assertEquals("targetString.typeString", result);
|
---|
177 | }
|
---|
178 |
|
---|
179 | @Test
|
---|
180 | public void testGetStandardId_1() throws Exception {
|
---|
181 | String type = "typeString";
|
---|
182 | String target = "targetString";
|
---|
183 | Event<String> fixture = new Event<String>(type);
|
---|
184 | fixture.target = target;
|
---|
185 |
|
---|
186 | String result = fixture.getStandardId();
|
---|
187 |
|
---|
188 | assertEquals("targetString.typeString", result);
|
---|
189 | }
|
---|
190 |
|
---|
191 | @Test
|
---|
192 | public void testGetStandardId_2() throws Exception {
|
---|
193 | String type = "typeString";
|
---|
194 | String target = "targetString";
|
---|
195 | String idInfo = "idInfoString";
|
---|
196 | Event<String> fixture = new Event<String>(type);
|
---|
197 | fixture.target = target;
|
---|
198 | fixture.idInfo = idInfo;
|
---|
199 |
|
---|
200 | String result = fixture.getStandardId();
|
---|
201 |
|
---|
202 | assertEquals("targetString.typeString.idInfoString", result);
|
---|
203 | }
|
---|
204 |
|
---|
205 | @Test
|
---|
206 | public void testGetStandardId_3() throws Exception {
|
---|
207 | String type = "typeString";
|
---|
208 | Event<String> fixture = new Event<String>(type);
|
---|
209 |
|
---|
210 | String result = fixture.getStandardId();
|
---|
211 |
|
---|
212 | assertEquals("typeString", result);
|
---|
213 | }
|
---|
214 |
|
---|
215 | @Test
|
---|
216 | public void testGetStandardId_4() throws Exception {
|
---|
217 | String type = "typeString";
|
---|
218 | String idInfo = "idInfoString";
|
---|
219 | Event<String> fixture = new Event<String>(type);
|
---|
220 | fixture.idInfo = idInfo;
|
---|
221 |
|
---|
222 | String result = fixture.getStandardId();
|
---|
223 |
|
---|
224 | assertEquals("typeString.idInfoString", result);
|
---|
225 | }
|
---|
226 |
|
---|
227 | @Test
|
---|
228 | public void testGetTarget_1() throws Exception {
|
---|
229 | String type = "typeString";
|
---|
230 | String target = "targetString";
|
---|
231 | Event<String> fixture = new Event<String>(type);
|
---|
232 | fixture.target = target;
|
---|
233 |
|
---|
234 | String result = fixture.getTarget();
|
---|
235 |
|
---|
236 | assertEquals(target, result);
|
---|
237 | }
|
---|
238 |
|
---|
239 | @Test
|
---|
240 | public void testGetTarget_2() throws Exception {
|
---|
241 | String type = "typeString";
|
---|
242 | Event<String> fixture = new Event<String>(type);
|
---|
243 |
|
---|
244 | String result = fixture.getTarget();
|
---|
245 |
|
---|
246 | assertNull(result);
|
---|
247 | }
|
---|
248 |
|
---|
249 | @Test
|
---|
250 | public void testGetTargetShort_1() throws Exception {
|
---|
251 | String type = "typeString";
|
---|
252 | String targetShort = "targetShort";
|
---|
253 | Event<String> fixture = new Event<String>(type);
|
---|
254 | fixture.targetShort = targetShort;
|
---|
255 |
|
---|
256 | String result = fixture.getTargetShort();
|
---|
257 |
|
---|
258 | assertEquals(targetShort, result);
|
---|
259 | }
|
---|
260 |
|
---|
261 | @Test
|
---|
262 | public void testGetTargetShort_2() throws Exception {
|
---|
263 | String type = "typeString";
|
---|
264 | Event<String> fixture = new Event<String>(type);
|
---|
265 |
|
---|
266 | String result = fixture.getTargetShort();
|
---|
267 |
|
---|
268 | assertNull(result);
|
---|
269 | }
|
---|
270 |
|
---|
271 | @Test
|
---|
272 | public void testGetType_1() throws Exception {
|
---|
273 | String type = "typeString";
|
---|
274 | Event<String> fixture = new Event<String>(type);
|
---|
275 |
|
---|
276 | String result = fixture.getType();
|
---|
277 |
|
---|
278 | assertEquals(type, result);
|
---|
279 | }
|
---|
280 |
|
---|
281 | @Test
|
---|
282 | public void testSetIdInfo_fixture_1() throws Exception {
|
---|
283 | String type = "typeString";
|
---|
284 | String idInfo = "idInfoString";
|
---|
285 | Event<String> fixture = new Event<String>(type);
|
---|
286 |
|
---|
287 | fixture.setIdInfo(idInfo);
|
---|
288 |
|
---|
289 | assertEquals(idInfo, fixture.idInfo);
|
---|
290 | }
|
---|
291 |
|
---|
292 | @Test
|
---|
293 | public void testSetIdInfo_2() throws Exception {
|
---|
294 | String type = "typeString";
|
---|
295 | String idInfo = null;
|
---|
296 | Event<String> fixture = new Event<String>(type);
|
---|
297 |
|
---|
298 | fixture.setIdInfo(idInfo);
|
---|
299 |
|
---|
300 | assertEquals(idInfo, fixture.idInfo);
|
---|
301 | }
|
---|
302 |
|
---|
303 | @Test
|
---|
304 | public void testSetTarget_1() throws Exception {
|
---|
305 | String type = "typeString";
|
---|
306 | String target = "targetString";
|
---|
307 | Event<String> fixture = new Event<String>(type);
|
---|
308 |
|
---|
309 | boolean result = fixture.setTarget(target);
|
---|
310 |
|
---|
311 | assertTrue(result);
|
---|
312 | assertEquals(target, fixture.target);
|
---|
313 | }
|
---|
314 |
|
---|
315 | @Test
|
---|
316 | public void testSetTarget_2() throws Exception {
|
---|
317 | String type = "typeString";
|
---|
318 | String target1 = "targetString1";
|
---|
319 | String target2 = "targetString2";
|
---|
320 | Event<String> fixture = new Event<String>(type);
|
---|
321 | fixture.target = target1;
|
---|
322 |
|
---|
323 | boolean result = fixture.setTarget(target2);
|
---|
324 |
|
---|
325 | assertFalse(result);
|
---|
326 | assertEquals(target1, fixture.target);
|
---|
327 | }
|
---|
328 |
|
---|
329 | @Test
|
---|
330 | public void testSetTargetShort_1() throws Exception {
|
---|
331 | String type = "typeString";
|
---|
332 | String targetShort = "targetShortString";
|
---|
333 | Event<String> fixture = new Event<String>(type);
|
---|
334 |
|
---|
335 | boolean result = fixture.setTargetShort(targetShort);
|
---|
336 |
|
---|
337 | assertTrue(result);
|
---|
338 | assertEquals(targetShort, fixture.targetShort);
|
---|
339 | }
|
---|
340 |
|
---|
341 | @Test
|
---|
342 | public void testSetTargetShort_2() throws Exception {
|
---|
343 | String type = "typeString";
|
---|
344 | String targetShort1 = "targetShortString1";
|
---|
345 | String targetShort2 = "targetShortString2";
|
---|
346 | Event<String> fixture = new Event<String>(type);
|
---|
347 | fixture.targetShort = targetShort1;
|
---|
348 |
|
---|
349 | boolean result = fixture.setTargetShort(targetShort2);
|
---|
350 |
|
---|
351 | assertFalse(result);
|
---|
352 | assertEquals(targetShort1, fixture.targetShort);
|
---|
353 | }
|
---|
354 |
|
---|
355 | @Test
|
---|
356 | public void testToString_1() throws Exception {
|
---|
357 | String type = "typeString";
|
---|
358 | String target = "targetString";
|
---|
359 | Event<String> fixture = new Event<String>(type);
|
---|
360 | fixture.target = target;
|
---|
361 |
|
---|
362 | String result = fixture.toString();
|
---|
363 |
|
---|
364 | assertEquals("targetString.typeString", result);
|
---|
365 | }
|
---|
366 |
|
---|
367 | @Test
|
---|
368 | public void testToString_2() throws Exception {
|
---|
369 | String type = "typeString";
|
---|
370 | String target = "targetString";
|
---|
371 | String idInfo = "idInfoString";
|
---|
372 | Event<String> fixture = new Event<String>(type);
|
---|
373 | fixture.target = target;
|
---|
374 | fixture.idInfo = idInfo;
|
---|
375 |
|
---|
376 | String result = fixture.toString();
|
---|
377 |
|
---|
378 | assertEquals("targetString.typeString.idInfoString", result);
|
---|
379 | }
|
---|
380 |
|
---|
381 | @Test
|
---|
382 | public void testToString_3() throws Exception {
|
---|
383 | String type = "typeString";
|
---|
384 | Event<String> fixture = new Event<String>(type);
|
---|
385 |
|
---|
386 | String result = fixture.toString();
|
---|
387 |
|
---|
388 | assertEquals("typeString", result);
|
---|
389 | }
|
---|
390 |
|
---|
391 | @Test
|
---|
392 | public void testToString_4() throws Exception {
|
---|
393 | String type = "typeString";
|
---|
394 | String idInfo = "idInfoString";
|
---|
395 | Event<String> fixture = new Event<String>(type);
|
---|
396 | fixture.idInfo = idInfo;
|
---|
397 |
|
---|
398 | String result = fixture.toString();
|
---|
399 |
|
---|
400 | assertEquals("typeString.idInfoString", result);
|
---|
401 | }
|
---|
402 |
|
---|
403 | public static void main(String[] args) {
|
---|
404 | new org.junit.runner.JUnitCore().run(EventTest.class);
|
---|
405 | }
|
---|
406 | } |
---|