View Javadoc
1   package de.fhdw.wtf.walker.tasks.test;
2   
3   import static org.junit.Assert.assertEquals;
4   import static org.junit.Assert.assertTrue;
5   import static org.junit.Assert.fail;
6   
7   import java.util.Iterator;
8   
9   import org.junit.Test;
10  
11  import de.fhdw.wtf.common.ast.Model;
12  import de.fhdw.wtf.common.ast.type.Type;
13  import de.fhdw.wtf.common.exception.editor.MultipleCheckExceptions;
14  import de.fhdw.wtf.tooling.SyntaxCheck;
15  
16  /**
17   * This test case tests the function of AnalyzeInheritanceTreesTask and check the generated map of this task and the
18   * elements.
19   */
20  public class TestAnalyzeInheritanceTreesTask {
21  	
22  	/**
23  	 * Tests an empty group. Model: group1:group = [];
24  	 * 
25  	 * @throws Exception
26  	 *             x
27  	 */
28  	@Test
29  	public void testEmptyGroup() throws Exception {
30  		final String input = "group1:group = [];";
31  		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
32  		
33  		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
34  		while (iterator.hasNext()) {
35  			fail();
36  		}
37  		assertTrue(true);
38  	}
39  	
40  	/**
41  	 * Tests an empty class. Model: group1:group = [A:class = {};]; It is necessary to define one or more constructors
42  	 * and in the model no constructors exist.
43  	 * 
44  	 * @throws Exception
45  	 *             x
46  	 */
47  	@Test
48  	public void testEmptyClass() throws Exception {
49  		final String input = "group1:group = [A:class = {};];";
50  		
51  		try {
52  			SyntaxCheck.getInstance().getModelFromString(input);
53  			fail();
54  		} catch (final MultipleCheckExceptions e) {
55  			assertTrue(true);
56  			// Konstruktoren fehlen daher fliegt diese
57  		}
58  	}
59  	
60  	/**
61  	 * Tests two empty classes. Model: group1:group = [A:class = {}; B:class = {};]; It is necessary to define one or
62  	 * more constructors and in the model no constructors exist.
63  	 * 
64  	 * @throws Exception
65  	 *             x
66  	 */
67  	@Test
68  	public void testTwoEmptyClass() throws Exception {
69  		final String input = "group1:group = [A:class = {}; B:class = {};];";
70  		
71  		try {
72  			SyntaxCheck.getInstance().getModelFromString(input);
73  			fail();
74  		} catch (final MultipleCheckExceptions e) {
75  			assertTrue(true);
76  			// Konstruktoren fehlen daher fliegt diese
77  		}
78  	}
79  	
80  	/**
81  	 * Tests one class with one constructor. Model: group1:group = [A:class = {();};];
82  	 * 
83  	 * @throws Exception
84  	 *             x
85  	 */
86  	@Test
87  	public void testOneClassOneConstructor() throws Exception {
88  		final String input = "group1:group = [A:class = {();};];";
89  		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
90  		
91  		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
92  		while (iterator.hasNext()) {
93  			final Type current = iterator.next();
94  			
95  			switch (current.getTypeString()) {
96  			case "group1>A":
97  				assertTrue(true);
98  				assertTrue(model.getConstructorCallDependencies().get(current).isEmpty());
99  				break;
100 			default:
101 				fail();
102 				break;
103 			}
104 		}
105 		assertTrue(true);
106 	}
107 	
108 	/**
109 	 * Tests two classes both with one constructor. Model: group1:group = [A:class = {();}; B:class = {();};];
110 	 * 
111 	 * @throws Exception
112 	 *             x
113 	 */
114 	@Test
115 	public void testTwoClassesBothWithOneConstructor() throws Exception {
116 		final String input = "group1:group = [A:class = {();}; B:class = {();};];";
117 		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
118 		
119 		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
120 		while (iterator.hasNext()) {
121 			final Type current = iterator.next();
122 			
123 			switch (current.getTypeString()) {
124 			case "group1>A":
125 				assertTrue(true);
126 				assertTrue(model.getConstructorCallDependencies().get(current).isEmpty());
127 				break;
128 			case "group1>B":
129 				assertTrue(true);
130 				assertTrue(model.getConstructorCallDependencies().get(current).isEmpty());
131 				break;
132 			default:
133 				fail();
134 				break;
135 			}
136 		}
137 		assertTrue(true);
138 	}
139 	
140 	/**
141 	 * Tests the simple inheritance between two classes that the second class inherits the first class. Both classes
142 	 * have no constructor.
143 	 * 
144 	 * Model: group1:group = [A:class = {}; B:class = A + {};];
145 	 * 
146 	 * It is necessary to define one or more constructors and in the model no constructors exist.
147 	 * 
148 	 * @throws Exception
149 	 *             x
150 	 */
151 	@Test
152 	public void testSimpleInheritance() throws Exception {
153 		final String input = "group1:group = [A:class = {}; B:class = A + {};];";
154 		
155 		try {
156 			SyntaxCheck.getInstance().getModelFromString(input);
157 			fail();
158 		} catch (final MultipleCheckExceptions e) {
159 			assertTrue(true);
160 			// Konstruktoren fehlen daher fliegt diese
161 		}
162 	}
163 	
164 	/**
165 	 * Tests the simple inheritance between two classes that the second class inherits the first class. Both classes
166 	 * have one default constructor.
167 	 * 
168 	 * Model: group1:group = [A:class = {();}; B:class = A + {() = A();};];
169 	 * 
170 	 * @throws Exception
171 	 *             x
172 	 */
173 	@Test
174 	public void testSimpleInheritanceWithConstructors() throws Exception {
175 		final String input = "group1:group = [A:class = {();}; B:class = A + {() = A();};];";
176 		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
177 		
178 		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
179 		while (iterator.hasNext()) {
180 			final Type current = iterator.next();
181 			
182 			switch (current.getTypeString()) {
183 			case "group1>A":
184 				assertTrue(true);
185 				assertTrue(model.getConstructorCallDependencies().get(current).isEmpty());
186 				break;
187 			case "group1>B":
188 				assertTrue(true);
189 				final Iterator<Type> bIterator = model.getConstructorCallDependencies().get(current).iterator();
190 				assertEquals("group1>A", bIterator.next().toString());
191 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
192 				break;
193 			default:
194 				fail();
195 				break;
196 			}
197 		}
198 		assertTrue(true);
199 	}
200 	
201 	/**
202 	 * Tests the model where a class implements two other classes.
203 	 * 
204 	 * Model: group1:group = [A :class={();}; B:class = {();}; C:class= A + B + {()=A() + B();};];
205 	 * 
206 	 * @throws Exception
207 	 *             x
208 	 * 
209 	 */
210 	@Test
211 	public void testInheritanceOfTwoSuperclasses() throws Exception {
212 		final String input = "group1:group = [A :class={();}; B:class = {();}; C:class= A + B + {()=A() + B();};];";
213 		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
214 		
215 		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
216 		while (iterator.hasNext()) {
217 			final Type current = iterator.next();
218 			
219 			switch (current.getTypeString()) {
220 			case "group1>A":
221 				assertTrue(true);
222 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
223 				break;
224 			case "group1>B":
225 				assertTrue(true);
226 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
227 				break;
228 			case "group1>C":
229 				final Iterator<Type> cIterator = model.getConstructorCallDependencies().get(current).iterator();
230 				assertEquals("group1>A", cIterator.next().toString());
231 				assertEquals("group1>B", cIterator.next().toString());
232 				assertEquals(2, model.getConstructorCallDependencies().get(current).size());
233 				break;
234 			default:
235 				fail();
236 				break;
237 			}
238 		}
239 	}
240 	
241 	/**
242 	 * Tests the model where a class implements three other classes.
243 	 * 
244 	 * Model: group1:group = [A :class={();}; B:class = {();}; C:class= {();}; D:class= A + B + C + {()= A() + B() +
245 	 * C();};];
246 	 * 
247 	 * @throws Exception
248 	 *             x
249 	 * 
250 	 */
251 	@Test
252 	public void testInheritanceOfThereSuperclasses() throws Exception {
253 		final String input =
254 				"group1:group = [A :class={();}; B:class = {();}; C:class= {();};"
255 						+ " D:class= A + B + C + {()= A() + B() + C();};];";
256 		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
257 		
258 		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
259 		while (iterator.hasNext()) {
260 			final Type current = iterator.next();
261 			
262 			switch (current.getTypeString()) {
263 			case "group1>A":
264 				assertTrue(true);
265 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
266 				break;
267 			case "group1>B":
268 				assertTrue(true);
269 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
270 				break;
271 			case "group1>C":
272 				assertTrue(true);
273 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
274 				break;
275 			case "group1>D":
276 				final Iterator<Type> dIterator = model.getConstructorCallDependencies().get(current).iterator();
277 				assertEquals("group1>A", dIterator.next().toString());
278 				assertEquals("group1>B", dIterator.next().toString());
279 				assertEquals("group1>C", dIterator.next().toString());
280 				assertEquals(3, model.getConstructorCallDependencies().get(current).size());
281 				break;
282 			default:
283 				fail();
284 				break;
285 			}
286 		}
287 	}
288 	
289 	/**
290 	 * Tests the Diamond.
291 	 * 
292 	 * Model: group1:group = [A :class={();}; B:class= A + {()=A();}; C:class= A + {()=A();}; D:class= B + C
293 	 * +{()=A()+B()+C();};];
294 	 * 
295 	 * @throws Exception
296 	 *             x
297 	 * 
298 	 */
299 	@Test
300 	public void testDiamond() throws Exception {
301 		final String input =
302 				"group1:group = [A :class={();}; B:class= A + {()=A();}; C:class= A + {()=A();};"
303 						+ " D:class= B + C +{()=A()+B()+C();};];";
304 		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
305 		
306 		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
307 		while (iterator.hasNext()) {
308 			final Type current = iterator.next();
309 			
310 			switch (current.getTypeString()) {
311 			case "group1>A":
312 				assertTrue(true);
313 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
314 				break;
315 			case "group1>B":
316 				final Iterator<Type> bIterator = model.getConstructorCallDependencies().get(current).iterator();
317 				assertEquals("group1>A", bIterator.next().toString());
318 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
319 				break;
320 			case "group1>C":
321 				final Iterator<Type> cIterator = model.getConstructorCallDependencies().get(current).iterator();
322 				assertEquals("group1>A", cIterator.next().toString());
323 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
324 				break;
325 			case "group1>D":
326 				final Iterator<Type> aIterator = model.getConstructorCallDependencies().get(current).iterator();
327 				assertEquals("group1>A", aIterator.next().toString());
328 				assertEquals("group1>B", aIterator.next().toString());
329 				assertEquals("group1>C", aIterator.next().toString());
330 				assertEquals(3, model.getConstructorCallDependencies().get(current).size());
331 				break;
332 			default:
333 				fail();
334 				break;
335 			}
336 		}
337 	}
338 	
339 	/**
340 	 * Tests the Diamond changed the order of the superTypes.
341 	 * 
342 	 * Model: group1:group = [A :class={();}; B:class= A + {()=A();}; C:class= A + {()=A();}; D:class= C + B
343 	 * +{()=A()+B()+C();};];
344 	 * 
345 	 * @throws Exception
346 	 *             x
347 	 */
348 	@Test
349 	public void testDiamondWithChangedOrderInInheritance() throws Exception {
350 		final String input =
351 				"group1:group = [A :class={();}; B:class= A + {()=A();}; C:class= A + {()=A();};"
352 						+ " D:class= C + B + {()=A()+B()+C();};];";
353 		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
354 		
355 		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
356 		while (iterator.hasNext()) {
357 			final Type current = iterator.next();
358 			
359 			switch (current.getTypeString()) {
360 			case "group1>A":
361 				assertTrue(true);
362 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
363 				break;
364 			case "group1>B":
365 				final Iterator<Type> bIterator = model.getConstructorCallDependencies().get(current).iterator();
366 				assertEquals("group1>A", bIterator.next().toString());
367 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
368 				break;
369 			case "group1>C":
370 				final Iterator<Type> cIterator = model.getConstructorCallDependencies().get(current).iterator();
371 				assertEquals("group1>A", cIterator.next().toString());
372 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
373 				break;
374 			case "group1>D":
375 				final Iterator<Type> aIterator = model.getConstructorCallDependencies().get(current).iterator();
376 				assertEquals("group1>A", aIterator.next().toString());
377 				assertEquals("group1>C", aIterator.next().toString());
378 				assertEquals("group1>B", aIterator.next().toString());
379 				assertEquals(3, model.getConstructorCallDependencies().get(current).size());
380 				break;
381 			default:
382 				fail();
383 				break;
384 			}
385 		}
386 	}
387 	
388 	/**
389 	 * Tests the Diamond changed the order of the superConstructor-calls.
390 	 * 
391 	 * Model: group1:group = [A :class={();}; B:class= A + {()=A();}; C:class= A + {()=A();}; D:class= B + C
392 	 * +{()=A()+C()+B();};];
393 	 * 
394 	 * @throws Exception
395 	 *             x
396 	 */
397 	@Test
398 	public void testDiamondWithChangedOrderInSuperconstructorCall() throws Exception {
399 		final String input =
400 				"group1:group = [A :class={();}; B:class= A + {()=A();}; C:class= A + {()=A();};"
401 						+ " D:class= C + B + {()=A()+C()+B();};];";
402 		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
403 		
404 		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
405 		while (iterator.hasNext()) {
406 			final Type current = iterator.next();
407 			
408 			switch (current.getTypeString()) {
409 			case "group1>A":
410 				assertTrue(true);
411 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
412 				break;
413 			case "group1>B":
414 				final Iterator<Type> bIterator = model.getConstructorCallDependencies().get(current).iterator();
415 				assertEquals("group1>A", bIterator.next().toString());
416 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
417 				break;
418 			case "group1>C":
419 				final Iterator<Type> cIterator = model.getConstructorCallDependencies().get(current).iterator();
420 				assertEquals("group1>A", cIterator.next().toString());
421 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
422 				break;
423 			case "group1>D":
424 				final Iterator<Type> aIterator = model.getConstructorCallDependencies().get(current).iterator();
425 				assertEquals("group1>A", aIterator.next().toString());
426 				assertEquals("group1>C", aIterator.next().toString());
427 				assertEquals("group1>B", aIterator.next().toString());
428 				assertEquals(3, model.getConstructorCallDependencies().get(current).size());
429 				break;
430 			default:
431 				fail();
432 				break;
433 			}
434 		}
435 	}
436 	
437 	/**
438 	 * Tests the Diamond under a diamond.
439 	 * 
440 	 * Model: group1:group = [A:class={();}; B:class = A + {()=A();}; C:class = A + {()=A();}; D:class = B + C + {()=A()
441 	 * + B() + C();}; E:class = D + {()=D();}; F:class = D + {()=D();}; G:class = E + F + {()=D() + E() + F();};];
442 	 * 
443 	 * @throws Exception
444 	 *             x
445 	 */
446 	@Test
447 	public void testDiamondUnderDiamond() throws Exception {
448 		final String input =
449 				"group1:group = [A:class={();}; B:class = A + {()=A();}; C:class = A + {()=A();};"
450 						+ " D:class = B + C + {()=A() + B() + C();}; E:class = D + {()=D();}; F:class = D + {()=D();};"
451 						+ " G:class = E + F + {()=D() + E() + F();};];";
452 		
453 		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
454 		
455 		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
456 		while (iterator.hasNext()) {
457 			final Type current = iterator.next();
458 			
459 			switch (current.getTypeString()) {
460 			case "group1>A":
461 				assertTrue(true);
462 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
463 				break;
464 			case "group1>B":
465 				final Iterator<Type> bIterator = model.getConstructorCallDependencies().get(current).iterator();
466 				assertEquals("group1>A", bIterator.next().toString());
467 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
468 				break;
469 			case "group1>C":
470 				final Iterator<Type> cIterator = model.getConstructorCallDependencies().get(current).iterator();
471 				assertEquals("group1>A", cIterator.next().toString());
472 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
473 				break;
474 			case "group1>D":
475 				final Iterator<Type> dIterator = model.getConstructorCallDependencies().get(current).iterator();
476 				assertEquals("group1>A", dIterator.next().toString());
477 				assertEquals("group1>B", dIterator.next().toString());
478 				assertEquals("group1>C", dIterator.next().toString());
479 				assertEquals(3, model.getConstructorCallDependencies().get(current).size());
480 				break;
481 			case "group1>E":
482 				final Iterator<Type> eIterator = model.getConstructorCallDependencies().get(current).iterator();
483 				assertEquals("group1>D", eIterator.next().toString());
484 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
485 				break;
486 			case "group1>F":
487 				final Iterator<Type> fIterator = model.getConstructorCallDependencies().get(current).iterator();
488 				assertEquals("group1>D", fIterator.next().toString());
489 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
490 				break;
491 			case "group1>G":
492 				final Iterator<Type> gIterator = model.getConstructorCallDependencies().get(current).iterator();
493 				assertEquals("group1>D", gIterator.next().toString());
494 				assertEquals("group1>E", gIterator.next().toString());
495 				assertEquals("group1>F", gIterator.next().toString());
496 				assertEquals(3, model.getConstructorCallDependencies().get(current).size());
497 				break;
498 			default:
499 				fail();
500 				break;
501 			}
502 		}
503 	}
504 	
505 	/**
506 	 * Tests the Diamond under a diamond with hands.
507 	 * 
508 	 * Model: group1:group = [A:class={();}; B:class = A + {()=A();}; C:class = A + {()=A();}; D:class = B + C + {()=A()
509 	 * + B() + C();}; E:class = D + H {()=D() + H();}; F:class = D + I + {()=D() + I();}; G:class = E + F + {()=D() +
510 	 * E() + F();}; H:class = {();}; I:class = {();};];
511 	 * 
512 	 * @throws Exception
513 	 *             x
514 	 */
515 	@Test
516 	public void testDiamondUnderDiamondWithHandyCalledCactus() throws Exception {
517 		final String input =
518 				"group1:group = [A:class={();}; B:class = A + {()=A();}; C:class = A + {()=A();};"
519 						+ " D:class = B + C + {()=A() + B() + C();}; E:class = D + H + {()=D() + H();};"
520 						+ " F:class = D + I + {()=D() + I();}; G:class = E + F + {()=D() + E() + F();};"
521 						+ " H:class = {();}; I:class = {();};];";
522 		
523 		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
524 		
525 		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
526 		while (iterator.hasNext()) {
527 			final Type current = iterator.next();
528 			
529 			switch (current.getTypeString()) {
530 			case "group1>A":
531 				assertTrue(true);
532 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
533 				break;
534 			case "group1>B":
535 				final Iterator<Type> bIterator = model.getConstructorCallDependencies().get(current).iterator();
536 				assertEquals("group1>A", bIterator.next().toString());
537 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
538 				break;
539 			case "group1>C":
540 				final Iterator<Type> cIterator = model.getConstructorCallDependencies().get(current).iterator();
541 				assertEquals("group1>A", cIterator.next().toString());
542 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
543 				break;
544 			case "group1>D":
545 				final Iterator<Type> dIterator = model.getConstructorCallDependencies().get(current).iterator();
546 				assertEquals("group1>A", dIterator.next().toString());
547 				assertEquals("group1>B", dIterator.next().toString());
548 				assertEquals("group1>C", dIterator.next().toString());
549 				assertEquals(3, model.getConstructorCallDependencies().get(current).size());
550 				break;
551 			case "group1>E":
552 				final Iterator<Type> eIterator = model.getConstructorCallDependencies().get(current).iterator();
553 				assertEquals("group1>D", eIterator.next().toString());
554 				assertEquals("group1>H", eIterator.next().toString());
555 				assertEquals(2, model.getConstructorCallDependencies().get(current).size());
556 				break;
557 			case "group1>F":
558 				final Iterator<Type> fIterator = model.getConstructorCallDependencies().get(current).iterator();
559 				assertEquals("group1>D", fIterator.next().toString());
560 				assertEquals("group1>I", fIterator.next().toString());
561 				assertEquals(2, model.getConstructorCallDependencies().get(current).size());
562 				break;
563 			case "group1>G":
564 				final Iterator<Type> gIterator = model.getConstructorCallDependencies().get(current).iterator();
565 				assertEquals("group1>D", gIterator.next().toString());
566 				assertEquals("group1>E", gIterator.next().toString());
567 				assertEquals("group1>F", gIterator.next().toString());
568 				assertEquals(3, model.getConstructorCallDependencies().get(current).size());
569 				break;
570 			case "group1>H":
571 				assertTrue(true);
572 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
573 				break;
574 			case "group1>I":
575 				assertTrue(true);
576 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
577 				break;
578 			default:
579 				fail();
580 				break;
581 			}
582 		}
583 	}
584 	
585 	/**
586 	 * Tests the Diamond under a diamond with an extra path from the bottom to the top.
587 	 * 
588 	 * Model: group1:group = [A:class={();}; B:class = A + {()=A();}; C:class = A + {()=A();}; D:class = B + C + {()=A()
589 	 * + B() + C();}; E:class = D + {()=D();}; F:class = D + {()=D();}; G:class = E + F + H + {()=A() + H() + D() + E()
590 	 * + F();}; H:class = A + {() = A();};];
591 	 * 
592 	 * @throws Exception
593 	 *             x InvalidConstructorReferencedListException
594 	 */
595 	@Test
596 	public void testDiamondExtra() throws Exception {
597 		final String input =
598 				"group1:group = [A:class={();}; B:class = A + {()=A();}; C:class = A + {()=A();};"
599 						+ " D:class = B + C + {()=A() + B() + C();}; E:class = D + {()=D();}; F:class = D + {()=D();};"
600 						+ " G:class = E + F + H + {()= A() + H() + D() + E() + F();}; H:class = A + {() = A();};];";
601 		
602 		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
603 		
604 		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
605 		while (iterator.hasNext()) {
606 			final Type current = iterator.next();
607 			
608 			switch (current.getTypeString()) {
609 			case "group1>A":
610 				assertTrue(true);
611 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
612 				break;
613 			case "group1>B":
614 				final Iterator<Type> bIterator = model.getConstructorCallDependencies().get(current).iterator();
615 				assertEquals("group1>A", bIterator.next().toString());
616 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
617 				break;
618 			case "group1>C":
619 				final Iterator<Type> cIterator = model.getConstructorCallDependencies().get(current).iterator();
620 				assertEquals("group1>A", cIterator.next().toString());
621 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
622 				break;
623 			case "group1>D":
624 				final Iterator<Type> dIterator = model.getConstructorCallDependencies().get(current).iterator();
625 				assertEquals("group1>A", dIterator.next().toString());
626 				assertEquals("group1>B", dIterator.next().toString());
627 				assertEquals("group1>C", dIterator.next().toString());
628 				assertEquals(3, model.getConstructorCallDependencies().get(current).size());
629 				break;
630 			case "group1>E":
631 				final Iterator<Type> eIterator = model.getConstructorCallDependencies().get(current).iterator();
632 				assertEquals("group1>D", eIterator.next().toString());
633 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
634 				break;
635 			case "group1>F":
636 				final Iterator<Type> fIterator = model.getConstructorCallDependencies().get(current).iterator();
637 				assertEquals("group1>D", fIterator.next().toString());
638 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
639 				break;
640 			case "group1>G":
641 				final Iterator<Type> gIterator = model.getConstructorCallDependencies().get(current).iterator();
642 				assertEquals("group1>A", gIterator.next().toString());
643 				assertEquals("group1>D", gIterator.next().toString());
644 				assertEquals("group1>E", gIterator.next().toString());
645 				assertEquals("group1>F", gIterator.next().toString());
646 				assertEquals("group1>H", gIterator.next().toString());
647 				assertEquals(5, model.getConstructorCallDependencies().get(current).size());
648 				break;
649 			case "group1>H":
650 				final Iterator<Type> hIterator = model.getConstructorCallDependencies().get(current).iterator();
651 				assertEquals("group1>A", hIterator.next().toString());
652 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
653 				break;
654 			default:
655 				fail();
656 				break;
657 			}
658 		}
659 	}
660 	
661 	/**
662 	 * Tests the large Diamond.
663 	 * 
664 	 * Model: group1:group = [A:class={();};B:class=
665 	 * A+{()=A();};C:class=A+{()=A();};D:class=A+{()=A();};E:class=A+{()=A(
666 	 * );};F:class=B+C+D+E+{()=A()+B()+C()+D()+E();};];
667 	 * 
668 	 * @throws Exception
669 	 *             x
670 	 */
671 	@Test
672 	public void testLargeDiamond() throws Exception {
673 		final String input =
674 				"group1:group = [A:class={();};B:class= A+{()=A();};C:class=A+{()=A();};"
675 						+ "D:class=A+{()=A();};E:class=A+{()=A();};F:class=B+C+D+E+{()=A()+B()+C()+D()+E();};];";
676 		
677 		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
678 		
679 		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
680 		while (iterator.hasNext()) {
681 			final Type current = iterator.next();
682 			
683 			switch (current.getTypeString()) {
684 			case "group1>A":
685 				assertTrue(true);
686 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
687 				break;
688 			case "group1>B":
689 				final Iterator<Type> bIterator = model.getConstructorCallDependencies().get(current).iterator();
690 				assertEquals("group1>A", bIterator.next().toString());
691 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
692 				break;
693 			case "group1>C":
694 				final Iterator<Type> cIterator = model.getConstructorCallDependencies().get(current).iterator();
695 				assertEquals("group1>A", cIterator.next().toString());
696 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
697 				break;
698 			case "group1>D":
699 				final Iterator<Type> dIterator = model.getConstructorCallDependencies().get(current).iterator();
700 				assertEquals("group1>A", dIterator.next().toString());
701 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
702 				break;
703 			case "group1>E":
704 				final Iterator<Type> eIterator = model.getConstructorCallDependencies().get(current).iterator();
705 				assertEquals("group1>A", eIterator.next().toString());
706 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
707 				break;
708 			case "group1>F":
709 				final Iterator<Type> fIterator = model.getConstructorCallDependencies().get(current).iterator();
710 				assertEquals("group1>A", fIterator.next().toString());
711 				assertEquals("group1>B", fIterator.next().toString());
712 				assertEquals("group1>C", fIterator.next().toString());
713 				assertEquals("group1>D", fIterator.next().toString());
714 				assertEquals("group1>E", fIterator.next().toString());
715 				assertEquals(5, model.getConstructorCallDependencies().get(current).size());
716 				break;
717 			default:
718 				fail();
719 				break;
720 			}
721 		}
722 	}
723 	
724 	/**
725 	 * Tests the parallel Diamond.
726 	 * 
727 	 * Model: group1:group = [A:class={();};B:class=
728 	 * A+{()=A();};C:class=A+{()=A();};D:class=B+{()=B();};E:class=B+{()=B();};H:class=D+E+{()=B()+D()+E();};
729 	 * F:class=C+{()=C();};G:class=C+{()=C();};I:class=F+G+{()=C()+F()+G();};J:class=H+I+{()=A()+H()+I();};];
730 	 * 
731 	 * @throws Exception
732 	 *             x
733 	 */
734 	@Test
735 	public void testParallelDiamond() throws Exception {
736 		final String input =
737 				"group1:group = [A:class={();};B:class= A+{()=A();};C:class=A+{()=A();};"
738 						+ "D:class=B+{()=B();};E:class=B+{()=B();};H:class=D+E+{()=B()+D()+E();};"
739 						+ "F:class=C+{()=C();};G:class=C+{()=C();};I:class=F+G+{()=C()+F()+G();};"
740 						+ "J:class=H+I+{()=A()+H()+I();};];";
741 		
742 		final Model model = SyntaxCheck.getInstance().getModelFromString(input);
743 		
744 		final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
745 		while (iterator.hasNext()) {
746 			final Type current = iterator.next();
747 			
748 			switch (current.getTypeString()) {
749 			case "group1>A":
750 				assertTrue(true);
751 				assertEquals(0, model.getConstructorCallDependencies().get(current).size());
752 				break;
753 			case "group1>B":
754 				final Iterator<Type> bIterator = model.getConstructorCallDependencies().get(current).iterator();
755 				assertEquals("group1>A", bIterator.next().toString());
756 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
757 				break;
758 			case "group1>C":
759 				final Iterator<Type> cIterator = model.getConstructorCallDependencies().get(current).iterator();
760 				assertEquals("group1>A", cIterator.next().toString());
761 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
762 				break;
763 			case "group1>D":
764 				final Iterator<Type> dIterator = model.getConstructorCallDependencies().get(current).iterator();
765 				assertEquals("group1>B", dIterator.next().toString());
766 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
767 				break;
768 			case "group1>E":
769 				final Iterator<Type> eIterator = model.getConstructorCallDependencies().get(current).iterator();
770 				assertEquals("group1>B", eIterator.next().toString());
771 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
772 				break;
773 			case "group1>F":
774 				final Iterator<Type> fIterator = model.getConstructorCallDependencies().get(current).iterator();
775 				assertEquals("group1>C", fIterator.next().toString());
776 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
777 				break;
778 			case "group1>G":
779 				final Iterator<Type> gIterator = model.getConstructorCallDependencies().get(current).iterator();
780 				assertEquals("group1>C", gIterator.next().toString());
781 				assertEquals(1, model.getConstructorCallDependencies().get(current).size());
782 				break;
783 			case "group1>H":
784 				final Iterator<Type> hIterator = model.getConstructorCallDependencies().get(current).iterator();
785 				assertEquals("group1>B", hIterator.next().toString());
786 				assertEquals("group1>D", hIterator.next().toString());
787 				assertEquals("group1>E", hIterator.next().toString());
788 				assertEquals(3, model.getConstructorCallDependencies().get(current).size());
789 				break;
790 			case "group1>I":
791 				final Iterator<Type> iIterator = model.getConstructorCallDependencies().get(current).iterator();
792 				assertEquals("group1>C", iIterator.next().toString());
793 				assertEquals("group1>F", iIterator.next().toString());
794 				assertEquals("group1>G", iIterator.next().toString());
795 				assertEquals(3, model.getConstructorCallDependencies().get(current).size());
796 				break;
797 			case "group1>J":
798 				final Iterator<Type> jIterator = model.getConstructorCallDependencies().get(current).iterator();
799 				assertEquals("group1>A", jIterator.next().toString());
800 				assertEquals("group1>H", jIterator.next().toString());
801 				assertEquals("group1>I", jIterator.next().toString());
802 				assertEquals(3, model.getConstructorCallDependencies().get(current).size());
803 				break;
804 			default:
805 				fail();
806 				break;
807 			}
808 		}
809 	}
810 	
811 	/**
812 	 * Tests the parallel Diamond.
813 	 * 
814 	 * Model: Komplex
815 	 * 
816 	 * @throws Exception
817 	 *             x
818 	 */
819 	@Test
820 	public void testComplexModel() throws Exception {
821 		try {
822 			
823 			final String input =
824 					" group1:group = [" + "N:class={();};" + "M:class={();};" + "K:class = N + M + {()=N()+M();};"
825 							+ "H:class = K + {()=K();};" + "J:class = K + {()=K();};"
826 							+ "E:class = H + J + {()=K()+H()+J();};" + "L:class = {();};" + "O:class = {();};"
827 							+ "C:class = E + {()=E();};" + "A:class = C + O + L + {()=C()+O()+L();};"
828 							+ "D:class = C + {()=C();};" + "I:class = L + E + {()=E()+L();};"
829 							+ "B:class = E + {()=E();};" + "G:class = A + {()=A();};"
830 							+ "F:class = A + D + B + P + S + Q + H + K + "
831 							+ "{()=A()+D()+H()+B()++P()+S()+C()+Q()+E()+R();};" + "P:class = R + {()=R();};"
832 							+ "Q:class = R + {()=R();};" + "S:class = R + {()=R();};" + "R:class = {();};" + "];";
833 			
834 			final Model model = SyntaxCheck.getInstance().getModelFromString(input);
835 			
836 			final Iterator<Type> iterator = model.getConstructorCallDependencies().keySet().iterator();
837 			while (iterator.hasNext()) {
838 				final Type current = iterator.next();
839 				
840 				switch (current.getTypeString()) {
841 				case "group1>A":
842 					final Iterator<Type> aIterator = model.getConstructorCallDependencies().get(current).iterator();
843 					assertEquals("group1>C", aIterator.next().toString());
844 					assertEquals("group1>O", aIterator.next().toString());
845 					assertEquals("group1>L", aIterator.next().toString());
846 					assertEquals(3, model.getConstructorCallDependencies().get(current).size());
847 					break;
848 				case "group1>B":
849 					final Iterator<Type> bIterator = model.getConstructorCallDependencies().get(current).iterator();
850 					assertEquals("group1>E", bIterator.next().toString());
851 					assertEquals(1, model.getConstructorCallDependencies().get(current).size());
852 					break;
853 				case "group1>C":
854 					final Iterator<Type> cIterator = model.getConstructorCallDependencies().get(current).iterator();
855 					assertEquals("group1>E", cIterator.next().toString());
856 					assertEquals(1, model.getConstructorCallDependencies().get(current).size());
857 					break;
858 				case "group1>D":
859 					final Iterator<Type> dIterator = model.getConstructorCallDependencies().get(current).iterator();
860 					assertEquals("group1>C", dIterator.next().toString());
861 					assertEquals(1, model.getConstructorCallDependencies().get(current).size());
862 					break;
863 				case "group1>E":
864 					final Iterator<Type> eIterator = model.getConstructorCallDependencies().get(current).iterator();
865 					assertEquals("group1>K", eIterator.next().toString());
866 					assertEquals("group1>H", eIterator.next().toString());
867 					assertEquals("group1>J", eIterator.next().toString());
868 					assertEquals(3, model.getConstructorCallDependencies().get(current).size());
869 					break;
870 				case "group1>F":
871 					final Iterator<Type> fIterator = model.getConstructorCallDependencies().get(current).iterator();
872 					assertEquals("group1>E", fIterator.next().toString());
873 					assertEquals("group1>C", fIterator.next().toString());
874 					assertEquals("group1>A", fIterator.next().toString());
875 					assertEquals("group1>D", fIterator.next().toString());
876 					assertEquals("group1>B", fIterator.next().toString());
877 					assertEquals("group1>R", fIterator.next().toString());
878 					assertEquals("group1>P", fIterator.next().toString());
879 					assertEquals("group1>S", fIterator.next().toString());
880 					assertEquals("group1>Q", fIterator.next().toString());
881 					assertEquals("group1>H", fIterator.next().toString());
882 					assertEquals(10, model.getConstructorCallDependencies().get(current).size());
883 					break;
884 				case "group1>G":
885 					final Iterator<Type> gIterator = model.getConstructorCallDependencies().get(current).iterator();
886 					assertEquals("group1>A", gIterator.next().toString());
887 					assertEquals(1, model.getConstructorCallDependencies().get(current).size());
888 					break;
889 				case "group1>H":
890 					final Iterator<Type> hIterator = model.getConstructorCallDependencies().get(current).iterator();
891 					assertEquals("group1>K", hIterator.next().toString());
892 					assertEquals(1, model.getConstructorCallDependencies().get(current).size());
893 					break;
894 				case "group1>I":
895 					final Iterator<Type> iIterator = model.getConstructorCallDependencies().get(current).iterator();
896 					assertEquals("group1>L", iIterator.next().toString());
897 					assertEquals("group1>E", iIterator.next().toString());
898 					assertEquals(2, model.getConstructorCallDependencies().get(current).size());
899 					break;
900 				case "group1>J":
901 					final Iterator<Type> jIterator = model.getConstructorCallDependencies().get(current).iterator();
902 					assertEquals("group1>K", jIterator.next().toString());
903 					assertEquals(1, model.getConstructorCallDependencies().get(current).size());
904 					break;
905 				case "group1>K":
906 					final Iterator<Type> kIterator = model.getConstructorCallDependencies().get(current).iterator();
907 					assertEquals("group1>N", kIterator.next().toString());
908 					assertEquals("group1>M", kIterator.next().toString());
909 					assertEquals(2, model.getConstructorCallDependencies().get(current).size());
910 					break;
911 				case "group1>L":
912 					assertTrue(true);
913 					assertEquals(0, model.getConstructorCallDependencies().get(current).size());
914 					break;
915 				case "group1>M":
916 					assertTrue(true);
917 					assertEquals(0, model.getConstructorCallDependencies().get(current).size());
918 					break;
919 				case "group1>N":
920 					assertTrue(true);
921 					assertEquals(0, model.getConstructorCallDependencies().get(current).size());
922 					break;
923 				case "group1>O":
924 					assertTrue(true);
925 					assertEquals(0, model.getConstructorCallDependencies().get(current).size());
926 					break;
927 				case "group1>P":
928 					final Iterator<Type> pIterator = model.getConstructorCallDependencies().get(current).iterator();
929 					assertEquals("group1>R", pIterator.next().toString());
930 					assertEquals(1, model.getConstructorCallDependencies().get(current).size());
931 					break;
932 				case "group1>Q":
933 					final Iterator<Type> qIterator = model.getConstructorCallDependencies().get(current).iterator();
934 					assertEquals("group1>R", qIterator.next().toString());
935 					assertEquals(1, model.getConstructorCallDependencies().get(current).size());
936 					break;
937 				case "group1>R":
938 					assertTrue(true);
939 					assertEquals(0, model.getConstructorCallDependencies().get(current).size());
940 					break;
941 				case "group1>S":
942 					final Iterator<Type> sIterator = model.getConstructorCallDependencies().get(current).iterator();
943 					assertEquals("group1>R", sIterator.next().toString());
944 					assertEquals(1, model.getConstructorCallDependencies().get(current).size());
945 					break;
946 				default:
947 					fail();
948 					break;
949 				}
950 			}
951 		} catch (final MultipleCheckExceptions e) {
952 			int i = 0;
953 			i = i + 1;
954 		}
955 	}
956 }