source: trunk/EventBenchCoreTest/src/de/ugoe/cs/eventbench/data/ReplayableEventTest.java @ 341

Last change on this file since 341 was 341, checked in by sherbold, 12 years ago
  • Property svn:mime-type set to text/plain
File size: 17.2 KB
Line 
1package de.ugoe.cs.eventbench.data;
2
3import java.util.LinkedList;
4import java.util.List;
5
6import junitx.framework.ListAssert;
7import de.ugoe.cs.eventbench.IReplayDecorator;
8import de.ugoe.cs.eventbench.data.mock.MockReplayable;
9import nl.jqno.equalsverifier.EqualsVerifier;
10import nl.jqno.equalsverifier.Warning;
11
12import org.junit.*;
13import static org.junit.Assert.*;
14
15/**
16 * The class <code>ReplayableEventTest</code> contains tests for the class
17 * <code>{@link ReplayableEvent}</code>.
18 *
19 * @generatedBy CodePro at 12/20/11 10:17 AM
20 * @author Steffen Herbold
21 * @version 1.0
22 */
23public class ReplayableEventTest {
24
25        private static class StubReplayDecorator implements IReplayDecorator {
26
27                private static final long serialVersionUID = 1L;
28
29                @Override
30                public String getHeader() {
31                        return null;
32                }
33
34                @Override
35                public String getFooter() {
36                        return null;
37                }
38
39                @Override
40                public String getSessionHeader(int sessionId) {
41                        return null;
42                }
43
44                @Override
45                public String getSessionFooter(int sessionId) {
46                        return null;
47                }
48               
49        }
50
51        @Test
52        public void testReplayableEvent_1() throws Exception {
53                String type = "typeString";
54
55                ReplayableEvent<MockReplayable> result = new ReplayableEvent<MockReplayable>(
56                                type);
57
58                assertNotNull(result);
59                assertNotNull(result.replayEvents);
60                assertTrue(result.replayEvents.isEmpty());
61                assertEquals(true, result.replayValid);
62                assertEquals(null, result.decorator);
63        }
64
65        @Test(expected = java.security.InvalidParameterException.class)
66        public void testReplayableEvent_2() throws Exception {
67                new ReplayableEvent<MockReplayable>(null);
68        }
69
70        @Test
71        public void testAddReplayEvent_1() throws Exception {
72                String type = "typeString";
73                String replayableReplay = "replayString";
74                String replaybleTarget = "replayTargetString";
75                MockReplayable replayable = new MockReplayable(replayableReplay,
76                                replaybleTarget);
77                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
78                                type);
79                fixture.addReplayEvent(replayable);
80               
81               
82                assertEquals(1, fixture.replayEvents.size());
83                assertEquals(replayable, fixture.replayEvents.get(0));
84        }
85       
86        @Test
87        public void testAddReplayEvent_2() throws Exception {
88                String type = "typeString";
89                String replayableReplay1 = "replayString1";
90                String replayableReplay2 = "replayString2";
91                String replaybleTarget1 = "replayTargetString1";
92                String replaybleTarget2 = "replayTargetString2";
93                MockReplayable replayable1 = new MockReplayable(replayableReplay1,
94                                replaybleTarget1);
95                MockReplayable replayable2 = new MockReplayable(replayableReplay2, replaybleTarget2);
96                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
97                                type);
98                fixture.addReplayEvent(replayable1);
99                fixture.addReplayEvent(replayable2);
100               
101               
102                assertEquals(2, fixture.replayEvents.size());
103                assertEquals(replayable1, fixture.replayEvents.get(0));
104                assertEquals(replayable2, fixture.replayEvents.get(1));
105        }
106
107        @Test(expected = java.security.InvalidParameterException.class )
108        public void testAddReplayEvent_fixture_3() throws Exception {
109                String type = "typeString";
110                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
111                                type);
112                fixture.addReplayEvent(null);
113        }
114
115        @Test
116        public void testAddReplaySequence_1() throws Exception {
117                String type = "typeString";
118                String replayableReplay1 = "replayString1";
119                String replayableReplay2 = "replayString2";
120                String replaybleTarget1 = "replayTargetString1";
121                String replaybleTarget2 = "replayTargetString2";
122                MockReplayable replayable1 = new MockReplayable(replayableReplay1,
123                                replaybleTarget1);
124                MockReplayable replayable2 = new MockReplayable(replayableReplay2, replaybleTarget2);
125                List<MockReplayable> replaySequence = new LinkedList<MockReplayable>();
126                replaySequence.add(replayable1);
127                replaySequence.add(replayable2);
128                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
129                                type);
130               
131                fixture.addReplaySequence(replaySequence);             
132               
133                assertEquals(2, fixture.replayEvents.size());
134                assertEquals(replayable1, fixture.replayEvents.get(0));
135                assertEquals(replayable2, fixture.replayEvents.get(1));
136        }
137
138        @Test(expected = java.security.InvalidParameterException.class )
139        public void testAddReplaySequence_2() throws Exception {
140                String type = "typeString";
141                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
142                                type);
143               
144                fixture.addReplaySequence(null);       
145        }
146
147        @Test
148        public void testEquals_1() throws Exception {
149                String type = "typeString";
150                boolean replayValid = true;
151                String replayableReplay1 = "replayString1";
152                String replayableReplay2 = "replayString2";
153                String replayableTarget1 = "replayTargetString1";
154                String replayableTarget2 = "replayTargetString2";
155                MockReplayable replayable1 = new MockReplayable(replayableReplay1,
156                                replayableTarget1);
157                MockReplayable replayable2 = new MockReplayable(replayableReplay2, replayableTarget2);
158                List<MockReplayable> replaySequence = new LinkedList<MockReplayable>();
159                replaySequence.add(replayable1);
160                replaySequence.add(replayable2);
161                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
162                                type);
163                fixture.replayEvents = replaySequence;
164                fixture.replayValid = replayValid;
165               
166                String typeOther = "typeString";
167                boolean replayValidOther = true;
168                String replayableReplayOther1 = "replayString1";
169                String replayableReplayOther2 = "replayString2";
170                String replaybleTargetOther1 = "replayTargetString1";
171                String replaybleTargetOther2 = "replayTargetString2";
172                MockReplayable replayableOther1 = new MockReplayable(replayableReplayOther1,
173                                replaybleTargetOther1);
174                MockReplayable replayableOther2 = new MockReplayable(replayableReplayOther2, replaybleTargetOther2);
175                List<MockReplayable> replaySequenceOther = new LinkedList<MockReplayable>();
176                replaySequenceOther.add(replayableOther1);
177                replaySequenceOther.add(replayableOther2);
178                ReplayableEvent<MockReplayable> other = new ReplayableEvent<MockReplayable>(
179                                typeOther);
180                other.replayEvents = replaySequenceOther;
181                other.replayValid = replayValidOther;
182
183                boolean result = fixture.equals(other);
184
185                assertEquals(true, result);
186        }
187       
188        @Test
189        public void testEquals_2() throws Exception {
190                String type = "typeString";
191                boolean replayValid = true;
192                String replayableReplay1 = "replayString1";
193                String replayableReplay2 = "replayString2";
194                String replayableTarget1 = "replayTargetString1";
195                String replayableTarget2 = "replayTargetString2";
196                MockReplayable replayable1 = new MockReplayable(replayableReplay1,
197                                replayableTarget1);
198                MockReplayable replayable2 = new MockReplayable(replayableReplay2, replayableTarget2);
199                List<MockReplayable> replaySequence = new LinkedList<MockReplayable>();
200                replaySequence.add(replayable1);
201                replaySequence.add(replayable2);
202                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
203                                type);
204                fixture.replayEvents = replaySequence;
205                fixture.replayValid = replayValid;
206               
207                String typeOther = "typeString2";
208                boolean replayValidOther = true;
209                String replayableReplayOther1 = "replayString1";
210                String replayableReplayOther2 = "replayString2";
211                String replaybleTargetOther1 = "replayTargetString1";
212                String replaybleTargetOther2 = "replayTargetString2";
213                MockReplayable replayableOther1 = new MockReplayable(replayableReplayOther1,
214                                replaybleTargetOther1);
215                MockReplayable replayableOther2 = new MockReplayable(replayableReplayOther2, replaybleTargetOther2);
216                List<MockReplayable> replaySequenceOther = new LinkedList<MockReplayable>();
217                replaySequenceOther.add(replayableOther1);
218                replaySequenceOther.add(replayableOther2);
219                ReplayableEvent<MockReplayable> other = new ReplayableEvent<MockReplayable>(
220                                typeOther);
221                other.replayEvents = replaySequenceOther;
222                other.replayValid = replayValidOther;
223
224                boolean result = fixture.equals(other);
225
226                assertEquals(false, result);
227        }
228       
229        @Test
230        public void testEquals_3() throws Exception {
231                String type = "typeString";
232                boolean replayValid = true;
233                String replayableReplay1 = "replayString1";
234                String replayableReplay2 = "replayString2";
235                String replayableTarget1 = "replayTargetString1";
236                String replayableTarget2 = "replayTargetString2";
237                MockReplayable replayable1 = new MockReplayable(replayableReplay1,
238                                replayableTarget1);
239                MockReplayable replayable2 = new MockReplayable(replayableReplay2, replayableTarget2);
240                List<MockReplayable> replaySequence = new LinkedList<MockReplayable>();
241                replaySequence.add(replayable1);
242                replaySequence.add(replayable2);
243                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
244                                type);
245                fixture.replayEvents = replaySequence;
246                fixture.replayValid = replayValid;
247               
248                String typeOther = "typeString";
249                boolean replayValidOther = true;
250                String replayableReplayOther1 = "replayString3";
251                String replayableReplayOther2 = "replayString2";
252                String replaybleTargetOther1 = "replayTargetString1";
253                String replaybleTargetOther2 = "replayTargetString2";
254                MockReplayable replayableOther1 = new MockReplayable(replayableReplayOther1,
255                                replaybleTargetOther1);
256                MockReplayable replayableOther2 = new MockReplayable(replayableReplayOther2, replaybleTargetOther2);
257                List<MockReplayable> replaySequenceOther = new LinkedList<MockReplayable>();
258                replaySequenceOther.add(replayableOther1);
259                replaySequenceOther.add(replayableOther2);
260                ReplayableEvent<MockReplayable> other = new ReplayableEvent<MockReplayable>(
261                                typeOther);
262                other.replayEvents = replaySequenceOther;
263                other.replayValid = replayValidOther;
264
265                boolean result = fixture.equals(other);
266
267                assertEquals(false, result);
268        }
269       
270        @Test
271        public void testEquals_4() throws Exception {
272                String type = "typeString";
273                boolean replayValid = true;
274                String replayableReplay1 = "replayString1";
275                String replayableReplay2 = "replayString2";
276                String replayableTarget1 = "replayTargetString1";
277                String replayableTarget2 = "replayTargetString2";
278                MockReplayable replayable1 = new MockReplayable(replayableReplay1,
279                                replayableTarget1);
280                MockReplayable replayable2 = new MockReplayable(replayableReplay2, replayableTarget2);
281                List<MockReplayable> replaySequence = new LinkedList<MockReplayable>();
282                replaySequence.add(replayable1);
283                replaySequence.add(replayable2);
284                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
285                                type);
286                fixture.replayEvents = replaySequence;
287                fixture.replayValid = replayValid;
288               
289                String typeOther = "typeString";
290                boolean replayValidOther = true;
291                String replayableReplayOther1 = "replayString1";
292                String replayableReplayOther2 = "replayString3";
293                String replaybleTargetOther1 = "replayTargetString1";
294                String replaybleTargetOther2 = "replayTargetString2";
295                MockReplayable replayableOther1 = new MockReplayable(replayableReplayOther1,
296                                replaybleTargetOther1);
297                MockReplayable replayableOther2 = new MockReplayable(replayableReplayOther2, replaybleTargetOther2);
298                List<MockReplayable> replaySequenceOther = new LinkedList<MockReplayable>();
299                replaySequenceOther.add(replayableOther1);
300                replaySequenceOther.add(replayableOther2);
301                ReplayableEvent<MockReplayable> other = new ReplayableEvent<MockReplayable>(
302                                typeOther);
303                other.replayEvents = replaySequenceOther;
304                other.replayValid = replayValidOther;
305
306                boolean result = fixture.equals(other);
307
308                assertEquals(false, result);
309        }
310       
311        @Test
312        public void testEquals_5() throws Exception {
313                String type = "typeString";
314                boolean replayValid = true;
315                String replayableReplay1 = "replayString1";
316                String replayableReplay2 = "replayString2";
317                String replayableTarget1 = "replayTargetString1";
318                String replayableTarget2 = "replayTargetString2";
319                MockReplayable replayable1 = new MockReplayable(replayableReplay1,
320                                replayableTarget1);
321                MockReplayable replayable2 = new MockReplayable(replayableReplay2, replayableTarget2);
322                List<MockReplayable> replaySequence = new LinkedList<MockReplayable>();
323                replaySequence.add(replayable1);
324                replaySequence.add(replayable2);
325                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
326                                type);
327                fixture.replayEvents = replaySequence;
328                fixture.replayValid = replayValid;
329               
330                String typeOther = "typeString";
331                boolean replayValidOther = false;
332                String replayableReplayOther1 = "replayString1";
333                String replayableReplayOther2 = "replayString2";
334                String replaybleTargetOther1 = "replayTargetString1";
335                String replaybleTargetOther2 = "replayTargetString2";
336                MockReplayable replayableOther1 = new MockReplayable(replayableReplayOther1,
337                                replaybleTargetOther1);
338                MockReplayable replayableOther2 = new MockReplayable(replayableReplayOther2, replaybleTargetOther2);
339                List<MockReplayable> replaySequenceOther = new LinkedList<MockReplayable>();
340                replaySequenceOther.add(replayableOther1);
341                replaySequenceOther.add(replayableOther2);
342                ReplayableEvent<MockReplayable> other = new ReplayableEvent<MockReplayable>(
343                                typeOther);
344                other.replayEvents = replaySequenceOther;
345                other.replayValid = replayValidOther;
346
347                boolean result = fixture.equals(other);
348
349                assertEquals(false, result);
350        }
351       
352        @Test
353        public void testEquals_6() throws Exception {
354                String type = "typeString";
355                boolean replayValid = true;
356                String replayableReplay1 = "replayString1";
357                String replayableReplay2 = "replayString2";
358                String replayableTarget1 = "replayTargetString1";
359                String replayableTarget2 = "replayTargetString2";
360                MockReplayable replayable1 = new MockReplayable(replayableReplay1,
361                                replayableTarget1);
362                MockReplayable replayable2 = new MockReplayable(replayableReplay2, replayableTarget2);
363                List<MockReplayable> replaySequence = new LinkedList<MockReplayable>();
364                replaySequence.add(replayable1);
365                replaySequence.add(replayable2);
366                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
367                                type);
368                fixture.replayEvents = replaySequence;
369                fixture.replayValid = replayValid;
370
371                boolean result = fixture.equals(fixture);
372
373                assertEquals(true, result);
374        }
375       
376        @Test
377        public void testEqualsContract() throws Exception {
378                EqualsVerifier.forClass(ReplayableEvent.class)
379                .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS).withRedefinedSuperclass()
380                .verify();
381        }
382
383        @Test
384        public void testGetReplayDecorator_1() throws Exception {
385                String type = "typeString";
386                StubReplayDecorator decorator = new StubReplayDecorator();
387                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
388                                type);
389                fixture.decorator = decorator;
390
391                IReplayDecorator result = fixture.getReplayDecorator();
392
393                assertEquals(decorator, result);
394        }
395
396        @Test
397        public void testGetReplayMessages_1() throws Exception {
398                String type = "typeString";
399                String replayableReplay1 = "replayString1";
400                String replayableReplay2 = "replayString2";
401                String replayableTarget1 = "replayTargetString1";
402                String replayableTarget2 = "replayTargetString2";
403                MockReplayable replayable1 = new MockReplayable(replayableReplay1,
404                                replayableTarget1);
405                MockReplayable replayable2 = new MockReplayable(replayableReplay2, replayableTarget2);
406                List<MockReplayable> replaySequence = new LinkedList<MockReplayable>();
407                replaySequence.add(replayable1);
408                replaySequence.add(replayable2);
409                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
410                                type);
411                fixture.replayEvents = replaySequence;
412
413                List<MockReplayable> result = fixture.getReplayMessages();
414
415                ListAssert.assertEquals(replaySequence, result);
416        }
417
418        @Test
419        public void testHasValidReplay_1() throws Exception {
420                String type = "typeString";
421                boolean replayValid = true;
422                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
423                                type);
424                fixture.replayValid = replayValid;
425
426                boolean result = fixture.hasValidReplay();
427
428                assertEquals(replayValid, result);
429        }
430       
431        @Test
432        public void testHasValidReplay_2() throws Exception {
433                String type = "typeString";
434                boolean replayValid = false;
435                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
436                                type);
437                fixture.replayValid = replayValid;
438
439                boolean result = fixture.hasValidReplay();
440
441                assertEquals(replayValid, result);
442        }
443
444        @Test
445        public void testInvalidateReplay_1() throws Exception {
446                String type = "typeString";
447                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
448                                type);
449               
450                fixture.invalidateReplay();
451
452                assertFalse(fixture.replayValid);
453        }
454       
455        @Test
456        public void testInvalidateReplay_2() throws Exception {
457                String type = "typeString";
458                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
459                                type);
460               
461                fixture.invalidateReplay();
462                fixture.invalidateReplay();
463
464                assertFalse(fixture.replayValid);
465        }
466
467        @Test
468        public void testSetDecorator_fixture_1() throws Exception {
469                String type = "typeString";
470                StubReplayDecorator decorator = new StubReplayDecorator();
471                ReplayableEvent<MockReplayable> fixture = new ReplayableEvent<MockReplayable>(
472                                type);
473
474                fixture.setDecorator(decorator);
475
476                assertEquals(decorator, fixture.decorator);
477        }
478
479        public static void main(String[] args) {
480                new org.junit.runner.JUnitCore().run(ReplayableEventTest.class);
481        }
482}
Note: See TracBrowser for help on using the repository browser.