View Javadoc

1   /*
2    * Zemucan: A Syntax Assistant for DB2
3    * Copyright (C) 2009, 2010 Andres Gomez Casanova
4    *
5    * This file is part of Zemucan.
6    *
7    * Zemucan is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU Lesser General Public License as published by
9    * the Free Software Foundation; either version 3 of the License, or
10   * (at your option) any later version.
11   *
12   * Zemucan is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public License
18   * along with this library; if not, see <http://www.gnu.org/licenses/>.
19   *
20   * Contact:
21   * a n g o c a  at  y a h o o  dot  c o m
22   * Cra. 45 No 61 - 31, Bogota, Colombia.
23   *
24   * Author:   $LastChangedBy: angoca $:
25   * Date:     $LastChangedDate: 2011-03-06 10:15:32 -0500 (dom, 06 mar 2011) $:
26   * Revision: $LastChangedRevision: 1913 $:
27   * URL:      $HeadURL: https://zemucan.svn.sourceforge.net/svnroot/zemucan/branches/zemucan_v1/source-code/interfaze/src/test/java/name/angoca/zemucan/interfaze/InterfaceMessagesTest.java $:
28   */
29  package name.angoca.zemucan.interfaze;
30  
31  import java.io.IOException;
32  
33  import junit.framework.Assert;
34  import name.angoca.zemucan.AbstractZemucanException;
35  import name.angoca.zemucan.GeneralException;
36  import name.angoca.zemucan.ParameterNullException;
37  import name.angoca.zemucan.core.graph.api.ChildEndingNodeException;
38  import name.angoca.zemucan.core.graph.api.InvalidGraphNodeException;
39  import name.angoca.zemucan.core.graph.api.NullGraphNodeException;
40  import name.angoca.zemucan.core.graph.api.ParentStartingNodeException;
41  import name.angoca.zemucan.core.graph.model.DuplicatedNodeException;
42  import name.angoca.zemucan.core.graph.model.DuplicatedNodeNameException;
43  import name.angoca.zemucan.core.graph.model.EmptyGrammarException;
44  import name.angoca.zemucan.core.graph.model.EndingNodeNotDefinedException;
45  import name.angoca.zemucan.core.graph.model.Graph;
46  import name.angoca.zemucan.core.graph.model.GraphState;
47  import name.angoca.zemucan.core.graph.model.HelpNode;
48  import name.angoca.zemucan.core.graph.model.InvalidEndingNodeException;
49  import name.angoca.zemucan.core.graph.model.InvalidGraphStateException;
50  import name.angoca.zemucan.core.graph.model.InvalidStartingNodeException;
51  import name.angoca.zemucan.core.graph.model.NodeNotComesFromStartingNodeException;
52  import name.angoca.zemucan.core.graph.model.NodeNotGoesToEndingNodeException;
53  import name.angoca.zemucan.core.graph.model.NotExistingChildNodeException;
54  import name.angoca.zemucan.core.graph.model.NotExistingNodeException;
55  import name.angoca.zemucan.core.graph.model.ReferencingEndingNodeException;
56  import name.angoca.zemucan.core.graph.model.ReferencingStartingNodeException;
57  import name.angoca.zemucan.core.graph.model.StartingNodeNotDefinedException;
58  import name.angoca.zemucan.core.lexical.impl.InvalidTokenException;
59  import name.angoca.zemucan.grammarReader.api.DelimitersIncorrectlyDefinedException;
60  import name.angoca.zemucan.grammarReader.api.GeneralGrammarFileProblemException;
61  import name.angoca.zemucan.grammarReader.api.GeneralGrammarReaderProblemException;
62  import name.angoca.zemucan.grammarReader.api.GrammarFileNotDefinedException;
63  import name.angoca.zemucan.grammarReader.api.GrammarReaderNotDefinedException;
64  import name.angoca.zemucan.grammarReader.api.UnprocessedGrammarException;
65  import name.angoca.zemucan.tools.configurator.ConfigurationFileCorruptException;
66  import name.angoca.zemucan.tools.configurator.ConfigurationFileNotFoundException;
67  import name.angoca.zemucan.tools.configurator.GeneralConfigurationFileProblemException;
68  import name.angoca.zemucan.tools.file.CorruptFileException;
69  import name.angoca.zemucan.tools.file.FileNotDefinedException;
70  import name.angoca.zemucan.tools.file.FileNotFoundException;
71  import name.angoca.zemucan.tools.test.RandomTestRunner;
72  import name.angoca.zemucan.ui.api.InputReaderException;
73  import name.angoca.zemucan.ui.api.OutputWriterException;
74  
75  import org.junit.Test;
76  import org.junit.runner.RunWith;
77  
78  /**
79   * Set of test for the translation files for the core part.
80   * <p>
81   * <b>Control Version</b>
82   * <p>
83   * <ul>
84   * <li>1.0.0 Class creation.</li>
85   * <li>1.1.0 More tests.</li>
86   * <li>1.1.1 Messages.</li>
87   * <li>1.2.0 New exceptions.</li>
88   * <li>1.2.1 GraphToken renamed by GraphNode</li>
89   * <li>1.2.2 Methods ordered.</li>
90   * <li>1.3.0 GrammarReader separated from Graph.</li>
91   * <li>1.3.1 Test getters.</li>
92   * <li>1.3.2 Exception deleted.</li>
93   * <li>1.4.0 Exception modified.</li>
94   * <li>1.4.1 DuplicatedNodeNameException with two node names.</li>
95   * </ul>
96   *
97   * @author Andres Gomez Casanova <a
98   *         href="mailto:a n g o c a at y a h o o dot c o m" >(AngocA)</a>
99   * @version 1.4.1 2010-08-29
100  */
101 @RunWith(RandomTestRunner.class)
102 public final class InterfaceMessagesTest {
103 
104     /**
105      * Default constructor.
106      */
107     public InterfaceMessagesTest() {
108         // Nothing
109     }
110 
111     /**
112      * Tests the message of the ChildEndingNodeException.
113      */
114     @Test
115     public void testChildEndingNodeException() {
116         final Exception exception = new ChildEndingNodeException();
117 
118         final String actual = exception.getMessage();
119 
120         final String expected = "GRPH8 - The grammar tries to put a children in the EndingNode."; //$NON-NLS-1$
121 
122         Assert.assertEquals("ChildEndingNodeException", expected, actual); //$NON-NLS-1$
123     }
124 
125     /**
126      * Tests the message of the ConfigurationFileCorruptException.
127      */
128     @Test
129     public void testConfigurationFileCorruptException() {
130         final String expectedFilename = "filename.txt"; //$NON-NLS-1$
131         final Exception ex = new Exception();
132         final ConfigurationFileCorruptException exception = new ConfigurationFileCorruptException(
133                 expectedFilename, ex);
134 
135         final String actual = exception.getMessage();
136 
137         final String expected = "CONF1 - Invalid structure in configuration file " //$NON-NLS-1$
138                 + expectedFilename + '(' + ex.getClass().getName() + ')';
139 
140         Assert.assertEquals("ConfigurationFileCorruptException", expected, //$NON-NLS-1$
141                 actual);
142 
143         final String actualFilename = exception.getFilename();
144 
145         Assert.assertEquals("ConfigurationFileCorruptException getFilename", //$NON-NLS-1$
146                 expectedFilename, actualFilename);
147     }
148 
149     /**
150      * Tests that the exception has to receive a not null parameter.
151      */
152     @Test(expected = AssertionError.class)
153     public void testConfigurationFileCorruptExceptionNull1() {
154         new ConfigurationFileCorruptException(null, new Exception());
155     }
156 
157     /**
158      * Tests that the exception has to receive a not null parameter.
159      */
160     @Test(expected = AssertionError.class)
161     public void testConfigurationFileCorruptExceptionNull2() {
162         new ConfigurationFileCorruptException("aa", null); //$NON-NLS-1$
163     }
164 
165     /**
166      * Message when the configuration file is not found.
167      */
168     @Test
169     public void testConfigurationFileNotFoundException() {
170         final String expectedFilename = "filename.txt"; //$NON-NLS-1$
171 
172         final ConfigurationFileNotFoundException exception = new ConfigurationFileNotFoundException(
173                 expectedFilename);
174 
175         final String actual = exception.getMessage();
176 
177         final String expected = "CONF2 - The file not found is " + expectedFilename; //$NON-NLS-1$
178 
179         Assert.assertEquals("ConfigurationFileNotFoundException", //$NON-NLS-1$
180                 expected, actual);
181 
182         final String actualFilename = exception.getFilename();
183 
184         Assert.assertEquals("ConfigurationFileNotFoundException getFilename", //$NON-NLS-1$
185                 expectedFilename, actualFilename);
186     }
187 
188     /**
189      * Tests that the exception has to receive a not null parameter.
190      */
191     @Test(expected = AssertionError.class)
192     public void testConfigurationFileNotFoundExceptionNull1() {
193         new ConfigurationFileNotFoundException(null);
194     }
195 
196     /**
197      * Tests the message of the CorruptFileException.
198      */
199     @Test
200     public void testCorruptFileException() {
201         final IOException excep = new IOException();
202 
203         final Exception exception = new CorruptFileException(excep);
204 
205         final String actual = exception.getMessage();
206 
207         final String expected = "CONF7 - The File is probably corrupt." //$NON-NLS-1$
208                 + excep.getMessage();
209 
210         Assert.assertEquals("CorruptFileException", //$NON-NLS-1$
211                 expected, actual);
212     }
213 
214     /**
215      * Tests the message of the DelimitersNotDefinedException.
216      */
217     @Test
218     public void testDelimitersNotDefinedException() {
219         final Exception exception = new DelimitersIncorrectlyDefinedException();
220 
221         final String actual = exception.getMessage();
222 
223         final String expected = "GRPH20 - The delimiters are not defined in the grammar file."; //$NON-NLS-1$
224 
225         Assert.assertEquals("GRPH20-DelimitersNotDefinedException", expected, //$NON-NLS-1$
226                 actual);
227     }
228 
229     /**
230      * Message when there is a duplicated node.
231      */
232     @Test
233     public void testDuplicatedNameNodeException() {
234         final String expectedNodeId1 = "ParentNodeId"; //$NON-NLS-1$
235         final String expectedNodeId2 = "RepeatedNodeId"; //$NON-NLS-1$
236         final String g1 = "node1";
237         final String g2 = "node2";
238 
239         final DuplicatedNodeNameException exception = new DuplicatedNodeNameException(
240                 expectedNodeId1, expectedNodeId2, g1, g2);
241 
242         final String actual = exception.getMessage();
243 
244         final String expected = "GRPH25 - The duplicated node name in the grammar file is: " //$NON-NLS-1$
245                 + expectedNodeId2
246                 + ". From this node "
247                 + expectedNodeId1
248                 + " (" + g1 + ", " + g2 + ")";
249 
250         Assert.assertEquals("DuplicatedNodeException", expected, //$NON-NLS-1$
251                 actual);
252 
253         final String actualNodeId = exception.getChildNodeName();
254 
255         Assert.assertEquals("DuplicatedNodeNameException getChildNodeName", //$NON-NLS-1$
256                 expectedNodeId2, actualNodeId);
257 
258         final String actualParentNodeId = exception.getParentNodeName();
259 
260         Assert.assertEquals("DuplicatedNodeNameException getParentNodeName", //$NON-NLS-1$
261                 expectedNodeId1, actualParentNodeId);
262     }
263 
264     /**
265      * Message when there is a duplicated node.
266      */
267     @Test
268     public void testDuplicatedNodeException() {
269         final String expectedNodeId = "RepeatedNodeId"; //$NON-NLS-1$
270 
271         final DuplicatedNodeException exception = new DuplicatedNodeException(
272                 expectedNodeId);
273 
274         final String actual = exception.getMessage();
275 
276         final String expected = "GRPH12 - The duplicated node in the grammar file is: " //$NON-NLS-1$
277                 + expectedNodeId;
278 
279         Assert.assertEquals("DuplicatedNodeException", expected, //$NON-NLS-1$
280                 actual);
281 
282         final String actualNodeId = exception.getNodeId();
283 
284         Assert.assertEquals("DuplicatedNodeException getNodeId", //$NON-NLS-1$
285                 expectedNodeId, actualNodeId);
286     }
287 
288     /**
289      * Tests that the exception has to receive a not null parameter.
290      */
291     @Test(expected = AssertionError.class)
292     public void testDuplicatedNodeExceptionNull() {
293         new DuplicatedNodeException(null);
294     }
295 
296     /**
297      * Tests that the exception has to receive a not null parameter.
298      */
299     @Test(expected = AssertionError.class)
300     public void testDuplicateNodeNameExceptionNull1() {
301         final String expectedNodeId2 = "RepeatedNodeId"; //$NON-NLS-1$
302         final String g1 = "node1";
303         final String g2 = "node2";
304 
305         new DuplicatedNodeNameException(null, expectedNodeId2, g1, g2);
306     }
307 
308     /**
309      * Tests that the exception has to receive a not null parameter.
310      */
311     @Test(expected = AssertionError.class)
312     public void testDuplicateNodeNameExceptionNull2() {
313         final String expectedNodeId1 = "ParentNodeId"; //$NON-NLS-1$
314         final String g1 = "node1";
315         final String g2 = "node2";
316 
317         new DuplicatedNodeNameException(expectedNodeId1, null, g1, g2);
318     }
319 
320     /**
321      * Tests that the exception has to receive a not null parameter.
322      */
323     @Test(expected = AssertionError.class)
324     public void testDuplicateNodeNameExceptionNull3() {
325         final String expectedNodeId1 = "ParentNodeId"; //$NON-NLS-1$
326         final String expectedNodeId2 = "RepeatedNodeId"; //$NON-NLS-1$
327         final String g1 = null;
328         final String g2 = "node2";
329 
330         new DuplicatedNodeNameException(expectedNodeId1, expectedNodeId2, g1,
331                 g2);
332     }
333 
334     /**
335      * Tests that the exception has to receive a not null parameter.
336      */
337     @Test(expected = AssertionError.class)
338     public void testDuplicateNodeNameExceptionNull4() {
339         final String expectedNodeId1 = "ParentNodeId"; //$NON-NLS-1$
340         final String expectedNodeId2 = "RepeatedNodeId"; //$NON-NLS-1$
341         final String g1 = "node1";
342         final String g2 = null;
343 
344         new DuplicatedNodeNameException(expectedNodeId1, expectedNodeId2, g1,
345                 g2);
346     }
347 
348     /**
349      * Tests the message of the EmptyGrammarException.
350      */
351     @Test
352     public void testEmptyGrammarException() {
353         final Exception exception = new EmptyGrammarException();
354 
355         final String actual = exception.getMessage();
356 
357         final String expected = "GRPH5 - The grammar is empty."; //$NON-NLS-1$
358 
359         Assert.assertEquals("EmptyGrammarException", expected, actual); //$NON-NLS-1$
360     }
361 
362     /**
363      * Tests the message of the EndingNodeNotDefinedException.
364      */
365     @Test
366     public void testEndingNodeNotDefinedException() {
367         final Exception exception = new EndingNodeNotDefinedException();
368 
369         final String actual = exception.getMessage();
370 
371         final String expected = "GRPH15 - Ending Node not defined in the grammar."; //$NON-NLS-1$
372 
373         Assert.assertEquals("EndingNodeNotDefinedException", expected, actual); //$NON-NLS-1$
374     }
375 
376     /**
377      * Tests the message of the FileNotDefinedException.
378      */
379     @Test
380     public void testFileNotDefinedException() {
381         final Exception exception = new FileNotDefinedException();
382 
383         final String actual = exception.getMessage();
384 
385         final String expected = "CONF6 - No file was defined."; //$NON-NLS-1$
386 
387         Assert.assertEquals("FileNotDefinedException", //$NON-NLS-1$
388                 expected, actual);
389     }
390 
391     /**
392      * Tests the message of the FileNotFoundException.
393      */
394     @Test
395     public void testFileNotFoundException1() {
396         final String filename = "filename";
397 
398         final Exception excep = new Exception();
399 
400         final Exception exception = new FileNotFoundException(filename, excep);
401 
402         final String actual = exception.getMessage();
403 
404         final String expected = "CONF5 - This files was not found: " //$NON-NLS-1$
405                 + filename + ": " + excep.getMessage();
406 
407         Assert.assertEquals("FileNotFoundException", //$NON-NLS-1$
408                 expected, actual);
409     }
410 
411     /**
412      * Tests the message of the FileNotFoundException.
413      */
414     @Test
415     public void testFileNotFoundException2() {
416         final String filename = "filename";
417 
418         final Exception exception = new FileNotFoundException(filename);
419 
420         final String actual = exception.getMessage();
421 
422         final String expected = "CONF5 - This files was not found: " + filename; //$NON-NLS-1$
423 
424         Assert.assertEquals("FileNotFoundException", //$NON-NLS-1$
425                 expected, actual);
426     }
427 
428     /**
429      * Tests the message of the help token.
430      *
431      * @throws AbstractZemucanException
432      *             Never.
433      */
434     @Test
435     public void testFinalHelpToken() throws AbstractZemucanException {
436         final HelpNode token = new HelpNode(new Graph("test", false));
437 
438         final String actual = token.getName();
439 
440         final String expected = "Type\n" //$NON-NLS-1$
441                 + "'quit' or 'exit' + ENTER to finish the application.\n" //$NON-NLS-1$
442                 + "'about' + TAB to see a short descriptive note.\n" //$NON-NLS-1$
443                 + "'license' + TAB to see the licenses."; //$NON-NLS-1$
444 
445         Assert.assertEquals("HelpToken Name", expected, actual); //$NON-NLS-1$
446     }
447 
448     /**
449      * Tests the message of the GeneralConfigurationFileProblemException.
450      */
451     @Test
452     public void testGeneralConfigurationFileProblemException() {
453         final Exception excep = new Exception();
454 
455         final Exception exception = new GeneralConfigurationFileProblemException(
456                 excep);
457 
458         final String actual = exception.getMessage();
459 
460         final String expected = "CONF4 - There was a problem while reading the configuration file."; //$NON-NLS-1$
461 
462         Assert.assertEquals("GeneralConfigurationFileProblemException", //$NON-NLS-1$
463                 expected, actual);
464     }
465 
466     /**
467      * Tests that the exception has to receive a not null parameter.
468      */
469     @Test(expected = AssertionError.class)
470     public void testGeneralConfigurationFileProblemExceptionNull() {
471         new GeneralConfigurationFileProblemException(null);
472     }
473 
474     /**
475      * Tests the message of the GeneralException.
476      */
477     @Test
478     public void testGeneralException() {
479         final Exception wrappedException = new NullPointerException();
480 
481         final GeneralException exception = new GeneralException(
482                 wrappedException);
483 
484         final String actual = exception.getMessage();
485 
486         final String expected = "CORE2 - General problem: " //$NON-NLS-1$
487                 + NullPointerException.class.getName();
488 
489         Assert.assertEquals("GeneralException", expected, actual); //$NON-NLS-1$
490     }
491 
492     /**
493      * Tests that the exception has to receive a not null parameter.
494      */
495     @Test(expected = AssertionError.class)
496     public void testGeneralExceptionNull() {
497         new GeneralException(null);
498     }
499 
500     /**
501      * Tests the message of the GeneralGrammarFileProblemException.
502      */
503     @Test
504     public void testGeneralGrammarFileProblemException() {
505         final Exception excep = new Exception();
506 
507         final Exception exception = new GeneralGrammarFileProblemException(
508                 excep);
509 
510         final String actual = exception.getMessage();
511 
512         final String expected = "GRPH7 - There was a problem while reading the grammar file."; //$NON-NLS-1$
513 
514         Assert.assertEquals("GeneralGrammarFileProblemException", expected, //$NON-NLS-1$
515                 actual);
516     }
517 
518     /**
519      * Tests that the exception has to receive a not null parameter.
520      */
521     @Test(expected = AssertionError.class)
522     public void testGeneralGrammarFileProblemExceptionNull() {
523         new GeneralGrammarFileProblemException(null);
524     }
525 
526     /**
527      * Tests the message of the GeneralGrammarReaderProblemException.
528      */
529     @Test
530     public void testGeneralGrammarReaderProblemException() {
531         final String text = "Real explanation"; //$NON-NLS-1$
532         final Exception excep = new Exception(text);
533 
534         final Exception exception = new GeneralGrammarReaderProblemException(
535                 excep);
536 
537         final String actual = exception.getMessage();
538 
539         final String expected = "GRPH22 - There was a problem loading the grammar reader: " //$NON-NLS-1$
540                 + excep.getClass().getName() + ": " + text; //$NON-NLS-1$
541 
542         Assert.assertEquals(
543                 "GRPH22-GeneralGrammarReaderProblemException", expected, //$NON-NLS-1$
544                 actual);
545     }
546 
547     /**
548      * Tests that the exception has to receive a not null parameter.
549      */
550     @Test(expected = AssertionError.class)
551     public void testGeneralGrammarReaderProblemExceptionNull() {
552         new GeneralGrammarReaderProblemException(null);
553     }
554 
555     /**
556      * Tests the message of the GrammarFileNotDefinedException.
557      */
558     @Test
559     public void testGrammarFileNotDefinedException() {
560         final GrammarFileNotDefinedException exception = new GrammarFileNotDefinedException();
561 
562         final String actual = exception.getMessage();
563 
564         final String expected = "GRPH3 - The grammar file was not defined."; //$NON-NLS-1$
565 
566         Assert.assertEquals("GrammarFileNotDefinedException", expected, //$NON-NLS-1$
567                 actual);
568     }
569 
570     /**
571      * Tests the message of the GrammarReaderNotDefinedException.
572      */
573     @Test
574     public void testGrammarReaderNotDefinedException() {
575         final GrammarReaderNotDefinedException exception = new GrammarReaderNotDefinedException();
576 
577         final String actual = exception.getMessage();
578 
579         final String expected = "GRPH21 - The grammar reader was not defined."; //$NON-NLS-1$
580 
581         Assert.assertEquals(
582                 "GRPH21-GrammarReaderNotDefinedException", expected, //$NON-NLS-1$
583                 actual);
584     }
585 
586     /**
587      * Tests the message of the InputReaderException.
588      */
589     @Test
590     public void testInputReaderException() {
591         final IOException excep = new IOException();
592 
593         final Exception exception = new InputReaderException(excep);
594 
595         final String actual = exception.getMessage();
596 
597         final String expected = "UI1 - There was a problem from the input reader."; //$NON-NLS-1$
598 
599         Assert.assertEquals("InputReaderException", expected, actual); //$NON-NLS-1$
600     }
601 
602     /**
603      * Tests that the exception has to receive a not null parameter.
604      */
605     @Test(expected = AssertionError.class)
606     public void testInputReaderExceptionNull() {
607         new InputReaderException(null);
608     }
609 
610     /**
611      * Tests the message of the InvalidEndingNodeException.
612      */
613     @Test
614     public void testInvalidEndingNodeException() {
615 
616         final Exception exception = new InvalidEndingNodeException();
617 
618         final String actual = exception.getMessage();
619 
620         final String expected = "GRPH23 - Invalid form for creating the EndingNode."; //$NON-NLS-1$
621 
622         Assert.assertEquals("GRPH22-InvalidEndingNodeException", expected, //$NON-NLS-1$
623                 actual);
624     }
625 
626     /**
627      * Tests the message of the InvalidGraphNodeException.
628      */
629     @Test
630     public void testInvalidGraphNodeException() {
631         final Exception exception = new InvalidGraphNodeException();
632 
633         final String actual = exception.getMessage();
634 
635         final String expected = "GRPH1 - Invalid graph node."; //$NON-NLS-1$
636 
637         Assert.assertEquals("InvalidGraphNodeException", expected, actual); //$NON-NLS-1$
638     }
639 
640     /**
641      * Tests the message of the InvalidGraphStateException for the first phase.
642      */
643     @Test
644     public void testInvalidGraphStateExceptionFirstPhase() {
645         final GraphState expectedCurrentState = GraphState.FirstPhase;
646         final GraphState expectedRequiredState = GraphState.SecondPhase;
647 
648         final InvalidGraphStateException exception = new InvalidGraphStateException(
649                 expectedCurrentState, expectedRequiredState);
650 
651         final String actual = exception.getMessage();
652 
653         final String expected = "GRPH19 - The operation is not valid for the current graph state (Current State " //$NON-NLS-1$
654                 + expectedCurrentState
655                 + ", needed state " + expectedRequiredState; //$NON-NLS-1$
656 
657         Assert.assertEquals("InvalidGraphStateException", //$NON-NLS-1$
658                 expected, actual);
659 
660         final GraphState actualCurrentState = exception.getCurrentGraphState();
661 
662         Assert.assertEquals("InvalidGraphStateException getCurrentGraphState", //$NON-NLS-1$
663                 expectedCurrentState, actualCurrentState);
664 
665         final GraphState actualRequiredState = exception
666                 .getRequiredGraphState();
667 
668         Assert.assertEquals("InvalidGraphStateException getRequiredGraphState", //$NON-NLS-1$
669                 expectedRequiredState, actualRequiredState);
670     }
671 
672     /**
673      * Tests that the exception has to receive a not null parameter.
674      */
675     @Test(expected = AssertionError.class)
676     public void testInvalidGraphStateExceptionNull1() {
677         new InvalidGraphStateException(null, GraphState.FirstPhase);
678     }
679 
680     /**
681      * Tests that the exception has to receive a not null parameter.
682      */
683     @Test(expected = AssertionError.class)
684     public void testInvalidGraphStateExceptionNull2() {
685         new InvalidGraphStateException(GraphState.FirstPhase, null);
686     }
687 
688     /**
689      * Tests the message of the InvalidStartingNodeException.
690      */
691     @Test
692     public void testInvalidStartingNodeException() {
693 
694         final Exception exception = new InvalidStartingNodeException();
695 
696         final String actual = exception.getMessage();
697 
698         final String expected = "GRPH24 - Invalid form for creating the StartingNode."; //$NON-NLS-1$
699 
700         Assert.assertEquals("GRPH22-InvalidStartingNodeException", expected, //$NON-NLS-1$
701                 actual);
702     }
703 
704     /**
705      * Tests the message of the InvalidTokenException.
706      */
707     @Test
708     public void testInvalidTokenException() {
709         final Exception exception = new InvalidTokenException();
710 
711         final String actual = exception.getMessage();
712 
713         final String expected = "GRPH2 - The token is invalid."; //$NON-NLS-1$
714 
715         Assert.assertEquals("InvalidTokenException", expected, actual); //$NON-NLS-1$
716     }
717 
718     /**
719      * Tests the message of the NodeNotComesFromStartingNodeException.
720      */
721     @Test
722     public void testNodeNotComesFromStartingNodeException() {
723         final String expectedName = "test"; //$NON-NLS-1$
724 
725         final NodeNotComesFromStartingNodeException exception = new NodeNotComesFromStartingNodeException(
726                 expectedName);
727 
728         final String actual = exception.getMessage();
729 
730         final String expected = "GRPH17 - The next node does not have StartingNode as ancestry (parent) " //$NON-NLS-1$
731                 + expectedName;
732 
733         Assert.assertEquals("NodeNotComesFromStartingNodeException", //$NON-NLS-1$
734                 expected, actual);
735 
736         final String actualName = exception.getNodename();
737         Assert.assertEquals(
738                 "NodeNotComesFromStartingNodeException getNodename", //$NON-NLS-1$
739                 expectedName, actualName);
740     }
741 
742     /**
743      * Tests that the exception has to receive a not null parameter.
744      */
745     @Test(expected = AssertionError.class)
746     public void testNodeNotComesFromStartingNodeExceptionNull() {
747         new NodeNotComesFromStartingNodeException(null);
748     }
749 
750     /**
751      * Tests the message of the NodeNotGoesToEndingNodeException.
752      */
753     @Test
754     public void testNodeNotGoesToEndingNodeException() {
755         final String expectedName = "test"; //$NON-NLS-1$
756 
757         final NodeNotGoesToEndingNodeException exception = new NodeNotGoesToEndingNodeException(
758                 expectedName);
759 
760         final String actual = exception.getMessage();
761 
762         final String expected = "GRPH16 - This node does not have EndingNode as descendancy (child) " //$NON-NLS-1$
763                 + expectedName;
764 
765         Assert.assertEquals("NodeNotGoesToEndingNodeException", expected, //$NON-NLS-1$
766                 actual);
767 
768         final String actualName = exception.getNodename();
769 
770         Assert.assertEquals("NodeNotGoesToEndingNodeException getNodename", //$NON-NLS-1$
771                 expectedName, actualName);
772     }
773 
774     /**
775      * Tests that the exception has to receive a not null parameter.
776      */
777     @Test(expected = AssertionError.class)
778     public void testNodeNotGoesToEndingNodeExceptionNull() {
779         new NodeNotGoesToEndingNodeException(null);
780     }
781 
782     /**
783      * Tests the message of the NotExistingChildNodeException.
784      */
785     @Test
786     public void testNotExistingChildNodeException() {
787         final String expectedParentId = "parentId"; //$NON-NLS-1$
788         final String expectedChildId = "childId"; //$NON-NLS-1$
789 
790         final NotExistingChildNodeException exception = new NotExistingChildNodeException(
791                 expectedParentId, expectedChildId);
792 
793         final String actual = exception.getMessage();
794 
795         final String expected = "GRPH13 - Invalid node: " + expectedParentId //$NON-NLS-1$
796                 + ", Not existing node: " + expectedChildId; //$NON-NLS-1$
797 
798         Assert.assertEquals("NotExistingChildNodeException", expected, //$NON-NLS-1$
799                 actual);
800 
801         final String actualParentId = exception.getParentNodeId();
802 
803         Assert.assertEquals("NotExistingChildNodeException getParentNodeId", //$NON-NLS-1$
804                 expectedParentId, actualParentId);
805 
806         final String actualChildId = exception.getChildNodeId();
807 
808         Assert.assertEquals("NotExistingChildNodeException getChildNodeId", //$NON-NLS-1$
809                 expectedChildId, actualChildId);
810     }
811 
812     /**
813      * Tests that the exception has to receive a not null parameter.
814      */
815     @Test(expected = AssertionError.class)
816     public void testNotExistingChildNodeExceptionNull1() {
817         new NotExistingChildNodeException(null, "a"); //$NON-NLS-1$
818     }
819 
820     /**
821      * Tests that the exception has to receive a not null parameter.
822      */
823     @Test(expected = AssertionError.class)
824     public void testNotExistingChildNodeExceptionNull2() {
825         new NotExistingChildNodeException("a", null); //$NON-NLS-1$
826     }
827 
828     /**
829      * Tests the message of the NotExistingNodeException.
830      */
831     @Test
832     public void testNotExistingNodeException() {
833         final String expectedName = "test"; //$NON-NLS-1$
834 
835         final NotExistingNodeException exception = new NotExistingNodeException(
836                 expectedName);
837 
838         final String actual = exception.getMessage();
839 
840         final String expected = "GRPH18 - This node does not exist: " //$NON-NLS-1$
841                 + expectedName;
842 
843         Assert.assertEquals("NotExistingNodeException", //$NON-NLS-1$
844                 expected, actual);
845 
846         final String actualName = exception.getNodeId();
847         Assert.assertEquals("NotExistingNodeException getNodeId", //$NON-NLS-1$
848                 expectedName, actualName);
849     }
850 
851     /**
852      * Tests that the exception has to receive a not null parameter.
853      */
854     @Test(expected = AssertionError.class)
855     public void testNotExistingNodeExceptionNull() {
856         new NotExistingNodeException(null);
857     }
858 
859     /**
860      * Tests the message of the NullGraphNodeException.
861      */
862     @Test
863     public void testNullGraphNodeException() {
864         final Exception exception = new NullGraphNodeException();
865 
866         final String actual = exception.getMessage();
867 
868         final String expected = "GRPH6 - The given node is null."; //$NON-NLS-1$
869 
870         Assert.assertEquals("NullGraphNodeException", expected, actual); //$NON-NLS-1$
871     }
872 
873     /**
874      * Tests the message of the OutputWriterException.
875      */
876     @Test
877     public void testOutputWriterException() {
878         final IOException excep = new IOException();
879 
880         final Exception exception = new OutputWriterException(excep);
881 
882         final String actual = exception.getMessage();
883 
884         final String expected = "UI2 - There was a problem writing in the console."; //$NON-NLS-1$
885 
886         Assert.assertEquals("OutputWriterException", expected, actual); //$NON-NLS-1$
887     }
888 
889     /**
890      * Tests that the exception has to receive a not null parameter.
891      */
892     @Test(expected = AssertionError.class)
893     public void testOutputWriterExceptionNull() {
894         new OutputWriterException(null);
895     }
896 
897     /**
898      * Tests the message of the ParameterNullException.
899      */
900     @Test
901     public void testParameterNullException() {
902         final String expectedParameterName = "parametername"; //$NON-NLS-1$
903 
904         final ParameterNullException exception = new ParameterNullException(
905                 expectedParameterName);
906 
907         final String actual = exception.getMessage();
908 
909         final String expected = "CORE1 - The following parameter has a null value: " //$NON-NLS-1$
910                 + expectedParameterName;
911 
912         Assert.assertEquals("ParameterNullException", expected, actual); //$NON-NLS-1$
913 
914         final String actualParameterName = exception.getParameterName();
915 
916         Assert.assertEquals("ParameterNullException getParameter", //$NON-NLS-1$
917                 expectedParameterName, actualParameterName);
918     }
919 
920     /**
921      * Tests that the exception has to receive a not null parameter.
922      */
923     @Test(expected = AssertionError.class)
924     public void testParameterNullExceptionNull() {
925         new ParameterNullException(null);
926     }
927 
928     /**
929      * Tests the message of the ParentStartingNodeException.
930      */
931     @Test
932     public void testParentStartingNodeException() {
933         final Exception exception = new ParentStartingNodeException();
934 
935         final String actual = exception.getMessage();
936 
937         final String expected = "GRPH9 - The grammar tries to put a parent in the StartingNode."; //$NON-NLS-1$
938 
939         Assert.assertEquals("ParentStartingNodeException", expected, actual); //$NON-NLS-1$
940     }
941 
942     /**
943      * Tests the message of the ReferencingEndingNodeException.
944      */
945     @Test
946     public void testReferencingEndingNodeException() {
947         final String expectedName = "test"; //$NON-NLS-1$
948 
949         final ReferencingEndingNodeException exception = new ReferencingEndingNodeException(
950                 expectedName);
951 
952         final String actual = exception.getMessage();
953 
954         final String expected = "GRPH11 - The EndingNode reference a node: " + expectedName; //$NON-NLS-1$
955 
956         Assert.assertEquals("ReferencingEndingNodeException", expected, //$NON-NLS-1$
957                 actual);
958 
959         final String actualName = exception.getReferencedNodename();
960 
961         Assert.assertEquals(
962                 "ReferencingEndingNodeException getReferencedNodeName", //$NON-NLS-1$
963                 expectedName, actualName);
964     }
965 
966     /**
967      * Tests that the exception has to receive a not null parameter.
968      */
969     @Test(expected = AssertionError.class)
970     public void testReferencingEndingNodeExceptionNull() {
971         new ReferencingEndingNodeException(null);
972     }
973 
974     /**
975      * Tests the message of the ReferencingStartingNodeException.
976      */
977     @Test
978     public void testReferencingStartingNodeException() {
979         final String expectedName = "test"; //$NON-NLS-1$
980 
981         final ReferencingStartingNodeException exception = new ReferencingStartingNodeException(
982                 expectedName);
983 
984         final String actual = exception.getMessage();
985 
986         final String expected = "GRPH10 - The StartingNode is referenced by another node: " //$NON-NLS-1$
987                 + expectedName;
988 
989         Assert.assertEquals("ReferencingStartingNodeException", expected, //$NON-NLS-1$
990                 actual);
991 
992         final String actualName = exception.getReferencingNodeName();
993 
994         Assert.assertEquals(
995                 "ReferencingStartingNodeException getReferencingNodeName", //$NON-NLS-1$
996                 expectedName, actualName);
997     }
998 
999     /**
1000      * Tests that the exception has to receive a not null parameter.
1001      */
1002     @Test(expected = AssertionError.class)
1003     public void testReferencingStartingNodeExceptionNull() {
1004         new ReferencingStartingNodeException(null);
1005     }
1006 
1007     /**
1008      * Tests the message of the StartingNodeNotDefinedException.
1009      */
1010     @Test
1011     public void testStartingNodeNotDefinedException() {
1012         final Exception exception = new StartingNodeNotDefinedException();
1013 
1014         final String actual = exception.getMessage();
1015 
1016         final String expected = "GRPH14 - The Starting Node is not defined in the grammar."; //$NON-NLS-1$
1017 
1018         Assert
1019                 .assertEquals(
1020                         "StartingNodeNotDefinedException", expected, actual); //$NON-NLS-1$
1021     }
1022 
1023     /**
1024      * Tests the message of the UnprocessedGrammarException.
1025      */
1026     @Test
1027     public void testUnprocessedGrammarException() {
1028         final UnprocessedGrammarException exception = new UnprocessedGrammarException();
1029 
1030         final String actual = exception.getMessage();
1031 
1032         final String expected = "GRPH27 - The grammar has not been processed."; //$NON-NLS-1$
1033 
1034         Assert.assertEquals("GRPH27-UnprocessedGrammarException", expected, //$NON-NLS-1$
1035                 actual);
1036     }
1037 }