1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 @RunWith(RandomTestRunner.class)
102 public final class InterfaceMessagesTest {
103
104
105
106
107 public InterfaceMessagesTest() {
108
109 }
110
111
112
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.";
121
122 Assert.assertEquals("ChildEndingNodeException", expected, actual);
123 }
124
125
126
127
128 @Test
129 public void testConfigurationFileCorruptException() {
130 final String expectedFilename = "filename.txt";
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 "
138 + expectedFilename + '(' + ex.getClass().getName() + ')';
139
140 Assert.assertEquals("ConfigurationFileCorruptException", expected,
141 actual);
142
143 final String actualFilename = exception.getFilename();
144
145 Assert.assertEquals("ConfigurationFileCorruptException getFilename",
146 expectedFilename, actualFilename);
147 }
148
149
150
151
152 @Test(expected = AssertionError.class)
153 public void testConfigurationFileCorruptExceptionNull1() {
154 new ConfigurationFileCorruptException(null, new Exception());
155 }
156
157
158
159
160 @Test(expected = AssertionError.class)
161 public void testConfigurationFileCorruptExceptionNull2() {
162 new ConfigurationFileCorruptException("aa", null);
163 }
164
165
166
167
168 @Test
169 public void testConfigurationFileNotFoundException() {
170 final String expectedFilename = "filename.txt";
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;
178
179 Assert.assertEquals("ConfigurationFileNotFoundException",
180 expected, actual);
181
182 final String actualFilename = exception.getFilename();
183
184 Assert.assertEquals("ConfigurationFileNotFoundException getFilename",
185 expectedFilename, actualFilename);
186 }
187
188
189
190
191 @Test(expected = AssertionError.class)
192 public void testConfigurationFileNotFoundExceptionNull1() {
193 new ConfigurationFileNotFoundException(null);
194 }
195
196
197
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."
208 + excep.getMessage();
209
210 Assert.assertEquals("CorruptFileException",
211 expected, actual);
212 }
213
214
215
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.";
224
225 Assert.assertEquals("GRPH20-DelimitersNotDefinedException", expected,
226 actual);
227 }
228
229
230
231
232 @Test
233 public void testDuplicatedNameNodeException() {
234 final String expectedNodeId1 = "ParentNodeId";
235 final String expectedNodeId2 = "RepeatedNodeId";
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: "
245 + expectedNodeId2
246 + ". From this node "
247 + expectedNodeId1
248 + " (" + g1 + ", " + g2 + ")";
249
250 Assert.assertEquals("DuplicatedNodeException", expected,
251 actual);
252
253 final String actualNodeId = exception.getChildNodeName();
254
255 Assert.assertEquals("DuplicatedNodeNameException getChildNodeName",
256 expectedNodeId2, actualNodeId);
257
258 final String actualParentNodeId = exception.getParentNodeName();
259
260 Assert.assertEquals("DuplicatedNodeNameException getParentNodeName",
261 expectedNodeId1, actualParentNodeId);
262 }
263
264
265
266
267 @Test
268 public void testDuplicatedNodeException() {
269 final String expectedNodeId = "RepeatedNodeId";
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: "
277 + expectedNodeId;
278
279 Assert.assertEquals("DuplicatedNodeException", expected,
280 actual);
281
282 final String actualNodeId = exception.getNodeId();
283
284 Assert.assertEquals("DuplicatedNodeException getNodeId",
285 expectedNodeId, actualNodeId);
286 }
287
288
289
290
291 @Test(expected = AssertionError.class)
292 public void testDuplicatedNodeExceptionNull() {
293 new DuplicatedNodeException(null);
294 }
295
296
297
298
299 @Test(expected = AssertionError.class)
300 public void testDuplicateNodeNameExceptionNull1() {
301 final String expectedNodeId2 = "RepeatedNodeId";
302 final String g1 = "node1";
303 final String g2 = "node2";
304
305 new DuplicatedNodeNameException(null, expectedNodeId2, g1, g2);
306 }
307
308
309
310
311 @Test(expected = AssertionError.class)
312 public void testDuplicateNodeNameExceptionNull2() {
313 final String expectedNodeId1 = "ParentNodeId";
314 final String g1 = "node1";
315 final String g2 = "node2";
316
317 new DuplicatedNodeNameException(expectedNodeId1, null, g1, g2);
318 }
319
320
321
322
323 @Test(expected = AssertionError.class)
324 public void testDuplicateNodeNameExceptionNull3() {
325 final String expectedNodeId1 = "ParentNodeId";
326 final String expectedNodeId2 = "RepeatedNodeId";
327 final String g1 = null;
328 final String g2 = "node2";
329
330 new DuplicatedNodeNameException(expectedNodeId1, expectedNodeId2, g1,
331 g2);
332 }
333
334
335
336
337 @Test(expected = AssertionError.class)
338 public void testDuplicateNodeNameExceptionNull4() {
339 final String expectedNodeId1 = "ParentNodeId";
340 final String expectedNodeId2 = "RepeatedNodeId";
341 final String g1 = "node1";
342 final String g2 = null;
343
344 new DuplicatedNodeNameException(expectedNodeId1, expectedNodeId2, g1,
345 g2);
346 }
347
348
349
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.";
358
359 Assert.assertEquals("EmptyGrammarException", expected, actual);
360 }
361
362
363
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.";
372
373 Assert.assertEquals("EndingNodeNotDefinedException", expected, actual);
374 }
375
376
377
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.";
386
387 Assert.assertEquals("FileNotDefinedException",
388 expected, actual);
389 }
390
391
392
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: "
405 + filename + ": " + excep.getMessage();
406
407 Assert.assertEquals("FileNotFoundException",
408 expected, actual);
409 }
410
411
412
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;
423
424 Assert.assertEquals("FileNotFoundException",
425 expected, actual);
426 }
427
428
429
430
431
432
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"
441 + "'quit' or 'exit' + ENTER to finish the application.\n"
442 + "'about' + TAB to see a short descriptive note.\n"
443 + "'license' + TAB to see the licenses.";
444
445 Assert.assertEquals("HelpToken Name", expected, actual);
446 }
447
448
449
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.";
461
462 Assert.assertEquals("GeneralConfigurationFileProblemException",
463 expected, actual);
464 }
465
466
467
468
469 @Test(expected = AssertionError.class)
470 public void testGeneralConfigurationFileProblemExceptionNull() {
471 new GeneralConfigurationFileProblemException(null);
472 }
473
474
475
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: "
487 + NullPointerException.class.getName();
488
489 Assert.assertEquals("GeneralException", expected, actual);
490 }
491
492
493
494
495 @Test(expected = AssertionError.class)
496 public void testGeneralExceptionNull() {
497 new GeneralException(null);
498 }
499
500
501
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.";
513
514 Assert.assertEquals("GeneralGrammarFileProblemException", expected,
515 actual);
516 }
517
518
519
520
521 @Test(expected = AssertionError.class)
522 public void testGeneralGrammarFileProblemExceptionNull() {
523 new GeneralGrammarFileProblemException(null);
524 }
525
526
527
528
529 @Test
530 public void testGeneralGrammarReaderProblemException() {
531 final String text = "Real explanation";
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: "
540 + excep.getClass().getName() + ": " + text;
541
542 Assert.assertEquals(
543 "GRPH22-GeneralGrammarReaderProblemException", expected,
544 actual);
545 }
546
547
548
549
550 @Test(expected = AssertionError.class)
551 public void testGeneralGrammarReaderProblemExceptionNull() {
552 new GeneralGrammarReaderProblemException(null);
553 }
554
555
556
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.";
565
566 Assert.assertEquals("GrammarFileNotDefinedException", expected,
567 actual);
568 }
569
570
571
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.";
580
581 Assert.assertEquals(
582 "GRPH21-GrammarReaderNotDefinedException", expected,
583 actual);
584 }
585
586
587
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.";
598
599 Assert.assertEquals("InputReaderException", expected, actual);
600 }
601
602
603
604
605 @Test(expected = AssertionError.class)
606 public void testInputReaderExceptionNull() {
607 new InputReaderException(null);
608 }
609
610
611
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.";
621
622 Assert.assertEquals("GRPH22-InvalidEndingNodeException", expected,
623 actual);
624 }
625
626
627
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.";
636
637 Assert.assertEquals("InvalidGraphNodeException", expected, actual);
638 }
639
640
641
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 "
654 + expectedCurrentState
655 + ", needed state " + expectedRequiredState;
656
657 Assert.assertEquals("InvalidGraphStateException",
658 expected, actual);
659
660 final GraphState actualCurrentState = exception.getCurrentGraphState();
661
662 Assert.assertEquals("InvalidGraphStateException getCurrentGraphState",
663 expectedCurrentState, actualCurrentState);
664
665 final GraphState actualRequiredState = exception
666 .getRequiredGraphState();
667
668 Assert.assertEquals("InvalidGraphStateException getRequiredGraphState",
669 expectedRequiredState, actualRequiredState);
670 }
671
672
673
674
675 @Test(expected = AssertionError.class)
676 public void testInvalidGraphStateExceptionNull1() {
677 new InvalidGraphStateException(null, GraphState.FirstPhase);
678 }
679
680
681
682
683 @Test(expected = AssertionError.class)
684 public void testInvalidGraphStateExceptionNull2() {
685 new InvalidGraphStateException(GraphState.FirstPhase, null);
686 }
687
688
689
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.";
699
700 Assert.assertEquals("GRPH22-InvalidStartingNodeException", expected,
701 actual);
702 }
703
704
705
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.";
714
715 Assert.assertEquals("InvalidTokenException", expected, actual);
716 }
717
718
719
720
721 @Test
722 public void testNodeNotComesFromStartingNodeException() {
723 final String expectedName = "test";
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) "
731 + expectedName;
732
733 Assert.assertEquals("NodeNotComesFromStartingNodeException",
734 expected, actual);
735
736 final String actualName = exception.getNodename();
737 Assert.assertEquals(
738 "NodeNotComesFromStartingNodeException getNodename",
739 expectedName, actualName);
740 }
741
742
743
744
745 @Test(expected = AssertionError.class)
746 public void testNodeNotComesFromStartingNodeExceptionNull() {
747 new NodeNotComesFromStartingNodeException(null);
748 }
749
750
751
752
753 @Test
754 public void testNodeNotGoesToEndingNodeException() {
755 final String expectedName = "test";
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) "
763 + expectedName;
764
765 Assert.assertEquals("NodeNotGoesToEndingNodeException", expected,
766 actual);
767
768 final String actualName = exception.getNodename();
769
770 Assert.assertEquals("NodeNotGoesToEndingNodeException getNodename",
771 expectedName, actualName);
772 }
773
774
775
776
777 @Test(expected = AssertionError.class)
778 public void testNodeNotGoesToEndingNodeExceptionNull() {
779 new NodeNotGoesToEndingNodeException(null);
780 }
781
782
783
784
785 @Test
786 public void testNotExistingChildNodeException() {
787 final String expectedParentId = "parentId";
788 final String expectedChildId = "childId";
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
796 + ", Not existing node: " + expectedChildId;
797
798 Assert.assertEquals("NotExistingChildNodeException", expected,
799 actual);
800
801 final String actualParentId = exception.getParentNodeId();
802
803 Assert.assertEquals("NotExistingChildNodeException getParentNodeId",
804 expectedParentId, actualParentId);
805
806 final String actualChildId = exception.getChildNodeId();
807
808 Assert.assertEquals("NotExistingChildNodeException getChildNodeId",
809 expectedChildId, actualChildId);
810 }
811
812
813
814
815 @Test(expected = AssertionError.class)
816 public void testNotExistingChildNodeExceptionNull1() {
817 new NotExistingChildNodeException(null, "a");
818 }
819
820
821
822
823 @Test(expected = AssertionError.class)
824 public void testNotExistingChildNodeExceptionNull2() {
825 new NotExistingChildNodeException("a", null);
826 }
827
828
829
830
831 @Test
832 public void testNotExistingNodeException() {
833 final String expectedName = "test";
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: "
841 + expectedName;
842
843 Assert.assertEquals("NotExistingNodeException",
844 expected, actual);
845
846 final String actualName = exception.getNodeId();
847 Assert.assertEquals("NotExistingNodeException getNodeId",
848 expectedName, actualName);
849 }
850
851
852
853
854 @Test(expected = AssertionError.class)
855 public void testNotExistingNodeExceptionNull() {
856 new NotExistingNodeException(null);
857 }
858
859
860
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.";
869
870 Assert.assertEquals("NullGraphNodeException", expected, actual);
871 }
872
873
874
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.";
885
886 Assert.assertEquals("OutputWriterException", expected, actual);
887 }
888
889
890
891
892 @Test(expected = AssertionError.class)
893 public void testOutputWriterExceptionNull() {
894 new OutputWriterException(null);
895 }
896
897
898
899
900 @Test
901 public void testParameterNullException() {
902 final String expectedParameterName = "parametername";
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: "
910 + expectedParameterName;
911
912 Assert.assertEquals("ParameterNullException", expected, actual);
913
914 final String actualParameterName = exception.getParameterName();
915
916 Assert.assertEquals("ParameterNullException getParameter",
917 expectedParameterName, actualParameterName);
918 }
919
920
921
922
923 @Test(expected = AssertionError.class)
924 public void testParameterNullExceptionNull() {
925 new ParameterNullException(null);
926 }
927
928
929
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.";
938
939 Assert.assertEquals("ParentStartingNodeException", expected, actual);
940 }
941
942
943
944
945 @Test
946 public void testReferencingEndingNodeException() {
947 final String expectedName = "test";
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;
955
956 Assert.assertEquals("ReferencingEndingNodeException", expected,
957 actual);
958
959 final String actualName = exception.getReferencedNodename();
960
961 Assert.assertEquals(
962 "ReferencingEndingNodeException getReferencedNodeName",
963 expectedName, actualName);
964 }
965
966
967
968
969 @Test(expected = AssertionError.class)
970 public void testReferencingEndingNodeExceptionNull() {
971 new ReferencingEndingNodeException(null);
972 }
973
974
975
976
977 @Test
978 public void testReferencingStartingNodeException() {
979 final String expectedName = "test";
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: "
987 + expectedName;
988
989 Assert.assertEquals("ReferencingStartingNodeException", expected,
990 actual);
991
992 final String actualName = exception.getReferencingNodeName();
993
994 Assert.assertEquals(
995 "ReferencingStartingNodeException getReferencingNodeName",
996 expectedName, actualName);
997 }
998
999
1000
1001
1002 @Test(expected = AssertionError.class)
1003 public void testReferencingStartingNodeExceptionNull() {
1004 new ReferencingStartingNodeException(null);
1005 }
1006
1007
1008
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.";
1017
1018 Assert
1019 .assertEquals(
1020 "StartingNodeNotDefinedException", expected, actual);
1021 }
1022
1023
1024
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.";
1033
1034 Assert.assertEquals("GRPH27-UnprocessedGrammarException", expected,
1035 actual);
1036 }
1037 }