View Javadoc
1   package de.fhdw.wtf.parser.test;
2   
3   import static org.junit.Assert.assertEquals;
4   import static org.junit.Assert.assertTrue;
5   
6   import java.util.Vector;
7   
8   import org.junit.Before;
9   import org.junit.Test;
10  
11  import de.fhdw.wtf.common.ast.Attribute;
12  import de.fhdw.wtf.common.ast.Constructor;
13  import de.fhdw.wtf.common.ast.Group;
14  import de.fhdw.wtf.common.ast.GroupElement;
15  import de.fhdw.wtf.common.ast.Model;
16  import de.fhdw.wtf.common.ast.Name;
17  import de.fhdw.wtf.common.ast.Operation;
18  import de.fhdw.wtf.common.ast.OperationModifier;
19  import de.fhdw.wtf.common.ast.OperationModifierAbstract;
20  import de.fhdw.wtf.common.ast.UnqualifiedName;
21  import de.fhdw.wtf.common.ast.type.ByNameState;
22  import de.fhdw.wtf.common.ast.type.ClassModifier;
23  import de.fhdw.wtf.common.ast.type.ClassType;
24  import de.fhdw.wtf.common.ast.type.ExceptionClassType;
25  import de.fhdw.wtf.common.ast.type.ProductElementType;
26  import de.fhdw.wtf.common.ast.type.ProductType;
27  import de.fhdw.wtf.common.ast.type.RegularClassType;
28  import de.fhdw.wtf.common.ast.type.SumType;
29  import de.fhdw.wtf.common.ast.type.ThrownType;
30  import de.fhdw.wtf.common.ast.type.Type;
31  import de.fhdw.wtf.common.ast.type.TypeProxy;
32  import de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException;
33  import de.fhdw.wtf.common.stream.SimpleTokenStream;
34  import de.fhdw.wtf.common.stream.TokenStream;
35  import de.fhdw.wtf.common.token.EndToken;
36  import de.fhdw.wtf.common.token.IdentifierToken;
37  import de.fhdw.wtf.common.token.Position;
38  import de.fhdw.wtf.common.token.keywords.AbstractToken;
39  import de.fhdw.wtf.common.token.keywords.ClassToken;
40  import de.fhdw.wtf.common.token.keywords.ExceptionToken;
41  import de.fhdw.wtf.common.token.keywords.GroupToken;
42  import de.fhdw.wtf.common.token.symbols.ArrowToken;
43  import de.fhdw.wtf.common.token.symbols.AsteriskToken;
44  import de.fhdw.wtf.common.token.symbols.BracketCloseToken;
45  import de.fhdw.wtf.common.token.symbols.BracketOpenToken;
46  import de.fhdw.wtf.common.token.symbols.ColonToken;
47  import de.fhdw.wtf.common.token.symbols.CommaToken;
48  import de.fhdw.wtf.common.token.symbols.CurlyBracketCloseToken;
49  import de.fhdw.wtf.common.token.symbols.CurlyBracketOpenToken;
50  import de.fhdw.wtf.common.token.symbols.DoubleSquareBracketCloseToken;
51  import de.fhdw.wtf.common.token.symbols.DoubleSquareBracketOpenToken;
52  import de.fhdw.wtf.common.token.symbols.EqualToken;
53  import de.fhdw.wtf.common.token.symbols.ExclamationToken;
54  import de.fhdw.wtf.common.token.symbols.GreaterSymbolToken;
55  import de.fhdw.wtf.common.token.symbols.SemicolonToken;
56  import de.fhdw.wtf.common.token.symbols.SquareBracketCloseToken;
57  import de.fhdw.wtf.common.token.symbols.SquareBracketOpenToken;
58  import de.fhdw.wtf.parser.Parser;
59  
60  /**
61   * Tests the parsing of operations and the {@link Operation}.
62   */
63  public class TestOperations {
64  	
65  	/**
66  	 * Parser which is used to parse the {@link TokenStream} from scanner.
67  	 */
68  	private Parser parser;
69  	
70  	/**
71  	 * {@link TokenStream} which is used for testing the {@link Parser}.
72  	 */
73  	private TokenStream stream;
74  	
75  	/**
76  	 * The {@link ColonToken} represents ":".
77  	 */
78  	private ColonToken colonToken;
79  	
80  	/**
81  	 * The {@link GroupToken} represents "group".
82  	 */
83  	private GroupToken groupToken;
84  	
85  	/**
86  	 * The {@link EqualToken} represents "=".
87  	 */
88  	private EqualToken equalToken;
89  	
90  	/**
91  	 * The {@link SquareBracketOpenToken} represents "[".
92  	 */
93  	private SquareBracketOpenToken squareBracketOpenToken;
94  	
95  	/**
96  	 * The {@link SquareBracketCloseToken} represents "]".
97  	 */
98  	private SquareBracketCloseToken squareBracketCloseToken;
99  	
100 	/**
101 	 * The {@link SemicolonToken} represents ";".
102 	 */
103 	private SemicolonToken semicolonToken;
104 	
105 	/**
106 	 * The {@link ClassToken} represents "class".
107 	 */
108 	private ClassToken classToken;
109 	
110 	/**
111 	 * The {@link CurlyBracketOpenToken} represents "{".
112 	 */
113 	private CurlyBracketOpenToken curlyBracketOpenToken;
114 	
115 	/**
116 	 * The {@link CurlyBracketCloseToken} represents "}".
117 	 */
118 	private CurlyBracketCloseToken curlyBracketCloseToken;
119 	
120 	/**
121 	 * The {@link BracketOpenToken} represents "(".
122 	 */
123 	private BracketOpenToken bracketOpenToken;
124 	
125 	/**
126 	 * The {@link BracketCloseToken} represents ")".
127 	 */
128 	private BracketCloseToken bracketCloseToken;
129 	
130 	/**
131 	 * The {@link EndToken} represents "".
132 	 */
133 	private EndToken endToken;
134 	
135 	/**
136 	 * The {@link GreaterSymbolToken} represents ">".
137 	 */
138 	private GreaterSymbolToken greaterSymbolToken;
139 	
140 	/**
141 	 * The {@link ArrowToken} represents "->".
142 	 */
143 	private ArrowToken arrowToken;
144 	
145 	/**
146 	 * The {@link CommaToken} represents ",".
147 	 */
148 	private CommaToken commaToken;
149 	
150 	/**
151 	 * The {@link AbstractToken} represents "abstract".
152 	 */
153 	private AbstractToken abstractToken;
154 	
155 	/**
156 	 * The {@link DoubleSquareBracketOpenToken} represents "[[".
157 	 */
158 	private DoubleSquareBracketOpenToken doubleSquareBracketOpenToken;
159 	
160 	/**
161 	 * The {@link DoubleSquareBracketCloseToken} represents "]]".
162 	 */
163 	private DoubleSquareBracketCloseToken doubleSquareBracketCloseToken;
164 	
165 	/**
166 	 * Creates the most important Tokens.
167 	 */
168 	@Before
169 	public void setUp() {
170 		this.stream = SimpleTokenStream.create();
171 		this.parser = Parser.create(this.stream);
172 		
173 		this.colonToken = ColonToken.create(Position.create("", 1, 1, 0));
174 		this.groupToken = GroupToken.create(Position.create("", 1, 1, 0));
175 		this.equalToken = EqualToken.create(Position.create("", 1, 1, 0));
176 		this.squareBracketOpenToken = SquareBracketOpenToken.create(Position.create("", 1, 1, 0));
177 		this.squareBracketCloseToken = SquareBracketCloseToken.create(Position.create("", 1, 1, 0));
178 		this.bracketOpenToken = BracketOpenToken.create(Position.create("", 1, 1, 0));
179 		this.bracketCloseToken = BracketCloseToken.create(Position.create("", 1, 1, 0));
180 		this.semicolonToken = SemicolonToken.create(Position.create("", 1, 1, 0));
181 		this.classToken = ClassToken.create(Position.create("", 1, 1, 0));
182 		this.curlyBracketOpenToken = CurlyBracketOpenToken.create(Position.create("", 1, 1, 0));
183 		this.curlyBracketCloseToken = CurlyBracketCloseToken.create(Position.create("", 1, 1, 0));
184 		this.endToken = EndToken.create(Position.create("", 1, 1, 0));
185 		this.abstractToken = AbstractToken.create(Position.create("", 1, 1, 0));
186 		this.greaterSymbolToken = GreaterSymbolToken.create(Position.create("", 1, 1, 0));
187 		this.commaToken = CommaToken.create(Position.create("", 1, 1, 0));
188 		this.doubleSquareBracketCloseToken = DoubleSquareBracketCloseToken.create(Position.create("", 1, 1, 0));
189 		this.doubleSquareBracketOpenToken = DoubleSquareBracketOpenToken.create(Position.create("", 1, 1, 0));
190 		this.arrowToken = ArrowToken.create(Position.create("", 1, 1, 0));
191 	}
192 	
193 	/**
194 	 * MyGroup:group=[MyClass:class={MyOperation:[[()->{}];};]];.
195 	 * 
196 	 * @throws Exception
197 	 *             {@link de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException}
198 	 */
199 	@Test
200 	public void testSimpleOperationWithoutParameters() throws Exception {
201 		final IdentifierToken myGroup = IdentifierToken.create("MyGroup", Position.create("", 1, 1, 0));
202 		final IdentifierToken myClass = IdentifierToken.create("MyClass", Position.create("", 1, 1, 0));
203 		final IdentifierToken myOperation = IdentifierToken.create("MyOperation", Position.create("", 1, 1, 0));
204 		this.stream.add(myGroup);
205 		this.stream.add(this.colonToken);
206 		this.stream.add(this.groupToken);
207 		this.stream.add(this.equalToken);
208 		this.stream.add(this.squareBracketOpenToken);
209 		this.stream.add(myClass);
210 		this.stream.add(this.colonToken);
211 		this.stream.add(this.classToken);
212 		this.stream.add(this.equalToken);
213 		this.stream.add(this.curlyBracketOpenToken);
214 		this.stream.add(myOperation);
215 		this.stream.add(this.colonToken);
216 		this.stream.add(this.doubleSquareBracketOpenToken);
217 		this.stream.add(this.bracketOpenToken);
218 		this.stream.add(this.bracketCloseToken);
219 		this.stream.add(this.arrowToken);
220 		this.stream.add(this.curlyBracketOpenToken);
221 		this.stream.add(this.curlyBracketCloseToken);
222 		this.stream.add(this.doubleSquareBracketCloseToken);
223 		this.stream.add(this.semicolonToken);
224 		this.stream.add(this.curlyBracketCloseToken);
225 		this.stream.add(this.semicolonToken);
226 		this.stream.add(this.squareBracketCloseToken);
227 		this.stream.add(this.semicolonToken);
228 		this.stream.add(this.endToken);
229 		
230 		final Vector<GroupElement> groupVector = new Vector<>();
231 		final Vector<Operation> operations = new Vector<>();
232 		
233 		final Name groupName = UnqualifiedName.create(myGroup);
234 		final Group group = Group.create(groupName, groupVector, myGroup);
235 		
236 		final Name className = groupName.addName(myClass);
237 		
238 		final ClassType class1 =
239 				RegularClassType.create(
240 						className,
241 						new Vector<ClassModifier>(),
242 						new Vector<Attribute>(),
243 						new Vector<Type>(),
244 						operations,
245 						new Vector<Constructor>(),
246 						myClass,
247 						
248 						new Vector<ClassType>());
249 		groupVector.add(class1);
250 		
251 		final ProductType product = ProductType.create(this.bracketOpenToken);
252 		final SumType sum = SumType.create(this.curlyBracketOpenToken);
253 		
254 		final Operation operation =
255 				Operation.create("MyOperation", new Vector<OperationModifier>(), product, class1, sum, myOperation);
256 		operations.add(operation);
257 		
258 		final Model expected = Model.create(myGroup);
259 		expected.addGroup(group);
260 		
261 		final Model actual = this.parser.parse();
262 		assertEquals(0, this.parser.getExceptions().size());
263 		assertEquals(expected, actual);
264 	}
265 	
266 	/**
267 	 * MyGroup:group=[MyClass:class={MyOperation:[[(MyParameter:String)->{}]];}; ];.
268 	 * 
269 	 * @throws Exception
270 	 *             {@link de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException}
271 	 */
272 	@Test
273 	public void testOperationWithOneSimpleInputParameter() throws Exception {
274 		final IdentifierToken myGroup = IdentifierToken.create("MyGroup", Position.create("", 1, 1, 0));
275 		final IdentifierToken myClass = IdentifierToken.create("MyClass", Position.create("", 1, 1, 0));
276 		final IdentifierToken myOperation = IdentifierToken.create("MyOperation", Position.create("", 1, 1, 0));
277 		final IdentifierToken myParameter = IdentifierToken.create("MyParameter", Position.create("", 1, 1, 0));
278 		final IdentifierToken string = IdentifierToken.create("String", Position.create("", 1, 1, 0));
279 		this.stream.add(myGroup);
280 		this.stream.add(this.colonToken);
281 		this.stream.add(this.groupToken);
282 		this.stream.add(this.equalToken);
283 		this.stream.add(this.squareBracketOpenToken);
284 		this.stream.add(myClass);
285 		this.stream.add(this.colonToken);
286 		this.stream.add(this.classToken);
287 		this.stream.add(this.equalToken);
288 		this.stream.add(this.curlyBracketOpenToken);
289 		this.stream.add(myOperation);
290 		this.stream.add(this.colonToken);
291 		this.stream.add(this.doubleSquareBracketOpenToken);
292 		this.stream.add(this.bracketOpenToken);
293 		this.stream.add(myParameter);
294 		this.stream.add(this.colonToken);
295 		this.stream.add(string);
296 		this.stream.add(this.bracketCloseToken);
297 		this.stream.add(this.arrowToken);
298 		this.stream.add(this.curlyBracketOpenToken);
299 		this.stream.add(this.curlyBracketCloseToken);
300 		this.stream.add(this.doubleSquareBracketCloseToken);
301 		this.stream.add(this.semicolonToken);
302 		this.stream.add(this.curlyBracketCloseToken);
303 		this.stream.add(this.semicolonToken);
304 		this.stream.add(this.squareBracketCloseToken);
305 		this.stream.add(this.semicolonToken);
306 		this.stream.add(this.endToken);
307 		
308 		final Vector<GroupElement> groupVector = new Vector<>();
309 		final Vector<Operation> operations = new Vector<>();
310 		
311 		final Name groupName = UnqualifiedName.create(myGroup);
312 		final Group group = Group.create(groupName, groupVector, myGroup);
313 		
314 		final Name className = groupName.addName(myClass);
315 		final ClassType class1 =
316 				RegularClassType.create(
317 						className,
318 						new Vector<ClassModifier>(),
319 						new Vector<Attribute>(),
320 						new Vector<Type>(),
321 						operations,
322 						new Vector<Constructor>(),
323 						myClass,
324 						
325 						new Vector<ClassType>());
326 		groupVector.add(class1);
327 		
328 		final ProductType product = ProductType.create(this.bracketOpenToken);
329 		final ByNameState byName = ByNameState.create(UnqualifiedName.create(string));
330 		final TypeProxy typeProxy = TypeProxy.create(string, byName);
331 		final ProductElementType element = ProductElementType.create("MyParameter", typeProxy, myParameter);
332 		product.addElement(element);
333 		
334 		final SumType sum = SumType.create(this.curlyBracketOpenToken);
335 		final Operation operation =
336 				Operation.create("MyOperation", new Vector<OperationModifier>(), product, class1, sum, myOperation);
337 		operations.add(operation);
338 		
339 		final Model expected = Model.create(myGroup);
340 		expected.addGroup(group);
341 		
342 		final Model actual = this.parser.parse();
343 		
344 		assertEquals(expected, actual);
345 		assertEquals(0, this.parser.getExceptions().size());
346 	}
347 	
348 	/**
349 	 * MyGroup:group=[MyClass:class={MyOperation:[[(MyParameter1:String, MyParameter2:Integer)->{}]];};];.
350 	 * 
351 	 * @throws Exception
352 	 *             {@link de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException}
353 	 */
354 	@Test
355 	public void testOperationWithTwoSimpleInputParameter() throws Exception {
356 		final IdentifierToken myGroup = IdentifierToken.create("MyGroup", Position.create("", 1, 1, 0));
357 		final IdentifierToken myClass = IdentifierToken.create("MyClass", Position.create("", 1, 1, 0));
358 		final IdentifierToken myOperation = IdentifierToken.create("MyOperation", Position.create("", 1, 1, 0));
359 		final IdentifierToken myParameter1 = IdentifierToken.create("MyParameter1", Position.create("", 1, 1, 0));
360 		final IdentifierToken myParameter2 = IdentifierToken.create("MyParameter2", Position.create("", 1, 1, 0));
361 		final IdentifierToken string = IdentifierToken.create("String", Position.create("", 1, 1, 0));
362 		final IdentifierToken integer = IdentifierToken.create("Integer", Position.create("", 1, 1, 0));
363 		this.stream.add(myGroup);
364 		this.stream.add(this.colonToken);
365 		this.stream.add(this.groupToken);
366 		this.stream.add(this.equalToken);
367 		this.stream.add(this.squareBracketOpenToken);
368 		this.stream.add(myClass);
369 		this.stream.add(this.colonToken);
370 		this.stream.add(this.classToken);
371 		this.stream.add(this.equalToken);
372 		this.stream.add(this.curlyBracketOpenToken);
373 		this.stream.add(myOperation);
374 		this.stream.add(this.colonToken);
375 		this.stream.add(this.doubleSquareBracketOpenToken);
376 		this.stream.add(this.bracketOpenToken);
377 		this.stream.add(myParameter1);
378 		this.stream.add(this.colonToken);
379 		this.stream.add(string);
380 		this.stream.add(this.commaToken);
381 		this.stream.add(myParameter2);
382 		this.stream.add(this.colonToken);
383 		this.stream.add(integer);
384 		this.stream.add(this.bracketCloseToken);
385 		this.stream.add(this.arrowToken);
386 		this.stream.add(this.curlyBracketOpenToken);
387 		this.stream.add(this.curlyBracketCloseToken);
388 		this.stream.add(this.doubleSquareBracketCloseToken);
389 		this.stream.add(this.semicolonToken);
390 		this.stream.add(this.curlyBracketCloseToken);
391 		this.stream.add(this.semicolonToken);
392 		this.stream.add(this.squareBracketCloseToken);
393 		this.stream.add(this.semicolonToken);
394 		this.stream.add(this.endToken);
395 		
396 		final Vector<GroupElement> groupVector = new Vector<>();
397 		final Vector<Operation> operations = new Vector<>();
398 		
399 		final Name groupName = UnqualifiedName.create(myGroup);
400 		final Group group = Group.create(groupName, groupVector, myGroup);
401 		
402 		final Name className = groupName.addName(myClass);
403 		final ClassType class1 =
404 				RegularClassType.create(
405 						className,
406 						new Vector<ClassModifier>(),
407 						new Vector<Attribute>(),
408 						new Vector<Type>(),
409 						operations,
410 						new Vector<Constructor>(),
411 						myClass,
412 						
413 						new Vector<ClassType>());
414 		groupVector.add(class1);
415 		
416 		final ProductType product = ProductType.create(this.bracketOpenToken);
417 		final ByNameState byNameString = ByNameState.create(UnqualifiedName.create(string));
418 		final TypeProxy typeProxyString = TypeProxy.create(string, byNameString);
419 		final ProductElementType element1 = ProductElementType.create("MyParameter1", typeProxyString, myParameter1);
420 		product.addElement(element1);
421 		
422 		final ByNameState byNameInteger = ByNameState.create(UnqualifiedName.create(integer));
423 		final TypeProxy typeProxyInteger = TypeProxy.create(string, byNameInteger);
424 		final ProductElementType element2 = ProductElementType.create("MyParameter2", typeProxyInteger, myParameter2);
425 		product.addElement(element2);
426 		
427 		final SumType sum = SumType.create(this.curlyBracketOpenToken);
428 		final Operation operation =
429 				Operation.create("MyOperation", new Vector<OperationModifier>(), product, class1, sum, myOperation);
430 		operations.add(operation);
431 		
432 		final Model expected = Model.create(myGroup);
433 		expected.addGroup(group);
434 		
435 		final Model actual = this.parser.parse();
436 		assertEquals(expected, actual);
437 		assertEquals(0, this.parser.getExceptions().size());
438 		
439 	}
440 	
441 	/**
442 	 * MyExceptionGroup:group=[MyException:exception={};]; MyGroup:group=[MyClass
443 	 * :class={operation:[[()->{MyExceptionGroup>MyException}]];};];.
444 	 * 
445 	 * @throws Exception
446 	 *             {@link de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException}
447 	 */
448 	@Test
449 	public void testOperationWithException() throws Exception {
450 		final IdentifierToken myGroup = IdentifierToken.create("MyGroup", Position.create("", 1, 1, 0));
451 		final IdentifierToken myClass = IdentifierToken.create("MyClass", Position.create("", 1, 1, 0));
452 		final IdentifierToken myExceptionGroup =
453 				IdentifierToken.create("MyExceptionGroup", Position.create("", 1, 1, 0));
454 		final IdentifierToken myException = IdentifierToken.create("MyException", Position.create("", 1, 1, 0));
455 		final IdentifierToken myOperation = IdentifierToken.create("MyOperation", Position.create("", 1, 1, 0));
456 		final ExceptionToken exception = ExceptionToken.create(Position.create("", 1, 1, 0));
457 		
458 		this.stream.add(myExceptionGroup);
459 		this.stream.add(this.colonToken);
460 		this.stream.add(this.groupToken);
461 		this.stream.add(this.equalToken);
462 		this.stream.add(this.squareBracketOpenToken);
463 		this.stream.add(myException);
464 		this.stream.add(this.colonToken);
465 		this.stream.add(exception);
466 		this.stream.add(this.equalToken);
467 		this.stream.add(this.curlyBracketOpenToken);
468 		this.stream.add(this.curlyBracketCloseToken);
469 		this.stream.add(this.semicolonToken);
470 		this.stream.add(this.squareBracketCloseToken);
471 		this.stream.add(this.semicolonToken);
472 		this.stream.add(myGroup);
473 		this.stream.add(this.colonToken);
474 		this.stream.add(this.groupToken);
475 		this.stream.add(this.equalToken);
476 		this.stream.add(this.squareBracketOpenToken);
477 		this.stream.add(myClass);
478 		this.stream.add(this.colonToken);
479 		this.stream.add(this.classToken);
480 		this.stream.add(this.equalToken);
481 		this.stream.add(this.curlyBracketOpenToken);
482 		this.stream.add(myOperation);
483 		this.stream.add(this.colonToken);
484 		this.stream.add(this.doubleSquareBracketOpenToken);
485 		this.stream.add(this.bracketOpenToken);
486 		this.stream.add(this.bracketCloseToken);
487 		this.stream.add(this.arrowToken);
488 		this.stream.add(this.curlyBracketOpenToken);
489 		this.stream.add(myExceptionGroup);
490 		this.stream.add(this.greaterSymbolToken);
491 		this.stream.add(myException);
492 		this.stream.add(this.curlyBracketCloseToken);
493 		this.stream.add(this.doubleSquareBracketCloseToken);
494 		this.stream.add(this.semicolonToken);
495 		this.stream.add(this.curlyBracketCloseToken);
496 		this.stream.add(this.semicolonToken);
497 		this.stream.add(this.squareBracketCloseToken);
498 		this.stream.add(this.semicolonToken);
499 		this.stream.add(this.endToken);
500 		
501 		// --------------------------- MyExceptionGroup
502 		// -------------------------------------------------------//
503 		final Vector<GroupElement> exceptionGroupVector = new Vector<>();
504 		final Name exceptionGroupName = UnqualifiedName.create(myExceptionGroup);
505 		final Group exceptionGroup = Group.create(exceptionGroupName, exceptionGroupVector, myExceptionGroup);
506 		
507 		final Name exceptionClassName = exceptionGroupName.addName(myException);
508 		final ClassType exceptionClass =
509 				ExceptionClassType.create(
510 						exceptionClassName,
511 						new Vector<ClassModifier>(),
512 						new Vector<Attribute>(),
513 						new Vector<Type>(),
514 						new Vector<Operation>(),
515 						new Vector<Constructor>(),
516 						myException,
517 						new Vector<ClassType>());
518 		exceptionGroupVector.add(exceptionClass);
519 		
520 		// ---------------------------- MyGroup
521 		// -------------------------------------------------------------//
522 		final Vector<GroupElement> groupVector = new Vector<>();
523 		final Vector<Operation> operations = new Vector<>();
524 		
525 		final Name groupName = UnqualifiedName.create(myGroup);
526 		final Group group = Group.create(groupName, groupVector, myGroup);
527 		
528 		final Name className = groupName.addName(myClass);
529 		final ClassType class1 =
530 				RegularClassType.create(
531 						className,
532 						new Vector<ClassModifier>(),
533 						new Vector<Attribute>(),
534 						new Vector<Type>(),
535 						operations,
536 						new Vector<Constructor>(),
537 						myClass,
538 						
539 						new Vector<ClassType>());
540 		groupVector.add(class1);
541 		
542 		// ------------------------------- empty Product
543 		// --------------------------------------------------//
544 		final ProductType product = ProductType.create(this.bracketOpenToken);
545 		
546 		// ------------------------------- Sum
547 		// ---------------------------------------------------------------//
548 		final SumType sum = SumType.create(this.curlyBracketOpenToken);
549 		final ByNameState byNameExceptionClass = ByNameState.create(exceptionClassName);
550 		final TypeProxy exceptionClassProxy = TypeProxy.create(myException, byNameExceptionClass);
551 		sum.add(exceptionClassProxy);
552 		
553 		// ------------------------------------- Operation
554 		// --------------------------------------------------------//
555 		final Operation operation =
556 				Operation.create("MyOperation", new Vector<OperationModifier>(), product, class1, sum, myOperation);
557 		operations.add(operation);
558 		
559 		final Model expected = Model.create(myExceptionGroup);
560 		expected.addGroup(exceptionGroup);
561 		expected.addGroup(group);
562 		
563 		final Model actual = this.parser.parse();
564 		assertEquals(expected, actual);
565 		
566 		assertEquals(0, this.parser.getExceptions().size());
567 		
568 	}
569 	
570 	/**
571 	 * MyGroup:group=[MyClass:class={MyOperation:[[()->String]];};];.
572 	 * 
573 	 * @throws Exception
574 	 *             {@link de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException}
575 	 */
576 	@Test
577 	public void testOperationWithOneOutputParameter() throws Exception {
578 		final IdentifierToken myGroup = IdentifierToken.create("MyGroup", Position.create("", 1, 1, 0));
579 		final IdentifierToken myClass = IdentifierToken.create("MyClass", Position.create("", 1, 1, 0));
580 		final IdentifierToken myOperation = IdentifierToken.create("MyOperation", Position.create("", 1, 1, 0));
581 		final IdentifierToken string = IdentifierToken.create("String", Position.create("", 1, 1, 0));
582 		
583 		this.stream.add(myGroup);
584 		this.stream.add(this.colonToken);
585 		this.stream.add(this.groupToken);
586 		this.stream.add(this.equalToken);
587 		this.stream.add(this.squareBracketOpenToken);
588 		this.stream.add(myClass);
589 		this.stream.add(this.colonToken);
590 		this.stream.add(this.classToken);
591 		this.stream.add(this.equalToken);
592 		this.stream.add(this.curlyBracketOpenToken);
593 		this.stream.add(myOperation);
594 		this.stream.add(this.colonToken);
595 		this.stream.add(this.doubleSquareBracketOpenToken);
596 		this.stream.add(this.bracketOpenToken);
597 		this.stream.add(this.bracketCloseToken);
598 		this.stream.add(this.arrowToken);
599 		this.stream.add(string);
600 		this.stream.add(this.doubleSquareBracketCloseToken);
601 		this.stream.add(this.semicolonToken);
602 		this.stream.add(this.curlyBracketCloseToken);
603 		this.stream.add(this.semicolonToken);
604 		this.stream.add(this.squareBracketCloseToken);
605 		this.stream.add(this.semicolonToken);
606 		this.stream.add(this.endToken);
607 		
608 		// ---------------------------- MyGroup
609 		// -------------------------------------------------------------//
610 		final Vector<GroupElement> groupVector = new Vector<>();
611 		final Vector<Operation> operations = new Vector<>();
612 		
613 		final Name groupName = UnqualifiedName.create(myGroup);
614 		final Group group = Group.create(groupName, groupVector, myGroup);
615 		
616 		final Name className = groupName.addName(myClass);
617 		final ClassType class1 =
618 				RegularClassType.create(
619 						className,
620 						new Vector<ClassModifier>(),
621 						new Vector<Attribute>(),
622 						new Vector<Type>(),
623 						operations,
624 						new Vector<Constructor>(),
625 						myClass,
626 						
627 						new Vector<ClassType>());
628 		groupVector.add(class1);
629 		
630 		// ------------------------------- empty Product
631 		// --------------------------------------------------//
632 		final ProductType product = ProductType.create(this.bracketOpenToken);
633 		final ByNameState byNameString = ByNameState.create(UnqualifiedName.create(string));
634 		final TypeProxy stringTypeProxy = TypeProxy.create(string, byNameString);
635 		
636 		// ------------------------------------- Operation
637 		// --------------------------------------------------------//
638 		final Operation operation =
639 				Operation.create(
640 						"MyOperation",
641 						new Vector<OperationModifier>(),
642 						product,
643 						class1,
644 						stringTypeProxy,
645 						myOperation);
646 		operations.add(operation);
647 		
648 		final Model expected = Model.create(myGroup);
649 		expected.addGroup(group);
650 		
651 		final Model actual = this.parser.parse();
652 		assertEquals(expected, actual);
653 		
654 		assertEquals(0, this.parser.getExceptions().size());
655 	}
656 	
657 	/**
658 	 * MyGroup:group=[MyClass:class={MyOperation:[[(MyParameter:Integer)->String ]] abstract;};];.
659 	 * 
660 	 * @throws Exception
661 	 *             {@link de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException}
662 	 */
663 	@Test
664 	public void testOperationWithParameterAndOutputParameterModifier() throws Exception {
665 		final IdentifierToken myGroup = IdentifierToken.create("MyGroup", Position.create("", 1, 1, 0));
666 		final IdentifierToken myClass = IdentifierToken.create("MyClass", Position.create("", 1, 1, 0));
667 		final IdentifierToken myOperation = IdentifierToken.create("MyOperation", Position.create("", 1, 1, 0));
668 		final IdentifierToken myParameter = IdentifierToken.create("MyParameter", Position.create("", 1, 1, 0));
669 		final IdentifierToken string = IdentifierToken.create("String", Position.create("", 1, 1, 0));
670 		final IdentifierToken integer = IdentifierToken.create("Integer", Position.create("", 1, 1, 0));
671 		
672 		this.stream.add(myGroup);
673 		this.stream.add(this.colonToken);
674 		this.stream.add(this.groupToken);
675 		this.stream.add(this.equalToken);
676 		this.stream.add(this.squareBracketOpenToken);
677 		this.stream.add(myClass);
678 		this.stream.add(this.colonToken);
679 		this.stream.add(this.classToken);
680 		this.stream.add(this.equalToken);
681 		this.stream.add(this.curlyBracketOpenToken);
682 		this.stream.add(myOperation);
683 		this.stream.add(this.colonToken);
684 		this.stream.add(this.doubleSquareBracketOpenToken);
685 		this.stream.add(this.bracketOpenToken);
686 		this.stream.add(myParameter);
687 		this.stream.add(this.colonToken);
688 		this.stream.add(integer);
689 		this.stream.add(this.bracketCloseToken);
690 		this.stream.add(this.arrowToken);
691 		this.stream.add(string);
692 		this.stream.add(this.doubleSquareBracketCloseToken);
693 		this.stream.add(this.abstractToken);
694 		this.stream.add(this.semicolonToken);
695 		this.stream.add(this.curlyBracketCloseToken);
696 		this.stream.add(this.semicolonToken);
697 		this.stream.add(this.squareBracketCloseToken);
698 		this.stream.add(this.semicolonToken);
699 		this.stream.add(this.endToken);
700 		
701 		// ---------------------------- MyGroup
702 		// -------------------------------------------------------------//
703 		final Vector<GroupElement> groupVector = new Vector<>();
704 		final Vector<Operation> operations = new Vector<>();
705 		final Vector<OperationModifier> operationModifiers = new Vector<>();
706 		
707 		final Name groupName = UnqualifiedName.create(myGroup);
708 		final Group group = Group.create(groupName, groupVector, myGroup);
709 		
710 		final Name className = groupName.addName(myClass);
711 		final ClassType class1 =
712 				RegularClassType.create(
713 						className,
714 						new Vector<ClassModifier>(),
715 						new Vector<Attribute>(),
716 						new Vector<Type>(),
717 						operations,
718 						new Vector<Constructor>(),
719 						myClass,
720 						
721 						new Vector<ClassType>());
722 		groupVector.add(class1);
723 		
724 		// ------------------------------- Product
725 		// --------------------------------------------------//
726 		final ProductType prod = ProductType.create(this.bracketOpenToken);
727 		final ByNameState byNameInteger = ByNameState.create(UnqualifiedName.create(integer));
728 		final TypeProxy typeProxyInteger = TypeProxy.create(integer, byNameInteger);
729 		final ProductElementType element = ProductElementType.create("MyParameter", typeProxyInteger, myParameter);
730 		prod.addElement(element);
731 		
732 		final ByNameState byNameString = ByNameState.create(UnqualifiedName.create(string));
733 		final TypeProxy typeProxyString = TypeProxy.create(integer, byNameString);
734 		
735 		// ------------------------------------- Operation
736 		// --------------------------------------------------------//
737 		operationModifiers.add(OperationModifierAbstract.create(this.abstractToken));
738 		final Operation operation =
739 				Operation.create("MyOperation", operationModifiers, prod, class1, typeProxyString, myOperation);
740 		operations.add(operation);
741 		
742 		final Model expected = Model.create(myGroup);
743 		expected.addGroup(group);
744 		
745 		final Model actual = this.parser.parse();
746 		assertEquals(expected, actual);
747 		
748 		assertEquals(0, this.parser.getExceptions().size());
749 	}
750 	
751 	/**
752 	 * MyOperation:[[()->{}];};]] abstract;.
753 	 */
754 	@Test
755 	public void testAbstractOperation() {
756 		final IdentifierToken abs = IdentifierToken.create("abstract", Position.create("", 1, 1, 0));
757 		final IdentifierToken myOperation = IdentifierToken.create("MyOperation", Position.create("", 1, 1, 0));
758 		
759 		final ProductType product = ProductType.create(this.bracketOpenToken);
760 		final SumType sum = SumType.create(this.curlyBracketOpenToken);
761 		final Vector<OperationModifier> modifiers = new Vector<>();
762 		modifiers.addElement(OperationModifierAbstract.create(abs));
763 		
764 		final Operation operation = Operation.create("MyOperation", modifiers, product, null, sum, myOperation);
765 		
766 		assertTrue(operation.isAbstract());
767 	}
768 	
769 	/**
770 	 * MyOperation:[[()->{}];};]] abstract;.
771 	 */
772 	@Test
773 	public void testOperationHashCode() {
774 		final IdentifierToken abs = IdentifierToken.create("abstract", Position.create("", 1, 1, 0));
775 		final IdentifierToken myOperation = IdentifierToken.create("MyOperation", Position.create("", 1, 1, 0));
776 		
777 		final ProductType product = ProductType.create(this.bracketOpenToken);
778 		final SumType sum = SumType.create(this.curlyBracketOpenToken);
779 		final Vector<OperationModifier> modifiers1 = new Vector<>();
780 		modifiers1.addElement(OperationModifierAbstract.create(abs));
781 		final Operation operation1 = Operation.create("MyOperation", modifiers1, product, null, sum, myOperation);
782 		
783 		final Vector<OperationModifier> modifiers2 = new Vector<>();
784 		modifiers2.addElement(OperationModifierAbstract.create(abs));
785 		final Operation operation2 = Operation.create("MyOperation", modifiers2, product, null, sum, myOperation);
786 		
787 		assertEquals(operation1, operation2);
788 		assertEquals(operation1.hashCode(), operation2.hashCode());
789 	}
790 	
791 	/**
792 	 * MyGroup:group=[MyClass:class={MyOperation:[[() -> {}]] abstract;};];.
793 	 * 
794 	 * @throws Exception
795 	 *             {@link de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException}
796 	 */
797 	@Test
798 	public void testOperationToString() throws Exception {
799 		final IdentifierToken myGroup = IdentifierToken.create("MyGroup", Position.create("", 1, 1, 0));
800 		final IdentifierToken myClass = IdentifierToken.create("MyClass", Position.create("", 1, 1, 0));
801 		final IdentifierToken myOperation = IdentifierToken.create("MyOperation", Position.create("", 1, 1, 0));
802 		this.stream.add(myGroup);
803 		this.stream.add(this.colonToken);
804 		this.stream.add(this.groupToken);
805 		this.stream.add(this.equalToken);
806 		this.stream.add(this.squareBracketOpenToken);
807 		this.stream.add(myClass);
808 		this.stream.add(this.colonToken);
809 		this.stream.add(this.classToken);
810 		this.stream.add(this.equalToken);
811 		this.stream.add(this.curlyBracketOpenToken);
812 		this.stream.add(myOperation);
813 		this.stream.add(this.colonToken);
814 		this.stream.add(this.doubleSquareBracketOpenToken);
815 		this.stream.add(this.bracketOpenToken);
816 		this.stream.add(this.bracketCloseToken);
817 		this.stream.add(this.arrowToken);
818 		this.stream.add(this.curlyBracketOpenToken);
819 		this.stream.add(this.curlyBracketCloseToken);
820 		this.stream.add(this.doubleSquareBracketCloseToken);
821 		this.stream.add(this.abstractToken);
822 		this.stream.add(this.semicolonToken);
823 		this.stream.add(this.curlyBracketCloseToken);
824 		this.stream.add(this.semicolonToken);
825 		this.stream.add(this.squareBracketCloseToken);
826 		this.stream.add(this.semicolonToken);
827 		this.stream.add(this.endToken);
828 		
829 		final String expected =
830 				"Model: \n" + "MyGroup:group=[ \n" + "MyGroup>MyClass:class={ \n"
831 						+ "MyOperation:[[()->{}]] abstract; \n" + "}; \n" + "]; \n";
832 		
833 		final Model model = this.parser.parse();
834 		assertEquals(expected, model.toString());
835 	}
836 	
837 	/**
838 	 * MyGroup:group=[MyClass:class={MyOperation:[[()->TestException!]];};TestException:exception={};];.
839 	 * 
840 	 * @throws Exception
841 	 *             {@link de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException}
842 	 */
843 	@Test
844 	public void testOperationWithoutReturnButThrow() throws Exception {
845 		
846 		final IdentifierToken myGroupToken = IdentifierToken.create("MyGroup", Position.create("", 1, 1, 1));
847 		final IdentifierToken myClassToken = IdentifierToken.create("MyClass", Position.create("", 1, 16, 16));
848 		final IdentifierToken myOperationToken = IdentifierToken.create("MyOperation", Position.create("", 1, 31, 31));
849 		final IdentifierToken testExceptionReferenceToken =
850 				IdentifierToken.create("TestException", Position.create("", 1, 49, 49));
851 		final IdentifierToken testExceptionToken =
852 				IdentifierToken.create("TestException", Position.create("", 1, 68, 68));
853 		
854 		this.stream.add(myGroupToken);
855 		this.stream.add(ColonToken.create(Position.create("", 1, 8, 8)));
856 		this.stream.add(GroupToken.create(Position.create("", 1, 9, 9)));
857 		this.stream.add(EqualToken.create(Position.create("", 1, 14, 14)));
858 		this.stream.add(SquareBracketOpenToken.create(Position.create("", 1, 15, 15)));
859 		this.stream.add(myClassToken);
860 		this.stream.add(ColonToken.create(Position.create("", 1, 23, 23)));
861 		this.stream.add(ClassToken.create(Position.create("", 1, 24, 24)));
862 		this.stream.add(EqualToken.create(Position.create("", 1, 29, 29)));
863 		this.stream.add(CurlyBracketOpenToken.create(Position.create("", 1, 30, 30)));
864 		this.stream.add(myOperationToken);
865 		this.stream.add(ColonToken.create(Position.create("", 1, 42, 42)));
866 		this.stream.add(DoubleSquareBracketOpenToken.create(Position.create("", 1, 43, 43)));
867 		this.stream.add(BracketOpenToken.create(Position.create("", 1, 45, 45)));
868 		this.stream.add(BracketCloseToken.create(Position.create("", 1, 46, 46)));
869 		this.stream.add(ArrowToken.create(Position.create("", 1, 47, 47)));
870 		this.stream.add(testExceptionReferenceToken);
871 		this.stream.add(ExclamationToken.create(Position.create("", 1, 62, 62)));
872 		this.stream.add(DoubleSquareBracketCloseToken.create(Position.create("", 1, 63, 63)));
873 		this.stream.add(SemicolonToken.create(Position.create("", 1, 65, 65)));
874 		this.stream.add(CurlyBracketCloseToken.create(Position.create("", 1, 66, 66)));
875 		this.stream.add(SemicolonToken.create(Position.create("", 1, 67, 67)));
876 		this.stream.add(testExceptionToken);
877 		this.stream.add(ColonToken.create(Position.create("", 1, 81, 81)));
878 		this.stream.add(ExceptionToken.create(Position.create("", 1, 82, 82)));
879 		this.stream.add(EqualToken.create(Position.create("", 1, 91, 91)));
880 		this.stream.add(CurlyBracketOpenToken.create(Position.create("", 1, 92, 92)));
881 		this.stream.add(CurlyBracketCloseToken.create(Position.create("", 1, 93, 93)));
882 		this.stream.add(SemicolonToken.create(Position.create("", 1, 94, 94)));
883 		this.stream.add(SquareBracketCloseToken.create(Position.create("", 1, 95, 95)));
884 		this.stream.add(SemicolonToken.create(Position.create("", 1, 96, 96)));
885 		this.stream.add(EndToken.create(Position.create("", 1, 97, 97)));
886 		
887 		// ---------------------------- MyGroup
888 		// -------------------------------------------------------------//
889 		final Vector<GroupElement> groupVector = new Vector<>();
890 		final Vector<Operation> operations = new Vector<>();
891 		final Vector<OperationModifier> operationModifiers = new Vector<>();
892 		
893 		final Name groupName = UnqualifiedName.create(myGroupToken);
894 		final Group group = Group.create(groupName, groupVector, myGroupToken);
895 		
896 		final Name className = groupName.addName(myClassToken);
897 		final ClassType class1 =
898 				RegularClassType.create(
899 						className,
900 						new Vector<ClassModifier>(),
901 						new Vector<Attribute>(),
902 						new Vector<Type>(),
903 						operations,
904 						new Vector<Constructor>(),
905 						myClassToken,
906 						new Vector<ClassType>());
907 		groupVector.add(class1);
908 		
909 		final Name exceptionName = groupName.addName(testExceptionToken);
910 		final ClassType exception1 =
911 				ExceptionClassType.create(
912 						exceptionName,
913 						new Vector<ClassModifier>(),
914 						new Vector<Attribute>(),
915 						new Vector<Type>(),
916 						new Vector<Operation>(),
917 						new Vector<Constructor>(),
918 						testExceptionToken,
919 						new Vector<ClassType>());
920 		groupVector.add(exception1);
921 		
922 		// -------------------------------------
923 		// --------------------------------------------------------//
924 		final ProductType product = ProductType.create(this.bracketOpenToken);
925 		final ByNameState byNameString = ByNameState.create(UnqualifiedName.create(testExceptionReferenceToken));
926 		final TypeProxy exceptionTypeProxy = TypeProxy.create(testExceptionReferenceToken, byNameString);
927 		final ThrownType thrownType =
928 				ThrownType.create(
929 						exceptionTypeProxy.getFirstToken(),
930 						exceptionTypeProxy,
931 						exceptionTypeProxy.getLastToken());
932 		
933 		// ------------------------------------- Operation
934 		// --------------------------------------------------------//
935 		final Operation operation =
936 				Operation.create("MyOperation", operationModifiers, product, class1, thrownType, myOperationToken);
937 		operations.add(operation);
938 		
939 		final Model expected = Model.create(myGroupToken);
940 		expected.addGroup(group);
941 		
942 		final Model actual = this.parser.parse();
943 		assertEquals(expected, actual);
944 		
945 		assertEquals(0, this.parser.getExceptions().size());
946 	}
947 	
948 	/**
949 	 * MyGroup:group=[MyClass:class={MyOperation:[[()->{TestException}!]];};TestException:exception={};];.
950 	 * 
951 	 * @throws Exception
952 	 *             {@link de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException}
953 	 */
954 	@Test
955 	public void testOperationWithoutReturnButThrowSumOfException() throws Exception {
956 		
957 		final IdentifierToken myGroupToken = IdentifierToken.create("MyGroup", Position.create("", 1, 1, 1));
958 		final IdentifierToken myClassToken = IdentifierToken.create("MyClass", Position.create("", 1, 16, 16));
959 		final IdentifierToken myOperationToken = IdentifierToken.create("MyOperation", Position.create("", 1, 31, 31));
960 		final IdentifierToken testExceptionReferenceToken =
961 				IdentifierToken.create("TestException", Position.create("", 1, 50, 50));
962 		final IdentifierToken testExceptionToken =
963 				IdentifierToken.create("TestException", Position.create("", 1, 70, 70));
964 		final CurlyBracketOpenToken sumTypeStart = CurlyBracketOpenToken.create(Position.create("", 1, 49, 49));
965 		
966 		this.stream.add(myGroupToken);
967 		this.stream.add(ColonToken.create(Position.create("", 1, 8, 8)));
968 		this.stream.add(GroupToken.create(Position.create("", 1, 9, 9)));
969 		this.stream.add(EqualToken.create(Position.create("", 1, 14, 14)));
970 		this.stream.add(SquareBracketOpenToken.create(Position.create("", 1, 15, 15)));
971 		this.stream.add(myClassToken);
972 		this.stream.add(ColonToken.create(Position.create("", 1, 23, 23)));
973 		this.stream.add(ClassToken.create(Position.create("", 1, 24, 24)));
974 		this.stream.add(EqualToken.create(Position.create("", 1, 29, 29)));
975 		this.stream.add(CurlyBracketOpenToken.create(Position.create("", 1, 30, 30)));
976 		this.stream.add(myOperationToken);
977 		this.stream.add(ColonToken.create(Position.create("", 1, 42, 42)));
978 		this.stream.add(DoubleSquareBracketOpenToken.create(Position.create("", 1, 43, 43)));
979 		this.stream.add(BracketOpenToken.create(Position.create("", 1, 45, 45)));
980 		this.stream.add(BracketCloseToken.create(Position.create("", 1, 46, 46)));
981 		this.stream.add(ArrowToken.create(Position.create("", 1, 47, 47)));
982 		this.stream.add(sumTypeStart);
983 		this.stream.add(testExceptionReferenceToken);
984 		this.stream.add(CurlyBracketCloseToken.create(Position.create("", 1, 63, 63)));
985 		this.stream.add(ExclamationToken.create(Position.create("", 1, 64, 64)));
986 		this.stream.add(DoubleSquareBracketCloseToken.create(Position.create("", 1, 65, 65)));
987 		this.stream.add(SemicolonToken.create(Position.create("", 1, 67, 67)));
988 		this.stream.add(CurlyBracketCloseToken.create(Position.create("", 1, 68, 68)));
989 		this.stream.add(SemicolonToken.create(Position.create("", 1, 69, 69)));
990 		this.stream.add(testExceptionToken);
991 		this.stream.add(ColonToken.create(Position.create("", 1, 83, 83)));
992 		this.stream.add(ExceptionToken.create(Position.create("", 1, 84, 84)));
993 		this.stream.add(EqualToken.create(Position.create("", 1, 93, 93)));
994 		this.stream.add(CurlyBracketOpenToken.create(Position.create("", 1, 94, 94)));
995 		this.stream.add(CurlyBracketCloseToken.create(Position.create("", 1, 95, 95)));
996 		this.stream.add(SemicolonToken.create(Position.create("", 1, 96, 96)));
997 		this.stream.add(SquareBracketCloseToken.create(Position.create("", 1, 97, 97)));
998 		this.stream.add(SemicolonToken.create(Position.create("", 1, 98, 98)));
999 		this.stream.add(EndToken.create(Position.create("", 1, 99, 99)));
1000 		
1001 		// ---------------------------- MyGroup
1002 		// -------------------------------------------------------------//
1003 		final Vector<GroupElement> groupVector = new Vector<>();
1004 		final Vector<Operation> operations = new Vector<>();
1005 		final Vector<OperationModifier> operationModifiers = new Vector<>();
1006 		
1007 		final Name groupName = UnqualifiedName.create(myGroupToken);
1008 		final Group group = Group.create(groupName, groupVector, myGroupToken);
1009 		
1010 		final Name className = groupName.addName(myClassToken);
1011 		final ClassType class1 =
1012 				RegularClassType.create(
1013 						className,
1014 						new Vector<ClassModifier>(),
1015 						new Vector<Attribute>(),
1016 						new Vector<Type>(),
1017 						operations,
1018 						new Vector<Constructor>(),
1019 						myClassToken,
1020 						new Vector<ClassType>());
1021 		groupVector.add(class1);
1022 		
1023 		final Name exceptionName = groupName.addName(testExceptionToken);
1024 		final ClassType exception1 =
1025 				ExceptionClassType.create(
1026 						exceptionName,
1027 						new Vector<ClassModifier>(),
1028 						new Vector<Attribute>(),
1029 						new Vector<Type>(),
1030 						new Vector<Operation>(),
1031 						new Vector<Constructor>(),
1032 						testExceptionToken,
1033 						new Vector<ClassType>());
1034 		groupVector.add(exception1);
1035 		
1036 		// -------------------------------------
1037 		// --------------------------------------------------------//
1038 		final ProductType product = ProductType.create(this.bracketOpenToken);
1039 		final SumType sum = SumType.create(sumTypeStart);
1040 		final ByNameState byNameString = ByNameState.create(UnqualifiedName.create(testExceptionReferenceToken));
1041 		final TypeProxy exceptionTypeProxy = TypeProxy.create(testExceptionReferenceToken, byNameString);
1042 		sum.add(exceptionTypeProxy);
1043 		final ThrownType thrownType = ThrownType.create(sum.getFirstToken(), sum, sum.getLastToken());
1044 		
1045 		// ------------------------------------- Operation
1046 		// --------------------------------------------------------//
1047 		final Operation operation =
1048 				Operation.create("MyOperation", operationModifiers, product, class1, thrownType, myOperationToken);
1049 		operations.add(operation);
1050 		
1051 		final Model expected = Model.create(myGroupToken);
1052 		expected.addGroup(group);
1053 		
1054 		final Model actual = this.parser.parse();
1055 		assertEquals(expected, actual);
1056 		
1057 		assertEquals(0, this.parser.getExceptions().size());
1058 	}
1059 	
1060 	/**
1061 	 * MyGroup:group=[MyClass:class={MyOperation:[[()->(a:Integer)!]];};];.
1062 	 * 
1063 	 * @throws Exception
1064 	 *             {@link de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException}
1065 	 */
1066 	@Test
1067 	public void testOperationReturnAProductThatShouldBeThrown() throws Exception {
1068 		
1069 		final IdentifierToken myGroupToken = IdentifierToken.create("MyGroup", Position.create("", 1, 1, 1));
1070 		final IdentifierToken myClassToken = IdentifierToken.create("MyClass", Position.create("", 1, 16, 16));
1071 		final IdentifierToken myOperationToken = IdentifierToken.create("MyOperation", Position.create("", 1, 31, 31));
1072 		
1073 		this.stream.add(myGroupToken);
1074 		this.stream.add(ColonToken.create(Position.create("", 1, 8, 8)));
1075 		this.stream.add(GroupToken.create(Position.create("", 1, 9, 9)));
1076 		this.stream.add(EqualToken.create(Position.create("", 1, 14, 14)));
1077 		this.stream.add(SquareBracketOpenToken.create(Position.create("", 1, 15, 15)));
1078 		this.stream.add(myClassToken);
1079 		this.stream.add(ColonToken.create(Position.create("", 1, 23, 23)));
1080 		this.stream.add(ClassToken.create(Position.create("", 1, 24, 24)));
1081 		this.stream.add(EqualToken.create(Position.create("", 1, 29, 29)));
1082 		this.stream.add(CurlyBracketOpenToken.create(Position.create("", 1, 30, 30)));
1083 		this.stream.add(myOperationToken);
1084 		this.stream.add(ColonToken.create(Position.create("", 1, 42, 42)));
1085 		this.stream.add(DoubleSquareBracketOpenToken.create(Position.create("", 1, 43, 43)));
1086 		this.stream.add(BracketOpenToken.create(Position.create("", 1, 45, 45)));
1087 		this.stream.add(BracketCloseToken.create(Position.create("", 1, 46, 46)));
1088 		this.stream.add(ArrowToken.create(Position.create("", 1, 47, 47)));
1089 		this.stream.add(BracketOpenToken.create(Position.create("", 1, 49, 49)));
1090 		this.stream.add(IdentifierToken.create("a", Position.create("", 1, 50, 50)));
1091 		this.stream.add(ColonToken.create(Position.create("", 1, 51, 51)));
1092 		this.stream.add(IdentifierToken.create("Integer", Position.create("", 1, 52, 52)));
1093 		this.stream.add(BracketCloseToken.create(Position.create("", 1, 59, 59)));
1094 		this.stream.add(ExclamationToken.create(Position.create("", 1, 60, 60)));
1095 		this.stream.add(DoubleSquareBracketCloseToken.create(Position.create("", 1, 61, 61)));
1096 		this.stream.add(SemicolonToken.create(Position.create("", 1, 63, 63)));
1097 		this.stream.add(CurlyBracketCloseToken.create(Position.create("", 1, 64, 64)));
1098 		this.stream.add(SemicolonToken.create(Position.create("", 1, 65, 65)));
1099 		this.stream.add(SquareBracketCloseToken.create(Position.create("", 1, 66, 66)));
1100 		this.stream.add(SemicolonToken.create(Position.create("", 1, 67, 67)));
1101 		this.stream.add(EndToken.create(Position.create("", 1, 68, 68)));
1102 		
1103 		try {
1104 			this.parser.parse();
1105 		} catch (final NoValidTokenStreamException e) {
1106 			assertTrue(true);
1107 		}
1108 	}
1109 	
1110 	/**
1111 	 * MyGroup:group=[MyClass:class={MyOperation:[[()->String*!]];};];.
1112 	 * 
1113 	 * @throws Exception
1114 	 *             {@link de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException}
1115 	 */
1116 	@Test
1117 	public void testOperationReturnAListThatShouldBeThrown() throws Exception {
1118 		
1119 		final IdentifierToken myGroupToken = IdentifierToken.create("MyGroup", Position.create("", 1, 1, 1));
1120 		final IdentifierToken myClassToken = IdentifierToken.create("MyClass", Position.create("", 1, 16, 16));
1121 		final IdentifierToken myOperationToken = IdentifierToken.create("MyOperation", Position.create("", 1, 31, 31));
1122 		
1123 		this.stream.add(myGroupToken);
1124 		this.stream.add(ColonToken.create(Position.create("", 1, 8, 8)));
1125 		this.stream.add(GroupToken.create(Position.create("", 1, 9, 9)));
1126 		this.stream.add(EqualToken.create(Position.create("", 1, 14, 14)));
1127 		this.stream.add(SquareBracketOpenToken.create(Position.create("", 1, 15, 15)));
1128 		this.stream.add(myClassToken);
1129 		this.stream.add(ColonToken.create(Position.create("", 1, 23, 23)));
1130 		this.stream.add(ClassToken.create(Position.create("", 1, 24, 24)));
1131 		this.stream.add(EqualToken.create(Position.create("", 1, 29, 29)));
1132 		this.stream.add(CurlyBracketOpenToken.create(Position.create("", 1, 30, 30)));
1133 		this.stream.add(myOperationToken);
1134 		this.stream.add(ColonToken.create(Position.create("", 1, 42, 42)));
1135 		this.stream.add(DoubleSquareBracketOpenToken.create(Position.create("", 1, 43, 43)));
1136 		this.stream.add(BracketOpenToken.create(Position.create("", 1, 45, 45)));
1137 		this.stream.add(BracketCloseToken.create(Position.create("", 1, 46, 46)));
1138 		this.stream.add(ArrowToken.create(Position.create("", 1, 47, 47)));
1139 		this.stream.add(IdentifierToken.create("String", Position.create("", 1, 49, 49)));
1140 		this.stream.add(AsteriskToken.create(Position.create("", 1, 55, 55)));
1141 		this.stream.add(ExclamationToken.create(Position.create("", 1, 56, 56)));
1142 		this.stream.add(DoubleSquareBracketCloseToken.create(Position.create("", 1, 57, 57)));
1143 		this.stream.add(SemicolonToken.create(Position.create("", 1, 59, 59)));
1144 		this.stream.add(CurlyBracketCloseToken.create(Position.create("", 1, 60, 60)));
1145 		this.stream.add(SemicolonToken.create(Position.create("", 1, 61, 61)));
1146 		this.stream.add(SquareBracketCloseToken.create(Position.create("", 1, 62, 62)));
1147 		this.stream.add(SemicolonToken.create(Position.create("", 1, 63, 63)));
1148 		this.stream.add(EndToken.create(Position.create("", 1, 64, 64)));
1149 		
1150 		try {
1151 			this.parser.parse();
1152 		} catch (final NoValidTokenStreamException e) {
1153 			assertTrue(true);
1154 		}
1155 	}
1156 	
1157 	/**
1158 	 * MyGroup:group=[MyClass:class={MyOperation:[[()->String!!]];};];.
1159 	 * 
1160 	 * @throws Exception
1161 	 *             {@link de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException}
1162 	 */
1163 	@Test
1164 	public void testOperationReturnAThrownTypeThatShouldBeThrown() throws Exception {
1165 		
1166 		final IdentifierToken myGroupToken = IdentifierToken.create("MyGroup", Position.create("", 1, 1, 1));
1167 		final IdentifierToken myClassToken = IdentifierToken.create("MyClass", Position.create("", 1, 16, 16));
1168 		final IdentifierToken myOperationToken = IdentifierToken.create("MyOperation", Position.create("", 1, 31, 31));
1169 		
1170 		this.stream.add(myGroupToken);
1171 		this.stream.add(ColonToken.create(Position.create("", 1, 8, 8)));
1172 		this.stream.add(GroupToken.create(Position.create("", 1, 9, 9)));
1173 		this.stream.add(EqualToken.create(Position.create("", 1, 14, 14)));
1174 		this.stream.add(SquareBracketOpenToken.create(Position.create("", 1, 15, 15)));
1175 		this.stream.add(myClassToken);
1176 		this.stream.add(ColonToken.create(Position.create("", 1, 23, 23)));
1177 		this.stream.add(ClassToken.create(Position.create("", 1, 24, 24)));
1178 		this.stream.add(EqualToken.create(Position.create("", 1, 29, 29)));
1179 		this.stream.add(CurlyBracketOpenToken.create(Position.create("", 1, 30, 30)));
1180 		this.stream.add(myOperationToken);
1181 		this.stream.add(ColonToken.create(Position.create("", 1, 42, 42)));
1182 		this.stream.add(DoubleSquareBracketOpenToken.create(Position.create("", 1, 43, 43)));
1183 		this.stream.add(BracketOpenToken.create(Position.create("", 1, 45, 45)));
1184 		this.stream.add(BracketCloseToken.create(Position.create("", 1, 46, 46)));
1185 		this.stream.add(ArrowToken.create(Position.create("", 1, 47, 47)));
1186 		this.stream.add(IdentifierToken.create("String", Position.create("", 1, 49, 49)));
1187 		this.stream.add(ExclamationToken.create(Position.create("", 1, 55, 55)));
1188 		this.stream.add(ExclamationToken.create(Position.create("", 1, 56, 56)));
1189 		this.stream.add(DoubleSquareBracketCloseToken.create(Position.create("", 1, 57, 57)));
1190 		this.stream.add(SemicolonToken.create(Position.create("", 1, 59, 59)));
1191 		this.stream.add(CurlyBracketCloseToken.create(Position.create("", 1, 60, 60)));
1192 		this.stream.add(SemicolonToken.create(Position.create("", 1, 61, 61)));
1193 		this.stream.add(SquareBracketCloseToken.create(Position.create("", 1, 62, 62)));
1194 		this.stream.add(SemicolonToken.create(Position.create("", 1, 63, 63)));
1195 		this.stream.add(EndToken.create(Position.create("", 1, 64, 64)));
1196 		
1197 		try {
1198 			this.parser.parse();
1199 		} catch (final NoValidTokenStreamException e) {
1200 			assertTrue(true);
1201 		}
1202 	}
1203 	
1204 	/**
1205 	 * MyGroup:group=[MyClass:class={MyOperation:[[()->[String->Integer]!!]];};];.
1206 	 * 
1207 	 * @throws Exception
1208 	 *             {@link de.fhdw.wtf.common.exception.parser.NoValidTokenStreamException}
1209 	 */
1210 	@Test
1211 	public void testOperationReturnAMapThatShouldBeThrown() throws Exception {
1212 		
1213 		final IdentifierToken myGroupToken = IdentifierToken.create("MyGroup", Position.create("", 1, 1, 1));
1214 		final IdentifierToken myClassToken = IdentifierToken.create("MyClass", Position.create("", 1, 16, 16));
1215 		final IdentifierToken myOperationToken = IdentifierToken.create("MyOperation", Position.create("", 1, 31, 31));
1216 		
1217 		this.stream.add(myGroupToken);
1218 		this.stream.add(ColonToken.create(Position.create("", 1, 8, 8)));
1219 		this.stream.add(GroupToken.create(Position.create("", 1, 9, 9)));
1220 		this.stream.add(EqualToken.create(Position.create("", 1, 14, 14)));
1221 		this.stream.add(SquareBracketOpenToken.create(Position.create("", 1, 15, 15)));
1222 		this.stream.add(myClassToken);
1223 		this.stream.add(ColonToken.create(Position.create("", 1, 23, 23)));
1224 		this.stream.add(ClassToken.create(Position.create("", 1, 24, 24)));
1225 		this.stream.add(EqualToken.create(Position.create("", 1, 29, 29)));
1226 		this.stream.add(CurlyBracketOpenToken.create(Position.create("", 1, 30, 30)));
1227 		this.stream.add(myOperationToken);
1228 		this.stream.add(ColonToken.create(Position.create("", 1, 42, 42)));
1229 		this.stream.add(DoubleSquareBracketOpenToken.create(Position.create("", 1, 43, 43)));
1230 		this.stream.add(BracketOpenToken.create(Position.create("", 1, 45, 45)));
1231 		this.stream.add(BracketCloseToken.create(Position.create("", 1, 46, 46)));
1232 		this.stream.add(ArrowToken.create(Position.create("", 1, 47, 47)));
1233 		this.stream.add(SquareBracketOpenToken.create(Position.create("", 1, 49, 49)));
1234 		this.stream.add(IdentifierToken.create("String", Position.create("", 1, 50, 50)));
1235 		this.stream.add(ArrowToken.create(Position.create("", 1, 56, 56)));
1236 		this.stream.add(IdentifierToken.create("Integer", Position.create("", 1, 58, 58)));
1237 		this.stream.add(SquareBracketCloseToken.create(Position.create("", 1, 65, 65)));
1238 		this.stream.add(ExclamationToken.create(Position.create("", 1, 66, 66)));
1239 		this.stream.add(DoubleSquareBracketCloseToken.create(Position.create("", 1, 67, 67)));
1240 		this.stream.add(SemicolonToken.create(Position.create("", 1, 69, 69)));
1241 		this.stream.add(CurlyBracketCloseToken.create(Position.create("", 1, 70, 70)));
1242 		this.stream.add(SemicolonToken.create(Position.create("", 1, 71, 71)));
1243 		this.stream.add(SquareBracketCloseToken.create(Position.create("", 1, 72, 72)));
1244 		this.stream.add(SemicolonToken.create(Position.create("", 1, 73, 73)));
1245 		this.stream.add(EndToken.create(Position.create("", 1, 74, 74)));
1246 		
1247 		try {
1248 			this.parser.parse();
1249 		} catch (final NoValidTokenStreamException e) {
1250 			assertTrue(true);
1251 		}
1252 	}
1253 }