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

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