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.core.graph.model;
30
31 import java.util.List;
32
33 import name.angoca.zemucan.AbstractZemucanException;
34 import name.angoca.zemucan.core.graph.api.InvalidGraphNodeException;
35 import name.angoca.zemucan.core.graph.api.NullGraphNodeException;
36 import name.angoca.zemucan.tools.test.RandomTestRunner;
37
38 import org.junit.Assert;
39 import org.junit.Test;
40 import org.junit.runner.RunWith;
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 @RunWith(RandomTestRunner.class)
71 public final class GraphNodeTest {
72
73
74
75
76 private static final String A = "a";
77
78
79
80 private static final String CHILD = "child";
81
82
83
84 private static final String CREATE = "create";
85
86
87
88 private static final String GRAPHNODE = "graphnode";
89
90
91
92 private static final String NODE = "node";
93
94
95
96 private static final String PARENT = "parent";
97
98
99
100 private static final String TABLE = "table";
101
102
103
104 private static final String TABLENAME = "<tableName>";
105
106
107
108 private static final String TABLESPACE = "tablespace";
109
110
111
112
113 public GraphNodeTest() {
114
115 }
116
117
118
119
120
121
122
123 @Test
124 public void testAddEndingNodeParent() throws AbstractZemucanException {
125 final Graph graph = new Graph("test", false);
126
127 final String name = GraphNodeTest.NODE;
128 final EndingNode node = new EndingNode(graph);
129
130 final GraphNode graphNode = new GraphNode(name, graph);
131
132 Exception e = null;
133 try {
134 graphNode.addParent(node);
135 } catch (final Exception exception) {
136 e = exception;
137 }
138 Assert.assertTrue("ReferencingEndingNodeException",
139 e instanceof ReferencingEndingNodeException);
140 }
141
142
143
144
145
146
147
148 @Test
149 public void testAddNullChild() throws AbstractZemucanException {
150 final String name = GraphNodeTest.NODE;
151 final GraphNode nul = null;
152
153 final GraphNode graphNode = new GraphNode(name,
154 new Graph("test", false));
155
156 Exception e = null;
157 try {
158 graphNode.addChild(nul);
159 } catch (final Exception exception) {
160 e = exception;
161 }
162 Assert.assertTrue("NullGraphNodeException",
163 e instanceof NullGraphNodeException);
164 }
165
166
167
168
169
170
171
172 @Test
173 public void testAddNullParent() throws AbstractZemucanException {
174 final String name = GraphNodeTest.NODE;
175 final GraphNode nul = null;
176
177 final GraphNode graphNode = new GraphNode(name,
178 new Graph("test", false));
179
180 Exception e = null;
181 try {
182 graphNode.addParent(nul);
183 } catch (final Exception exception) {
184 e = exception;
185 }
186 Assert.assertTrue("NullGraphNodeException",
187 e instanceof NullGraphNodeException);
188 }
189
190
191
192
193
194
195
196 @Test
197 public void testAddTwiceSameChild() throws AbstractZemucanException {
198 final Graph graph = new Graph("test", false);
199
200 final String name = GraphNodeTest.NODE;
201 final GraphNode node = new GraphNode(name, graph);
202
203 final String childName = GraphNodeTest.CHILD;
204 final GraphNode child = new GraphNode(childName, graph);
205
206 node.addChild(child);
207 node.addChild(child);
208
209 final int children = node.getChildren().size();
210
211 Assert.assertTrue("One child", children == 1);
212 }
213
214
215
216
217
218
219
220 @Test
221 public void testAddTwiceSameParent() throws AbstractZemucanException {
222 final Graph graph = new Graph("test", false);
223
224 final String name = GraphNodeTest.NODE;
225 final GraphNode node = new GraphNode(name, graph);
226
227 final String parentName = GraphNodeTest.PARENT;
228 final GraphNode parent = new GraphNode(parentName, graph);
229
230 node.addParent(parent);
231 node.addParent(parent);
232
233 final int parents = node.getParents().size();
234
235 Assert.assertTrue("One parent", parents == 1);
236 }
237
238
239
240
241
242
243
244 @Test
245 public void testCongruent() throws AbstractZemucanException {
246 final String node = "test";
247
248 final GraphNode node1 = new GraphNode(node, new Graph("test", false));
249 final int val1 = node1.hashCode();
250 final int val2 = node1.hashCode();
251
252 final boolean val = val1 == val2;
253
254 Assert.assertTrue("Two consecutive calls return the same value", val);
255 }
256
257
258
259
260
261
262
263 @Test(expected = AssertionError.class)
264 public void testConstructorNull1() throws AbstractZemucanException {
265 new GraphNode(null, new Graph("test", false));
266 }
267
268
269
270
271
272
273
274 @Test(expected = AssertionError.class)
275 public void testConstructorNull2() throws AbstractZemucanException {
276 new GraphNode(GraphNodeTest.A, null, new Graph("test", false));
277 }
278
279
280
281
282
283
284
285 @Test
286 public void testEqualsDifferentChildren()
287 throws AbstractZemucanException {
288 final Graph graph = new Graph("test", false);
289
290 final String node11 = GraphNodeTest.CREATE;
291 final String node12 = GraphNodeTest.TABLE;
292 final String node21 = GraphNodeTest.CREATE;
293 final String node22 = GraphNodeTest.TABLESPACE;
294
295 final GraphNode actual = new GraphNode(node11, graph);
296 final GraphNode child1 = new GraphNode(node12, graph);
297 actual.addChild(child1);
298 final GraphNode expected = new GraphNode(node21, graph);
299 final GraphNode child2 = new GraphNode(node22, graph);
300 expected.addChild(child2);
301 final boolean condition1 = actual.equals(expected);
302 final boolean condition2 = expected.equals(actual);
303
304 Assert.assertFalse("1 - Two identical nodes with different children "
305 + "(a.equals(e))", condition1);
306 Assert.assertFalse("2 - Two identical nodes with different children "
307 + "(e.equals(a))", condition2);
308 }
309
310
311
312
313
314
315
316 @Test
317 public void testEqualsDifferentMixed() throws AbstractZemucanException {
318 final Graph graph = new Graph("test", false);
319
320 final String node1 = GraphNodeTest.CREATE;
321 final String node2 = GraphNodeTest.TABLENAME;
322
323 final GraphNode actual = new GraphNode(node1, graph);
324 final NonReservedGraphNode expected = new NonReservedGraphNode(node2,
325 graph);
326 final boolean condition1 = actual.equals(expected);
327 final boolean condition2 = expected.equals(actual);
328
329 Assert.assertFalse("1 - Two different nodes - mixed",
330 condition1);
331 Assert.assertFalse("2 - Two different nodes - mixed",
332 condition2);
333 }
334
335
336
337
338
339
340
341 @Test
342 public void testEqualsDifferentNotReserved()
343 throws AbstractZemucanException {
344 final Graph graph = new Graph("test", false);
345
346 final String node1 = GraphNodeTest.TABLENAME;
347 final String node2 = "<colName>";
348
349 final NonReservedGraphNode actual = new NonReservedGraphNode(node1,
350 graph);
351 final NonReservedGraphNode expected = new NonReservedGraphNode(node2,
352 graph);
353 final boolean condition = actual.equals(expected);
354 final boolean condition2 = expected.equals(actual);
355
356 Assert.assertFalse("two different nodes - non reserved",
357 condition);
358 Assert.assertFalse("two different nodes - non reserved 2",
359 condition2);
360 }
361
362
363
364
365
366
367
368 @Test
369 public void testEqualsDifferentParents()
370 throws AbstractZemucanException {
371 final Graph graph = new Graph("test", false);
372
373 final String node11 = GraphNodeTest.CREATE;
374 final String node12 = GraphNodeTest.TABLE;
375 final String node21 = GraphNodeTest.CREATE;
376 final String node22 = GraphNodeTest.TABLESPACE;
377
378 final GraphNode actual = new GraphNode(node11, graph);
379 final GraphNode parent1 = new GraphNode(node12, graph);
380 actual.addParent(parent1);
381 final GraphNode expected = new GraphNode(node21, graph);
382 final GraphNode parent2 = new GraphNode(node22, graph);
383 expected.addParent(parent2);
384 final boolean condition1 = actual.equals(expected);
385 final boolean condition2 = expected.equals(actual);
386
387 Assert.assertFalse("1 - Two identical nodes with different parents "
388 + "(a.equals(e))", condition1);
389 Assert.assertFalse("2 - Two identical nodes with different parents "
390 + "(e.equals(a))", condition2);
391 }
392
393
394
395
396
397
398
399 @Test
400 public void testEqualsDifferentReserved()
401 throws AbstractZemucanException {
402 final Graph graph = new Graph("test", false);
403
404 final String node1 = GraphNodeTest.CREATE;
405 final String node2 = GraphNodeTest.TABLE;
406
407 final GraphNode actual = new GraphNode(node1, graph);
408 final GraphNode expected = new GraphNode(node2, graph);
409 final boolean condition = actual.equals(expected);
410 final boolean condition2 = expected.equals(actual);
411
412 Assert.assertFalse("two different node - reserved", condition);
413 Assert.assertFalse("two different node - reserved 2", condition2);
414 }
415
416
417
418
419
420
421
422 @Test
423 public void testEqualsMoreChildren() throws AbstractZemucanException {
424 final Graph graph = new Graph("test", false);
425
426 final String node11 = GraphNodeTest.CREATE;
427 final String node12 = GraphNodeTest.TABLE;
428 final String node21 = GraphNodeTest.CREATE;
429 final String node22 = GraphNodeTest.TABLE;
430 final String node23 = GraphNodeTest.TABLESPACE;
431
432 final GraphNode actual = new GraphNode(node11, graph);
433 final GraphNode child1 = new GraphNode(node12, graph);
434 actual.addChild(child1);
435 final GraphNode expected = new GraphNode(node21, graph);
436 final GraphNode child2 = new GraphNode(node22, graph);
437 expected.addChild(child2);
438 final GraphNode child3 = new GraphNode(node23, graph);
439 expected.addChild(child3);
440 final boolean condition1 = actual.equals(expected);
441 final boolean condition2 = expected.equals(actual);
442
443 Assert.assertFalse("1 - two identical node, one with children",
444 condition1);
445 Assert.assertFalse("2- two identical node, one with children",
446 condition2);
447 }
448
449
450
451
452
453
454
455 @Test
456 public void testEqualsNotReserved() throws AbstractZemucanException {
457 final Graph graph = new Graph("test", false);
458
459 final String node1 = GraphNodeTest.TABLENAME;
460 final String node2 = GraphNodeTest.TABLENAME;
461
462 final NonReservedGraphNode actual = new NonReservedGraphNode(node1,
463 graph);
464 final NonReservedGraphNode expected = new NonReservedGraphNode(node2,
465 graph);
466 final boolean condition = actual.equals(expected);
467 final boolean condition2 = expected.equals(actual);
468
469 Assert.assertTrue("two identical node reserved", condition);
470 Assert.assertTrue("two identical node reserved2", condition2);
471 }
472
473
474
475
476
477
478
479 @Test
480 public void testEqualsNull() throws AbstractZemucanException {
481 final String node1 = GraphNodeTest.CREATE;
482
483 final GraphNode actual = new GraphNode(node1, new Graph("test", false));
484
485 final GraphNode nullObject = null;
486
487 final boolean condition = actual.equals(nullObject);
488
489 Assert.assertFalse("equals with null value", condition);
490 }
491
492
493
494
495
496
497
498 @Test
499 public void testEqualsOtherObject() throws AbstractZemucanException {
500 final Graph graph = new Graph("test", false);
501
502 final String node1 = GraphNodeTest.CREATE;
503
504 final GraphNode actual = new GraphNode(node1, graph);
505 final StartingNode expected = new StartingNode(graph);
506 final boolean condition = actual.equals(expected);
507 final boolean condition2 = expected.equals(actual);
508
509 Assert.assertFalse("equals with two identical objects",
510 condition);
511 Assert.assertFalse("equals with two identical objects 2",
512 condition2);
513 }
514
515
516
517
518
519
520
521 @Test
522 public void testEqualsReserved() throws AbstractZemucanException {
523 final Graph graph = new Graph("test", false);
524
525 final String node1 = GraphNodeTest.CREATE;
526 final String node2 = GraphNodeTest.CREATE;
527
528 final GraphNode actual = new GraphNode(node1, graph);
529 final GraphNode expected = new GraphNode(node2, graph);
530 final boolean condition = actual.equals(expected);
531 final boolean condition2 = expected.equals(actual);
532
533 Assert.assertTrue("two identical nodes - reserved word",
534 condition);
535 Assert.assertTrue("two identical nodes - reserved word 2",
536 condition2);
537 }
538
539
540
541
542
543
544
545 @Test
546 public void testEqualsSameChildren() throws AbstractZemucanException {
547 final Graph graph = new Graph("test", false);
548
549 final String node11 = GraphNodeTest.CREATE;
550 final String node12 = GraphNodeTest.TABLE;
551 final String node21 = GraphNodeTest.CREATE;
552 final String node22 = GraphNodeTest.TABLE;
553
554 final GraphNode actual = new GraphNode(node11, graph);
555 final GraphNode child1 = new GraphNode(node12, graph);
556 actual.addChild(child1);
557 final GraphNode expected = new GraphNode(node21, graph);
558 final GraphNode child2 = new GraphNode(node22, graph);
559 expected.addChild(child2);
560 final boolean condition = actual.equals(expected);
561 final boolean condition2 = expected.equals(actual);
562
563 Assert.assertTrue("Two identical nodes with same children", condition);
564 Assert.assertTrue("Two identical nodes with same children2",
565 condition2);
566 }
567
568
569
570
571
572
573
574 @Test
575 public void testHashCodeDifferent() throws AbstractZemucanException {
576 final Graph graph = new Graph("test", false);
577
578 final String node1 = GraphNodeTest.CREATE;
579 final String node2 = GraphNodeTest.TABLENAME;
580
581 final GraphNode actual = new GraphNode(node1, graph);
582 final NonReservedGraphNode expected = new NonReservedGraphNode(node2,
583 graph);
584
585 final int actualHashcode = actual.hashCode();
586 final int expectedHashcode = expected.hashCode();
587 final boolean condition = actualHashcode == expectedHashcode;
588
589 Assert.assertFalse("Hashcode of two different nodes", condition);
590 }
591
592
593
594
595
596
597
598 @Test
599 public void testHashCodeDifferentWithChildren()
600 throws AbstractZemucanException {
601 final Graph graph = new Graph("test", false);
602
603 final String node1 = GraphNodeTest.CREATE;
604 final String node2 = GraphNodeTest.CREATE;
605 final String node21 = GraphNodeTest.TABLE;
606
607 final NonReservedGraphNode actual = new NonReservedGraphNode(node1,
608 graph);
609 final NonReservedGraphNode expected = new NonReservedGraphNode(node2,
610 graph);
611 final NonReservedGraphNode child = new NonReservedGraphNode(node21,
612 graph);
613 expected.addChild(child);
614
615 final int actualHash = actual.hashCode();
616 final int expectedHash = expected.hashCode();
617
618 final boolean condition = actualHash == expectedHash;
619
620 Assert.assertFalse("Hashcode of two different objects", condition);
621 }
622
623
624
625
626
627
628
629 @Test
630 public void testHashCodeIdenticalNotReserved()
631 throws AbstractZemucanException {
632 final Graph graph = new Graph("test", false);
633
634 final String node1 = GraphNodeTest.TABLENAME;
635 final String node2 = GraphNodeTest.TABLENAME;
636
637 final NonReservedGraphNode actual = new NonReservedGraphNode(node1,
638 graph);
639 final NonReservedGraphNode expected = new NonReservedGraphNode(node2,
640 graph);
641
642 final boolean condition = actual.hashCode() == expected.hashCode();
643
644 Assert.assertTrue("Hashcod of two identical non reserved nodes",
645 condition);
646 }
647
648
649
650
651
652
653
654 @Test
655 public void testHashCodeIdenticalReserved()
656 throws AbstractZemucanException {
657 final Graph graph = new Graph("test", false);
658
659 final String node1 = GraphNodeTest.CREATE;
660 final String node2 = GraphNodeTest.CREATE;
661
662 final GraphNode actual = new GraphNode(node1, graph);
663 final GraphNode expected = new GraphNode(node2, graph);
664
665 final boolean condition = actual.hashCode() == expected.hashCode();
666
667 Assert.assertTrue("Hashcode of two identical reserved nodes",
668 condition);
669 }
670
671
672
673
674
675
676
677 @Test
678 public void testInvalidName() throws InvalidGraphNodeException {
679 final String node = "";
680
681 Exception e = null;
682 try {
683 new GraphNode(node, new Graph("test", false));
684 } catch (final Exception exception) {
685 e = exception;
686 }
687 Assert.assertTrue("InvalidGraphNodeException",
688 e instanceof InvalidGraphNodeException);
689 }
690
691
692
693
694
695
696
697 @Test
698 public void testReferencingStartingNode()
699 throws AbstractZemucanException {
700 final Graph graph = new Graph("test", false);
701
702 final String name = GraphNodeTest.GRAPHNODE;
703
704 final GraphNode graphNode = new GraphNode(name, graph);
705 final StartingNode starting = new StartingNode(graph);
706
707 Exception e = null;
708 try {
709 graphNode.addChild(starting);
710 } catch (final Exception exception) {
711 e = exception;
712 }
713 Assert.assertTrue("ReferencingStartingNodeException",
714 e instanceof ReferencingStartingNodeException);
715 }
716
717
718
719
720
721
722
723 @Test
724 public void testRemoveChild() throws AbstractZemucanException {
725 final Graph graph = new Graph("test", false);
726
727 final String name = GraphNodeTest.GRAPHNODE;
728 final GraphNode graphNode = new GraphNode(name, graph);
729
730 int size = graphNode.getChildren().size();
731
732 Assert.assertTrue("No children", size == 0);
733
734 final String childName = GraphNodeTest.CHILD;
735 final GraphNode child = new GraphNode(childName, graph);
736
737 graphNode.addChild(child);
738
739 size = graphNode.getChildren().size();
740
741 Assert.assertTrue("One child", size == 1);
742
743 graphNode.removeChild(child);
744
745 size = graphNode.getChildren().size();
746
747 Assert.assertTrue("No children after remove", size == 0);
748 }
749
750
751
752
753
754
755
756 @Test
757 public void testRemoveNullChild() throws AbstractZemucanException {
758 final String name = GraphNodeTest.GRAPHNODE;
759 final GraphNode graphNode = new GraphNode(name,
760 new Graph("test", false));
761
762 Exception e = null;
763 try {
764 graphNode.removeChild(null);
765 } catch (final Exception exception) {
766 e = exception;
767 }
768 Assert.assertTrue("NullGraphNodeException",
769 e instanceof NullGraphNodeException);
770 }
771
772
773
774
775
776
777
778 @Test
779 public void testRemoveNullParent() throws AbstractZemucanException {
780 final String name = GraphNodeTest.GRAPHNODE;
781 final GraphNode graphNode = new GraphNode(name,
782 new Graph("test", false));
783
784 Exception e = null;
785 try {
786 graphNode.removeParent(null);
787 } catch (final Exception exception) {
788 e = exception;
789 }
790 Assert.assertTrue("NullGraphNodeException",
791 e instanceof NullGraphNodeException);
792 }
793
794
795
796
797
798
799
800 @Test
801 public void testRemoveParent() throws AbstractZemucanException {
802 final Graph graph = new Graph("test", false);
803
804 final String name = GraphNodeTest.GRAPHNODE;
805 final GraphNode graphNode = new GraphNode(name, graph);
806
807 int size = graphNode.getParents().size();
808
809 Assert.assertTrue("No parents", size == 0);
810
811 final String parentName = GraphNodeTest.PARENT;
812 final GraphNode parent = new GraphNode(parentName, graph);
813
814 graphNode.addParent(parent);
815
816 size = graphNode.getParents().size();
817
818 Assert.assertTrue("One parents", size == 1);
819
820 graphNode.removeParent(parent);
821
822 size = graphNode.getParents().size();
823
824 Assert.assertTrue("No parents after remove", size == 0);
825 }
826
827
828
829
830
831
832
833
834 @Test
835 public void testRepresentCapitalReservedFalse()
836 throws AbstractZemucanException {
837 final String node1 = GraphNodeTest.CREATE;
838 final String node2 = "TABLE";
839
840 final GraphNode node = new GraphNode(node1, new Graph("test", false));
841 final boolean condition = node.represent(node2);
842
843 Assert.assertFalse("Represents capitals with no capitals", condition);
844 }
845
846
847
848
849
850
851
852 @Test
853 public void testRepresentCapitalReservedTrue()
854 throws AbstractZemucanException {
855 final String node1 = GraphNodeTest.CREATE;
856 final String node2 = "CREATE";
857
858 final GraphNode node = new GraphNode(node1, new Graph("test", false));
859 final boolean condition = node.represent(node2);
860
861 Assert.assertTrue("Represents capitals", condition);
862 }
863
864
865
866
867
868
869
870 @Test
871 public void testRepresentNotReservedTrue()
872 throws AbstractZemucanException {
873 final String node1 = GraphNodeTest.TABLENAME;
874 final String node2 = "Employees";
875
876 final NonReservedGraphNode node = new NonReservedGraphNode(node1,
877 new Graph("test", false));
878 final boolean condition = node.represent(node2);
879
880 Assert.assertTrue("Represents a no reserved word", condition);
881 }
882
883
884
885
886
887
888
889 @Test
890 public void testRepresentReservedFalse()
891 throws AbstractZemucanException {
892 final String node1 = GraphNodeTest.CREATE;
893 final String node2 = GraphNodeTest.TABLE;
894
895 final GraphNode node = new GraphNode(node1, new Graph("test", false));
896 final boolean condition = node.represent(node2);
897
898 Assert.assertFalse("Represents a reserved word", condition);
899 }
900
901
902
903
904
905
906
907 @Test
908 public void testRepresentReservedTrue() throws AbstractZemucanException {
909 final String node1 = GraphNodeTest.CREATE;
910 final String node2 = GraphNodeTest.CREATE;
911
912 final GraphNode node = new GraphNode(node1, new Graph("test", false));
913 final boolean condition = node.represent(node2);
914
915 Assert.assertTrue("Not represents a reserved word", condition);
916 }
917
918
919
920
921
922
923
924 @Test(expected = AssertionError.class)
925 public void testRepresentsNull() throws AbstractZemucanException {
926 final GraphNode node = new GraphNode(GraphNodeTest.A, new Graph("test",
927 false));
928
929 node.represent(null);
930 }
931
932
933
934
935
936
937
938 @Test
939 public void testSeveralOperations() throws AbstractZemucanException {
940 final Graph graph = new Graph("test", false);
941
942 final String text1 = "test1";
943 final String text2 = "test2";
944
945 final NonReservedGraphNode node1 = new NonReservedGraphNode(text1,
946 graph);
947 final NonReservedGraphNode node2 = new NonReservedGraphNode(text2,
948 graph);
949
950 node1.addParent(node2);
951 node1.getParents();
952
953 node2.setName(text1);
954
955 node1.setComeFromStartingNode(false);
956 node1.isComeFromStartingNode();
957
958 node2.setGoToEndingNode(false);
959 node2.isGoToEndingNode();
960 }
961
962
963
964
965
966
967
968 @Test
969 public void testSimpleMethods() throws AbstractZemucanException {
970 final String name = GraphNodeTest.GRAPHNODE;
971 String graphname = "test";
972
973 final GraphNode graphNode = new GraphNode(name, new Graph(graphname,
974 false));
975
976 String actual = graphNode.getId();
977
978 String expected = graphname + ":" + name;
979
980 Assert.assertEquals("id", expected, actual);
981
982 actual = graphNode.getName();
983
984 expected = name;
985
986 Assert.assertEquals("name", expected, actual);
987
988 final List<AbstractGraphNode> ways = graphNode.getChildren();
989
990 final boolean condition = ways.size() == 0;
991
992 Assert.assertTrue("ways", condition);
993 }
994
995
996
997
998
999
1000
1001 @Test
1002 public void testSymmetricNotReserved() throws AbstractZemucanException {
1003 final String text = "test";
1004
1005 final NonReservedGraphNode actual = new NonReservedGraphNode(text,
1006 new Graph("test", false));
1007
1008 final boolean value = actual.equals(actual);
1009
1010 Assert.assertTrue("Symmetry not reserved", value);
1011 }
1012
1013
1014
1015
1016
1017
1018
1019 @Test
1020 public void testSymmetricReserved() throws AbstractZemucanException {
1021 final String text = "test";
1022
1023 final GraphNode actual = new GraphNode(text, new Graph("test", false));
1024
1025 final boolean value = actual.equals(actual);
1026
1027 Assert.assertTrue("Symmetry reserved", value);
1028 }
1029
1030
1031
1032
1033
1034
1035
1036 @Test
1037 public void testToStringNotReserved() throws AbstractZemucanException {
1038 final String nodeIn = GraphNodeTest.TABLENAME;
1039 final String nodeOut = "<tableName>::{<tableName>\n0\n0\nfalse|false}";
1040
1041 final NonReservedGraphNode actualnode = new NonReservedGraphNode(
1042 nodeIn, new Graph("test", false));
1043 final String actual = actualnode.toString();
1044 final String expected = nodeOut;
1045
1046 Assert.assertEquals("Not represents a not reserved word", expected,
1047 actual);
1048 }
1049
1050
1051
1052
1053
1054
1055
1056 @Test
1057 public void testToStringReserved() throws AbstractZemucanException {
1058 final String nodeIn = GraphNodeTest.CREATE;
1059 final String nodeOut = "create|R::{create\n0\n0\nfalse|false}";
1060
1061 final GraphNode actualnode = new GraphNode(nodeIn, new Graph("test",
1062 false));
1063 final String actual = actualnode.toString();
1064 final String expected = nodeOut;
1065
1066 Assert.assertEquals("Is a reserved word", expected, actual);
1067 }
1068
1069
1070
1071
1072
1073
1074
1075 @Test
1076 public void testToStringWithChildren() throws AbstractZemucanException {
1077 final Graph graph = new Graph("test", false);
1078
1079 final String nodeIn = GraphNodeTest.TABLENAME;
1080 final String nodeIn1 = GraphNodeTest.TABLENAME;
1081 final String nodeOut = GraphNodeTest.TABLENAME + "::" + '{'
1082 + GraphNodeTest.TABLENAME
1083 + "\n0\n1\t[" + GraphNodeTest.TABLENAME + "]\nfalse|false}";
1084
1085 final NonReservedGraphNode actualnode = new NonReservedGraphNode(
1086 nodeIn, graph);
1087 final NonReservedGraphNode actualnode1 = new NonReservedGraphNode(
1088 nodeIn1, graph);
1089 actualnode.addChild(actualnode1);
1090
1091 final String actual = actualnode.toString();
1092 final String expected = nodeOut;
1093
1094 Assert.assertEquals("String of a node", expected, actual);
1095 }
1096
1097
1098
1099
1100
1101
1102
1103 @Test
1104 public void testToStringWithParents() throws AbstractZemucanException {
1105 final Graph graph = new Graph("test", false);
1106
1107 final String nodeIn = GraphNodeTest.TABLENAME;
1108 final String nodeIn1 = GraphNodeTest.TABLENAME;
1109 final String nodeOut = GraphNodeTest.TABLENAME + "::" + '{'
1110 + GraphNodeTest.TABLENAME
1111 + "\n1\t<" + GraphNodeTest.TABLENAME + ">\n0\nfalse|false}";
1112
1113 final NonReservedGraphNode actualnode = new NonReservedGraphNode(
1114 nodeIn, graph);
1115 final NonReservedGraphNode actualnode1 = new NonReservedGraphNode(
1116 nodeIn1, graph);
1117 actualnode.addParent(actualnode1);
1118
1119 final String actual = actualnode.toString();
1120 final String expected = nodeOut;
1121
1122 Assert.assertEquals("String of a node", expected, actual);
1123 }
1124
1125
1126
1127
1128
1129
1130
1131 @Test
1132 public void testTransitivity() throws AbstractZemucanException {
1133 final Graph graph = new Graph("test", false);
1134
1135 final String node = "test";
1136
1137 final GraphNode node1 = new GraphNode(node, graph);
1138 final GraphNode node2 = new GraphNode(node, graph);
1139 final GraphNode node3 = new GraphNode(node, graph);
1140
1141 final boolean val1 = node1.equals(node2) == node2.equals(node3);
1142 final boolean val2 = node1.equals(node3);
1143
1144 final boolean val = val1 == val2;
1145
1146 Assert.assertTrue("Transitivity", val);
1147 }
1148 }