source: trunk/EventBenchCoreTest/src/de/ugoe/cs/eventbench/data/EventTest.java @ 338

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