|
Lines 28-40
Link Here
|
| 28 |
import org.eclipse.gef4.dot.internal.parser.arrowtype.DeprecatedShape; |
28 |
import org.eclipse.gef4.dot.internal.parser.arrowtype.DeprecatedShape; |
| 29 |
import org.eclipse.gef4.dot.internal.parser.arrowtype.PrimitiveShape; |
29 |
import org.eclipse.gef4.dot.internal.parser.arrowtype.PrimitiveShape; |
| 30 |
import org.eclipse.gef4.dot.internal.parser.dir.DirType; |
30 |
import org.eclipse.gef4.dot.internal.parser.dir.DirType; |
|
|
31 |
import org.eclipse.gef4.dot.internal.parser.layout.Layout; |
| 31 |
import org.eclipse.gef4.dot.internal.parser.point.Point; |
32 |
import org.eclipse.gef4.dot.internal.parser.point.Point; |
| 32 |
import org.eclipse.gef4.dot.internal.parser.point.PointFactory; |
33 |
import org.eclipse.gef4.dot.internal.parser.point.PointFactory; |
| 33 |
import org.eclipse.gef4.dot.internal.parser.rankdir.Rankdir; |
34 |
import org.eclipse.gef4.dot.internal.parser.rankdir.Rankdir; |
|
|
35 |
import org.eclipse.gef4.dot.internal.parser.shape.PolygonBasedNodeShape; |
| 36 |
import org.eclipse.gef4.dot.internal.parser.shape.PolygonBasedShape; |
| 37 |
import org.eclipse.gef4.dot.internal.parser.shape.RecordBasedNodeShape; |
| 38 |
import org.eclipse.gef4.dot.internal.parser.shape.RecordBasedShape; |
| 39 |
import org.eclipse.gef4.dot.internal.parser.shape.Shape; |
| 40 |
import org.eclipse.gef4.dot.internal.parser.shape.ShapeFactory; |
| 34 |
import org.eclipse.gef4.dot.internal.parser.splines.Splines; |
41 |
import org.eclipse.gef4.dot.internal.parser.splines.Splines; |
| 35 |
import org.eclipse.gef4.dot.internal.parser.splinetype.Spline; |
42 |
import org.eclipse.gef4.dot.internal.parser.splinetype.Spline; |
| 36 |
import org.eclipse.gef4.dot.internal.parser.splinetype.SplineType; |
43 |
import org.eclipse.gef4.dot.internal.parser.splinetype.SplineType; |
| 37 |
import org.eclipse.gef4.dot.internal.parser.splinetype.SplinetypeFactory; |
44 |
import org.eclipse.gef4.dot.internal.parser.splinetype.SplinetypeFactory; |
|
|
45 |
import org.eclipse.gef4.dot.internal.parser.style.Style; |
| 46 |
import org.eclipse.gef4.dot.internal.parser.style.StyleFactory; |
| 47 |
import org.eclipse.gef4.dot.internal.parser.style.StyleItem; |
| 38 |
import org.eclipse.gef4.graph.Edge; |
48 |
import org.eclipse.gef4.graph.Edge; |
| 39 |
import org.eclipse.gef4.graph.Graph; |
49 |
import org.eclipse.gef4.graph.Graph; |
| 40 |
import org.eclipse.gef4.graph.Node; |
50 |
import org.eclipse.gef4.graph.Node; |
|
Lines 303-309
Link Here
|
| 303 |
assertTrue(EcoreUtil.equals(validEdgeHeadLpParsed, |
313 |
assertTrue(EcoreUtil.equals(validEdgeHeadLpParsed, |
| 304 |
DotAttributes.getHeadLpParsed(edge))); |
314 |
DotAttributes.getHeadLpParsed(edge))); |
| 305 |
|
315 |
|
| 306 |
// TODO: add test cases for setting invalid edge head label positions |
316 |
// set invalid string values |
|
|
317 |
try { |
| 318 |
DotAttributes.setHeadLp(edge, "foo"); |
| 319 |
fail("Expecting IllegalArgumentException."); |
| 320 |
} catch (IllegalArgumentException e) { |
| 321 |
assertEquals( |
| 322 |
"Cannot set edge attribute 'head_lp' to 'foo'. The value 'foo' is not a syntactically correct point: No viable alternative at character 'f'. No viable alternative at character 'o'. No viable alternative at character 'o'.", |
| 323 |
e.getMessage()); |
| 324 |
} |
| 307 |
} |
325 |
} |
| 308 |
|
326 |
|
| 309 |
@Test |
327 |
@Test |
|
Lines 331-338
Link Here
|
| 331 |
final String validEdgeLabel = "edgeLabel"; |
349 |
final String validEdgeLabel = "edgeLabel"; |
| 332 |
DotAttributes.setLabel(edge, validEdgeLabel); |
350 |
DotAttributes.setLabel(edge, validEdgeLabel); |
| 333 |
assertEquals(validEdgeLabel, DotAttributes.getLabel(edge)); |
351 |
assertEquals(validEdgeLabel, DotAttributes.getLabel(edge)); |
| 334 |
|
|
|
| 335 |
// TODO: add test cases for setting invalid edge label |
| 336 |
} |
352 |
} |
| 337 |
|
353 |
|
| 338 |
@Test |
354 |
@Test |
|
Lines 354-360
Link Here
|
| 354 |
assertTrue(EcoreUtil.equals(validEdgeLpParsed, |
370 |
assertTrue(EcoreUtil.equals(validEdgeLpParsed, |
| 355 |
DotAttributes.getLpParsed(edge))); |
371 |
DotAttributes.getLpParsed(edge))); |
| 356 |
|
372 |
|
| 357 |
// TODO: add test cases for setting invalid edge label positions |
373 |
// set invalid string values |
|
|
374 |
try { |
| 375 |
DotAttributes.setLp(edge, "foo"); |
| 376 |
fail("Expecting IllegalArgumentException."); |
| 377 |
} catch (IllegalArgumentException e) { |
| 378 |
assertEquals( |
| 379 |
"Cannot set edge attribute 'lp' to 'foo'. The value 'foo' is not a syntactically correct point: No viable alternative at character 'f'. No viable alternative at character 'o'. No viable alternative at character 'o'.", |
| 380 |
e.getMessage()); |
| 381 |
} |
| 358 |
} |
382 |
} |
| 359 |
|
383 |
|
| 360 |
@Test |
384 |
@Test |
|
Lines 506-546
Link Here
|
| 506 |
Edge edge = new Edge.Builder(n1, n2).buildEdge(); |
530 |
Edge edge = new Edge.Builder(n1, n2).buildEdge(); |
| 507 |
|
531 |
|
| 508 |
// set valid string values |
532 |
// set valid string values |
| 509 |
String validEdgeStyle = "bold"; |
533 |
String[] validEdgeStyleItems = { "bold", "dashed", "dotted", "invis", |
|
|
534 |
"solid", "tapered" }; |
| 535 |
|
| 536 |
for (String validEdgeStyleItem : validEdgeStyleItems) { |
| 537 |
DotAttributes.setStyle(edge, validEdgeStyleItem); |
| 538 |
assertEquals(validEdgeStyleItem, DotAttributes.getStyle(edge)); |
| 539 |
|
| 540 |
Style styleParsed = StyleFactory.eINSTANCE.createStyle(); |
| 541 |
StyleItem styleItem = StyleFactory.eINSTANCE.createStyleItem(); |
| 542 |
styleItem.setName(validEdgeStyleItem); |
| 543 |
styleParsed.getStyleItems().add(styleItem); |
| 544 |
assertTrue(EcoreUtil.equals(styleParsed, |
| 545 |
DotAttributes.getStyleParsed(edge))); |
| 546 |
} |
| 547 |
|
| 548 |
String validEdgeStyle = ""; |
| 510 |
DotAttributes.setStyle(edge, validEdgeStyle); |
549 |
DotAttributes.setStyle(edge, validEdgeStyle); |
| 511 |
assertEquals(validEdgeStyle, DotAttributes.getStyle(edge)); |
550 |
assertEquals(validEdgeStyle, DotAttributes.getStyle(edge)); |
| 512 |
|
551 |
|
| 513 |
validEdgeStyle = "dashed"; |
552 |
// set valid parsed values |
| 514 |
DotAttributes.setStyle(edge, validEdgeStyle); |
553 |
Style styleParsed = StyleFactory.eINSTANCE.createStyle(); |
| 515 |
assertEquals(validEdgeStyle, DotAttributes.getStyle(edge)); |
554 |
StyleItem styleItem1 = StyleFactory.eINSTANCE.createStyleItem(); |
|
|
555 |
styleItem1.setName("bold"); |
| 556 |
StyleItem styleItem2 = StyleFactory.eINSTANCE.createStyleItem(); |
| 557 |
styleItem2.setName("dashed"); |
| 516 |
|
558 |
|
| 517 |
validEdgeStyle = "dotted"; |
559 |
styleParsed.getStyleItems().add(styleItem1); |
| 518 |
DotAttributes.setStyle(edge, validEdgeStyle); |
560 |
styleParsed.getStyleItems().add(styleItem2); |
| 519 |
assertEquals(validEdgeStyle, DotAttributes.getStyle(edge)); |
561 |
DotAttributes.setStyleParsed(edge, styleParsed); |
|
|
562 |
assertEquals("bold , dashed", DotAttributes.getStyle(edge)); |
| 520 |
|
563 |
|
| 521 |
validEdgeStyle = "invis"; |
564 |
// set syntactically invalid values |
| 522 |
DotAttributes.setStyle(edge, validEdgeStyle); |
565 |
try { |
| 523 |
assertEquals(validEdgeStyle, DotAttributes.getStyle(edge)); |
566 |
DotAttributes.setStyle(edge, "bold, "); |
|
|
567 |
fail("Expecting IllegalArgumentException."); |
| 568 |
} catch (IllegalArgumentException e) { |
| 569 |
assertEquals( |
| 570 |
"Cannot set edge attribute 'style' to 'bold, '. The value 'bold, ' is not a syntactically correct style: Mismatched input '<EOF>' expecting RULE_NAME.", |
| 571 |
e.getMessage()); |
| 572 |
} |
| 524 |
|
573 |
|
| 525 |
validEdgeStyle = "solid"; |
574 |
// set syntactically correct, but semantically invalid values |
| 526 |
DotAttributes.setStyle(edge, validEdgeStyle); |
|
|
| 527 |
assertEquals(validEdgeStyle, DotAttributes.getStyle(edge)); |
| 528 |
|
| 529 |
validEdgeStyle = "tapered"; |
| 530 |
DotAttributes.setStyle(edge, validEdgeStyle); |
| 531 |
assertEquals(validEdgeStyle, DotAttributes.getStyle(edge)); |
| 532 |
|
| 533 |
validEdgeStyle = ""; |
| 534 |
DotAttributes.setStyle(edge, validEdgeStyle); |
| 535 |
assertEquals(validEdgeStyle, DotAttributes.getStyle(edge)); |
| 536 |
|
| 537 |
// set invalid string values |
| 538 |
try { |
575 |
try { |
| 539 |
DotAttributes.setStyle(edge, "foo"); |
576 |
DotAttributes.setStyle(edge, "foo"); |
| 540 |
fail("Expecting IllegalArgumentException."); |
577 |
fail("Expecting IllegalArgumentException."); |
| 541 |
} catch (IllegalArgumentException e) { |
578 |
} catch (IllegalArgumentException e) { |
| 542 |
assertEquals( |
579 |
assertEquals( |
| 543 |
"Cannot set edge attribute 'style' to 'foo'. The style value 'foo' is not semantically correct: Value should be one of 'bold', 'dashed', 'dotted', 'invis', 'solid', 'tapered'.", |
580 |
"Cannot set edge attribute 'style' to 'foo'. The style value 'foo' is not semantically correct: Value should be one of 'bold', 'dashed', 'dotted', 'invis', 'solid', 'tapered'.", |
|
|
581 |
e.getMessage()); |
| 582 |
} |
| 583 |
|
| 584 |
try { |
| 585 |
DotAttributes.setStyle(edge, "diagonals"); |
| 586 |
fail("Expecting IllegalArgumentException."); |
| 587 |
} catch (IllegalArgumentException e) { |
| 588 |
assertEquals( |
| 589 |
"Cannot set edge attribute 'style' to 'diagonals'. The style value 'diagonals' is not semantically correct: Value should be one of 'bold', 'dashed', 'dotted', 'invis', 'solid', 'tapered'.", |
| 544 |
e.getMessage()); |
590 |
e.getMessage()); |
| 545 |
} |
591 |
} |
| 546 |
} |
592 |
} |
|
Lines 580-586
Link Here
|
| 580 |
assertTrue(EcoreUtil.equals(validEdgeTailLpParsed, |
626 |
assertTrue(EcoreUtil.equals(validEdgeTailLpParsed, |
| 581 |
DotAttributes.getTailLpParsed(edge))); |
627 |
DotAttributes.getTailLpParsed(edge))); |
| 582 |
|
628 |
|
| 583 |
// TODO: add test cases for setting invalid edge tail label positions |
629 |
// set invalid string values |
|
|
630 |
try { |
| 631 |
DotAttributes.setTailLp(edge, "foo"); |
| 632 |
fail("Expecting IllegalArgumentException."); |
| 633 |
} catch (IllegalArgumentException e) { |
| 634 |
assertEquals( |
| 635 |
"Cannot set edge attribute 'tail_lp' to 'foo'. The value 'foo' is not a syntactically correct point: No viable alternative at character 'f'. No viable alternative at character 'o'. No viable alternative at character 'o'.", |
| 636 |
e.getMessage()); |
| 637 |
} |
| 584 |
} |
638 |
} |
| 585 |
|
639 |
|
| 586 |
@Test |
640 |
@Test |
|
Lines 593-600
Link Here
|
| 593 |
final String validEdgeXLabel = "edgeXLabel"; |
647 |
final String validEdgeXLabel = "edgeXLabel"; |
| 594 |
DotAttributes.setXLabel(edge, validEdgeXLabel); |
648 |
DotAttributes.setXLabel(edge, validEdgeXLabel); |
| 595 |
assertEquals(validEdgeXLabel, DotAttributes.getXLabel(edge)); |
649 |
assertEquals(validEdgeXLabel, DotAttributes.getXLabel(edge)); |
| 596 |
|
|
|
| 597 |
// TODO: add test cases for setting invalid edge xlabel |
| 598 |
} |
650 |
} |
| 599 |
|
651 |
|
| 600 |
@Test |
652 |
@Test |
|
Lines 615-622
Link Here
|
| 615 |
assertEquals("33.0, 54.6", DotAttributes.getXlp(edge)); |
667 |
assertEquals("33.0, 54.6", DotAttributes.getXlp(edge)); |
| 616 |
assertTrue(EcoreUtil.equals(DotAttributes.getXlpParsed(edge), xlp)); |
668 |
assertTrue(EcoreUtil.equals(DotAttributes.getXlpParsed(edge), xlp)); |
| 617 |
|
669 |
|
| 618 |
// TODO: add test cases for setting invalid edge exterior label |
670 |
// set invalid string values |
| 619 |
// positions |
671 |
try { |
|
|
672 |
DotAttributes.setXlp(edge, "foo"); |
| 673 |
fail("Expecting IllegalArgumentException."); |
| 674 |
} catch (IllegalArgumentException e) { |
| 675 |
assertEquals( |
| 676 |
"Cannot set edge attribute 'xlp' to 'foo'. The value 'foo' is not a syntactically correct point: No viable alternative at character 'f'. No viable alternative at character 'o'. No viable alternative at character 'o'.", |
| 677 |
e.getMessage()); |
| 678 |
} |
| 620 |
} |
679 |
} |
| 621 |
|
680 |
|
| 622 |
@Test |
681 |
@Test |
|
Lines 668-673
Link Here
|
| 668 |
} |
727 |
} |
| 669 |
|
728 |
|
| 670 |
@Test |
729 |
@Test |
|
|
730 |
public void graph_label() { |
| 731 |
Graph g = new Graph.Builder().build(); |
| 732 |
|
| 733 |
// set valid string values |
| 734 |
final String validGraphLabel = "graphLabel"; |
| 735 |
DotAttributes.setLabel(g, validGraphLabel); |
| 736 |
assertEquals(validGraphLabel, DotAttributes.getLabel(g)); |
| 737 |
} |
| 738 |
|
| 739 |
@Test |
| 671 |
public void graph_layout() { |
740 |
public void graph_layout() { |
| 672 |
Graph g = new Graph.Builder().build(); |
741 |
Graph g = new Graph.Builder().build(); |
| 673 |
|
742 |
|
|
Lines 675-708
Link Here
|
| 675 |
String validGraphLayout = "circo"; |
744 |
String validGraphLayout = "circo"; |
| 676 |
DotAttributes.setLayout(g, validGraphLayout); |
745 |
DotAttributes.setLayout(g, validGraphLayout); |
| 677 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
746 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
|
|
747 |
assertEquals(Layout.CIRCO, DotAttributes.getLayoutParsed(g)); |
| 678 |
|
748 |
|
| 679 |
validGraphLayout = "dot"; |
749 |
validGraphLayout = "dot"; |
| 680 |
DotAttributes.setLayout(g, validGraphLayout); |
750 |
DotAttributes.setLayout(g, validGraphLayout); |
| 681 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
751 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
|
|
752 |
assertEquals(Layout.DOT, DotAttributes.getLayoutParsed(g)); |
| 682 |
|
753 |
|
| 683 |
validGraphLayout = "fdp"; |
754 |
validGraphLayout = "fdp"; |
| 684 |
DotAttributes.setLayout(g, validGraphLayout); |
755 |
DotAttributes.setLayout(g, validGraphLayout); |
| 685 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
756 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
|
|
757 |
assertEquals(Layout.FDP, DotAttributes.getLayoutParsed(g)); |
| 686 |
|
758 |
|
| 687 |
validGraphLayout = "grid"; |
759 |
validGraphLayout = "grid"; |
| 688 |
DotAttributes.setLayout(g, validGraphLayout); |
760 |
DotAttributes.setLayout(g, validGraphLayout); |
| 689 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
761 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
|
|
762 |
assertEquals(Layout.GRID, DotAttributes.getLayoutParsed(g)); |
| 690 |
|
763 |
|
| 691 |
validGraphLayout = "neato"; |
764 |
validGraphLayout = "neato"; |
| 692 |
DotAttributes.setLayout(g, validGraphLayout); |
765 |
DotAttributes.setLayout(g, validGraphLayout); |
| 693 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
766 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
|
|
767 |
assertEquals(Layout.NEATO, DotAttributes.getLayoutParsed(g)); |
| 694 |
|
768 |
|
| 695 |
validGraphLayout = "osage"; |
769 |
validGraphLayout = "osage"; |
| 696 |
DotAttributes.setLayout(g, validGraphLayout); |
770 |
DotAttributes.setLayout(g, validGraphLayout); |
| 697 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
771 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
|
|
772 |
assertEquals(Layout.OSAGE, DotAttributes.getLayoutParsed(g)); |
| 698 |
|
773 |
|
| 699 |
validGraphLayout = "sfdp"; |
774 |
validGraphLayout = "sfdp"; |
| 700 |
DotAttributes.setLayout(g, validGraphLayout); |
775 |
DotAttributes.setLayout(g, validGraphLayout); |
| 701 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
776 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
|
|
777 |
assertEquals(Layout.SFDP, DotAttributes.getLayoutParsed(g)); |
| 702 |
|
778 |
|
| 703 |
validGraphLayout = "twopi"; |
779 |
validGraphLayout = "twopi"; |
| 704 |
DotAttributes.setLayout(g, validGraphLayout); |
780 |
DotAttributes.setLayout(g, validGraphLayout); |
| 705 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
781 |
assertEquals(validGraphLayout, DotAttributes.getLayout(g)); |
|
|
782 |
assertEquals(Layout.TWOPI, DotAttributes.getLayoutParsed(g)); |
| 783 |
|
| 784 |
// set valid parsed values |
| 785 |
Layout validGraphLayoutParsed = Layout.CIRCO; |
| 786 |
DotAttributes.setLayoutParsed(g, validGraphLayoutParsed); |
| 787 |
assertEquals(validGraphLayoutParsed.toString(), |
| 788 |
DotAttributes.getLayout(g)); |
| 789 |
assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g)); |
| 790 |
|
| 791 |
validGraphLayoutParsed = Layout.DOT; |
| 792 |
DotAttributes.setLayoutParsed(g, validGraphLayoutParsed); |
| 793 |
assertEquals(validGraphLayoutParsed.toString(), |
| 794 |
DotAttributes.getLayout(g)); |
| 795 |
assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g)); |
| 796 |
|
| 797 |
validGraphLayoutParsed = Layout.CIRCO; |
| 798 |
DotAttributes.setLayoutParsed(g, validGraphLayoutParsed); |
| 799 |
assertEquals(validGraphLayoutParsed.toString(), |
| 800 |
DotAttributes.getLayout(g)); |
| 801 |
assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g)); |
| 802 |
|
| 803 |
validGraphLayoutParsed = Layout.FDP; |
| 804 |
DotAttributes.setLayoutParsed(g, validGraphLayoutParsed); |
| 805 |
assertEquals(validGraphLayoutParsed.toString(), |
| 806 |
DotAttributes.getLayout(g)); |
| 807 |
assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g)); |
| 808 |
|
| 809 |
validGraphLayoutParsed = Layout.GRID; |
| 810 |
DotAttributes.setLayoutParsed(g, validGraphLayoutParsed); |
| 811 |
assertEquals(validGraphLayoutParsed.toString(), |
| 812 |
DotAttributes.getLayout(g)); |
| 813 |
assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g)); |
| 814 |
|
| 815 |
validGraphLayoutParsed = Layout.NEATO; |
| 816 |
DotAttributes.setLayoutParsed(g, validGraphLayoutParsed); |
| 817 |
assertEquals(validGraphLayoutParsed.toString(), |
| 818 |
DotAttributes.getLayout(g)); |
| 819 |
assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g)); |
| 820 |
|
| 821 |
validGraphLayoutParsed = Layout.OSAGE; |
| 822 |
DotAttributes.setLayoutParsed(g, validGraphLayoutParsed); |
| 823 |
assertEquals(validGraphLayoutParsed.toString(), |
| 824 |
DotAttributes.getLayout(g)); |
| 825 |
assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g)); |
| 826 |
|
| 827 |
validGraphLayoutParsed = Layout.SFDP; |
| 828 |
DotAttributes.setLayoutParsed(g, validGraphLayoutParsed); |
| 829 |
assertEquals(validGraphLayoutParsed.toString(), |
| 830 |
DotAttributes.getLayout(g)); |
| 831 |
assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g)); |
| 832 |
|
| 833 |
validGraphLayoutParsed = Layout.TWOPI; |
| 834 |
DotAttributes.setLayoutParsed(g, validGraphLayoutParsed); |
| 835 |
assertEquals(validGraphLayoutParsed.toString(), |
| 836 |
DotAttributes.getLayout(g)); |
| 837 |
assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g)); |
| 706 |
|
838 |
|
| 707 |
// set invalid string values |
839 |
// set invalid string values |
| 708 |
try { |
840 |
try { |
|
Lines 711-716
Link Here
|
| 711 |
} catch (IllegalArgumentException e) { |
843 |
} catch (IllegalArgumentException e) { |
| 712 |
assertEquals( |
844 |
assertEquals( |
| 713 |
"Cannot set graph attribute 'layout' to 'foo'. The layout value 'foo' is not semantically correct: Value should be one of 'circo', 'dot', 'fdp', 'grid', 'neato', 'osage', 'sfdp', 'twopi'.", |
845 |
"Cannot set graph attribute 'layout' to 'foo'. The layout value 'foo' is not semantically correct: Value should be one of 'circo', 'dot', 'fdp', 'grid', 'neato', 'osage', 'sfdp', 'twopi'.", |
|
|
846 |
e.getMessage()); |
| 847 |
} |
| 848 |
} |
| 849 |
|
| 850 |
@Test |
| 851 |
public void graph_lp() { |
| 852 |
Graph g = new Graph.Builder().build(); |
| 853 |
|
| 854 |
// set valid string values |
| 855 |
String validGraphLp = "0.0,1.1"; |
| 856 |
DotAttributes.setLp(g, validGraphLp); |
| 857 |
assertEquals(validGraphLp, DotAttributes.getLp(g)); |
| 858 |
|
| 859 |
// set valid parsed values |
| 860 |
Point validGraphLpParsed = PointFactory.eINSTANCE.createPoint(); |
| 861 |
validGraphLpParsed.setX(2.2); |
| 862 |
validGraphLpParsed.setY(3.3); |
| 863 |
DotAttributes.setLpParsed(g, validGraphLpParsed); |
| 864 |
assertTrue(EcoreUtil.equals(validGraphLpParsed, |
| 865 |
DotAttributes.getLpParsed(g))); |
| 866 |
assertEquals("2.2, 3.3", DotAttributes.getLp(g)); |
| 867 |
|
| 868 |
// set invalid string values |
| 869 |
try { |
| 870 |
DotAttributes.setLp(g, "foo"); |
| 871 |
fail("Expecting IllegalArgumentException."); |
| 872 |
} catch (IllegalArgumentException e) { |
| 873 |
assertEquals( |
| 874 |
"Cannot set graph attribute 'lp' to 'foo'. The value 'foo' is not a syntactically correct point: No viable alternative at character 'f'. No viable alternative at character 'o'. No viable alternative at character 'o'.", |
| 714 |
e.getMessage()); |
875 |
e.getMessage()); |
| 715 |
} |
876 |
} |
| 716 |
} |
877 |
} |
|
Lines 915-920
Link Here
|
| 915 |
} |
1076 |
} |
| 916 |
|
1077 |
|
| 917 |
@Test |
1078 |
@Test |
|
|
1079 |
public void graph_type() { |
| 1080 |
Graph g = new Graph.Builder().build(); |
| 1081 |
|
| 1082 |
// set valid string values |
| 1083 |
String validGraphType = "graph"; |
| 1084 |
DotAttributes._setType(g, validGraphType); |
| 1085 |
assertEquals(validGraphType, DotAttributes._getType(g)); |
| 1086 |
|
| 1087 |
validGraphType = "digraph"; |
| 1088 |
DotAttributes._setType(g, validGraphType); |
| 1089 |
assertEquals(validGraphType, DotAttributes._getType(g)); |
| 1090 |
|
| 1091 |
// set invalid string values |
| 1092 |
try { |
| 1093 |
DotAttributes._setType(g, "foo"); |
| 1094 |
fail("Expecting IllegalArgumentException."); |
| 1095 |
} catch (IllegalArgumentException e) { |
| 1096 |
assertEquals( |
| 1097 |
"Cannot set graph attribute \"type\" to \"foo\"; supported values: graph, digraph", |
| 1098 |
e.getMessage()); |
| 1099 |
} |
| 1100 |
} |
| 1101 |
|
| 1102 |
@Test |
| 918 |
public void node_distortion() { |
1103 |
public void node_distortion() { |
| 919 |
Node n = new Node.Builder().buildNode(); |
1104 |
Node n = new Node.Builder().buildNode(); |
| 920 |
|
1105 |
|
|
Lines 967-996
Link Here
|
| 967 |
} |
1152 |
} |
| 968 |
|
1153 |
|
| 969 |
@Test |
1154 |
@Test |
| 970 |
public void graph_type() { |
|
|
| 971 |
Graph g = new Graph.Builder().build(); |
| 972 |
|
| 973 |
// set valid string values |
| 974 |
String validGraphType = "graph"; |
| 975 |
DotAttributes._setType(g, validGraphType); |
| 976 |
assertEquals(validGraphType, DotAttributes._getType(g)); |
| 977 |
|
| 978 |
validGraphType = "digraph"; |
| 979 |
DotAttributes._setType(g, validGraphType); |
| 980 |
assertEquals(validGraphType, DotAttributes._getType(g)); |
| 981 |
|
| 982 |
// set invalid string values |
| 983 |
try { |
| 984 |
DotAttributes._setType(g, "foo"); |
| 985 |
fail("Expecting IllegalArgumentException."); |
| 986 |
} catch (IllegalArgumentException e) { |
| 987 |
assertEquals( |
| 988 |
"Cannot set graph attribute \"type\" to \"foo\"; supported values: graph, digraph", |
| 989 |
e.getMessage()); |
| 990 |
} |
| 991 |
} |
| 992 |
|
| 993 |
@Test |
| 994 |
public void node_fixedsize() { |
1155 |
public void node_fixedsize() { |
| 995 |
Node n = new Node.Builder().buildNode(); |
1156 |
Node n = new Node.Builder().buildNode(); |
| 996 |
|
1157 |
|
|
Lines 1014-1020
Link Here
|
| 1014 |
assertEquals(validNodeFixedSizeParsed, |
1175 |
assertEquals(validNodeFixedSizeParsed, |
| 1015 |
DotAttributes.getFixedSizeParsed(n)); |
1176 |
DotAttributes.getFixedSizeParsed(n)); |
| 1016 |
|
1177 |
|
| 1017 |
// TODO: add test cases for setting invalid graph fixedsize |
1178 |
// set invalid string values |
|
|
1179 |
try { |
| 1180 |
DotAttributes.setFixedSize(n, "foo"); |
| 1181 |
fail("Expecting IllegalArgumentException."); |
| 1182 |
} catch (IllegalArgumentException e) { |
| 1183 |
assertEquals( |
| 1184 |
"Cannot set node attribute 'fixedsize' to 'foo'. The value 'foo' is not a syntactically correct bool: The given value 'foo' does not (case-insensitively) equal 'true', 'yes', 'false', or 'no' and is also not parsable as an integer value.", |
| 1185 |
e.getMessage()); |
| 1186 |
} |
| 1018 |
} |
1187 |
} |
| 1019 |
|
1188 |
|
| 1020 |
@Test |
1189 |
@Test |
|
Lines 1082-1089
Link Here
|
| 1082 |
final String validNodeLabel = "nodeLabel"; |
1251 |
final String validNodeLabel = "nodeLabel"; |
| 1083 |
DotAttributes.setLabel(n, validNodeLabel); |
1252 |
DotAttributes.setLabel(n, validNodeLabel); |
| 1084 |
assertEquals(validNodeLabel, DotAttributes.getLabel(n)); |
1253 |
assertEquals(validNodeLabel, DotAttributes.getLabel(n)); |
| 1085 |
|
|
|
| 1086 |
// TODO: add test cases for setting invalid node label |
| 1087 |
} |
1254 |
} |
| 1088 |
|
1255 |
|
| 1089 |
@Test |
1256 |
@Test |
|
Lines 1123-1128
Link Here
|
| 1123 |
} catch (IllegalArgumentException e) { |
1290 |
} catch (IllegalArgumentException e) { |
| 1124 |
assertEquals( |
1291 |
assertEquals( |
| 1125 |
"Cannot set node attribute 'pos' to '47x, 11'. The value '47x, 11' is not a syntactically correct point: No viable alternative at character 'x'.", |
1292 |
"Cannot set node attribute 'pos' to '47x, 11'. The value '47x, 11' is not a syntactically correct point: No viable alternative at character 'x'.", |
|
|
1293 |
e.getMessage()); |
| 1294 |
} |
| 1295 |
} |
| 1296 |
|
| 1297 |
@Test |
| 1298 |
public void node_shape() { |
| 1299 |
Node n = new Node.Builder().buildNode(); |
| 1300 |
|
| 1301 |
// set valid (polygon based) string values |
| 1302 |
String[] validPolygonBasedNodeShapes = { "assembly", "box", "box3d", |
| 1303 |
"cds", "circle", "component", "cylinder", "diamond", |
| 1304 |
"doublecircle", "doubleoctagon", "egg", "ellipse", |
| 1305 |
"fivepoverhang", "folder", "hexagon", "house", "insulator", |
| 1306 |
"invhouse", "invtrapezium", "invtriangle", "larrow", |
| 1307 |
"lpromoter", "Mcircle", "Mdiamond", "Msquare", "none", "note", |
| 1308 |
"noverhang", "octagon", "oval", "parallelogram", "pentagon", |
| 1309 |
"plain", "plaintext", "point", "polygon", "primersite", |
| 1310 |
"promoter", "proteasesite", "proteinstab", "rarrow", "rect", |
| 1311 |
"rectangle", "restrictionsite", "ribosite", "rnastab", |
| 1312 |
"rpromoter", "septagon", "signature", "square", "star", "tab", |
| 1313 |
"terminator", "threepoverhang", "trapezium", "triangle", |
| 1314 |
"tripleoctagon", "underline", "utr" }; |
| 1315 |
|
| 1316 |
for (String validPolygonBasedNodeShape : validPolygonBasedNodeShapes) { |
| 1317 |
DotAttributes.setShape(n, validPolygonBasedNodeShape); |
| 1318 |
assertEquals(validPolygonBasedNodeShape, DotAttributes.getShape(n)); |
| 1319 |
|
| 1320 |
Shape shapeParsed = ShapeFactory.eINSTANCE.createShape(); |
| 1321 |
PolygonBasedShape polygonBasedShape = ShapeFactory.eINSTANCE |
| 1322 |
.createPolygonBasedShape(); |
| 1323 |
polygonBasedShape.setShape( |
| 1324 |
PolygonBasedNodeShape.get(validPolygonBasedNodeShape)); |
| 1325 |
shapeParsed.setShape(polygonBasedShape); |
| 1326 |
assertTrue(EcoreUtil.equals(shapeParsed, |
| 1327 |
DotAttributes.getShapeParsed(n))); |
| 1328 |
} |
| 1329 |
|
| 1330 |
// set valid (record based) string values |
| 1331 |
String[] validRecordBasedNodeShapes = { "record", "Mrecord" }; |
| 1332 |
|
| 1333 |
for (String validRecordBasedNodeShape : validRecordBasedNodeShapes) { |
| 1334 |
DotAttributes.setShape(n, validRecordBasedNodeShape); |
| 1335 |
assertEquals(validRecordBasedNodeShape, DotAttributes.getShape(n)); |
| 1336 |
|
| 1337 |
Shape shapeParsed = ShapeFactory.eINSTANCE.createShape(); |
| 1338 |
RecordBasedShape recordBasedShape = ShapeFactory.eINSTANCE |
| 1339 |
.createRecordBasedShape(); |
| 1340 |
recordBasedShape.setShape( |
| 1341 |
RecordBasedNodeShape.get(validRecordBasedNodeShape)); |
| 1342 |
shapeParsed.setShape(recordBasedShape); |
| 1343 |
assertTrue(EcoreUtil.equals(shapeParsed, |
| 1344 |
DotAttributes.getShapeParsed(n))); |
| 1345 |
} |
| 1346 |
|
| 1347 |
// set valid parsed values |
| 1348 |
Shape validNodeShapeParsed = ShapeFactory.eINSTANCE.createShape(); |
| 1349 |
PolygonBasedShape polygonBasedShape = ShapeFactory.eINSTANCE |
| 1350 |
.createPolygonBasedShape(); |
| 1351 |
polygonBasedShape.setShape(PolygonBasedNodeShape.BOX); |
| 1352 |
validNodeShapeParsed.setShape(polygonBasedShape); |
| 1353 |
DotAttributes.setShapeParsed(n, validNodeShapeParsed); |
| 1354 |
assertEquals("box", DotAttributes.getShape(n)); |
| 1355 |
|
| 1356 |
// set invalid string values |
| 1357 |
try { |
| 1358 |
DotAttributes.setShape(n, "foo"); |
| 1359 |
fail("Expecting IllegalArgumentException."); |
| 1360 |
} catch (IllegalArgumentException e) { |
| 1361 |
assertEquals( |
| 1362 |
"Cannot set node attribute 'shape' to 'foo'. The value 'foo' is not a syntactically correct shape: Mismatched character 'o' expecting 'l'.", |
| 1363 |
e.getMessage()); |
| 1364 |
} |
| 1365 |
} |
| 1366 |
|
| 1367 |
@Test |
| 1368 |
public void node_sides() { |
| 1369 |
Node n = new Node.Builder().buildNode(); |
| 1370 |
|
| 1371 |
// set valid string values |
| 1372 |
String validNodeSides = "5"; |
| 1373 |
DotAttributes.setSides(n, validNodeSides); |
| 1374 |
assertEquals(validNodeSides, DotAttributes.getSides(n)); |
| 1375 |
assertEquals(5, DotAttributes.getSidesParsed(n).intValue()); |
| 1376 |
|
| 1377 |
// set the minimum valid value |
| 1378 |
validNodeSides = "0"; |
| 1379 |
DotAttributes.setSides(n, validNodeSides); |
| 1380 |
assertEquals(validNodeSides, DotAttributes.getSides(n)); |
| 1381 |
assertEquals(0, DotAttributes.getSidesParsed(n).intValue()); |
| 1382 |
|
| 1383 |
// set valid parsed values |
| 1384 |
Integer validNodeSidesParsed = 3; |
| 1385 |
DotAttributes.setSidesParsed(n, validNodeSidesParsed); |
| 1386 |
assertEquals("3", DotAttributes.getSides(n)); |
| 1387 |
assertEquals(validNodeSidesParsed, DotAttributes.getSidesParsed(n)); |
| 1388 |
|
| 1389 |
validNodeSidesParsed = 42; |
| 1390 |
DotAttributes.setSidesParsed(n, validNodeSidesParsed); |
| 1391 |
assertEquals("42", DotAttributes.getSides(n)); |
| 1392 |
assertEquals(validNodeSidesParsed, DotAttributes.getSidesParsed(n)); |
| 1393 |
|
| 1394 |
// set syntactically invalid values |
| 1395 |
try { |
| 1396 |
DotAttributes.setSides(n, "42x"); |
| 1397 |
fail("Expecting IllegalArgumentException."); |
| 1398 |
} catch (IllegalArgumentException e) { |
| 1399 |
assertEquals( |
| 1400 |
"Cannot set node attribute 'sides' to '42x'. The value '42x' is not a syntactically correct int: For input string: \"42x\".", |
| 1401 |
e.getMessage()); |
| 1402 |
} |
| 1403 |
|
| 1404 |
// set syntactically correct, but semantically invalid values |
| 1405 |
try { |
| 1406 |
DotAttributes.setSides(n, "-1"); |
| 1407 |
fail("Expecting IllegalArgumentException."); |
| 1408 |
} catch (IllegalArgumentException e) { |
| 1409 |
assertEquals( |
| 1410 |
"Cannot set node attribute 'sides' to '-1'. The int value '-1' is not semantically correct: Value may not be smaller than 0.", |
| 1411 |
e.getMessage()); |
| 1412 |
} |
| 1413 |
} |
| 1414 |
|
| 1415 |
@Test |
| 1416 |
public void node_skew() { |
| 1417 |
Node n = new Node.Builder().buildNode(); |
| 1418 |
|
| 1419 |
// set valid string values |
| 1420 |
String validNodeSkew = "5"; |
| 1421 |
DotAttributes.setSkew(n, validNodeSkew); |
| 1422 |
assertEquals(validNodeSkew, DotAttributes.getSkew(n)); |
| 1423 |
assertEquals(5.0, DotAttributes.getSkewParsed(n).doubleValue(), 0.0); |
| 1424 |
|
| 1425 |
// set the minimum valid value |
| 1426 |
validNodeSkew = "-100.0"; |
| 1427 |
DotAttributes.setSkew(n, validNodeSkew); |
| 1428 |
assertEquals(validNodeSkew, DotAttributes.getSkew(n)); |
| 1429 |
assertEquals(-100.0, DotAttributes.getSkewParsed(n).doubleValue(), 0.0); |
| 1430 |
|
| 1431 |
// set valid parsed values |
| 1432 |
Double validNodeSkewParsed = 10.0; |
| 1433 |
DotAttributes.setSkewParsed(n, validNodeSkewParsed); |
| 1434 |
assertEquals("10.0", DotAttributes.getSkew(n)); |
| 1435 |
assertEquals(validNodeSkewParsed, DotAttributes.getSkewParsed(n)); |
| 1436 |
|
| 1437 |
validNodeSkewParsed = 9.9; |
| 1438 |
DotAttributes.setSkewParsed(n, validNodeSkewParsed); |
| 1439 |
assertEquals("9.9", DotAttributes.getSkew(n)); |
| 1440 |
assertEquals(validNodeSkewParsed, DotAttributes.getSkewParsed(n)); |
| 1441 |
|
| 1442 |
// set syntactically invalid values |
| 1443 |
try { |
| 1444 |
DotAttributes.setSkew(n, "42x"); |
| 1445 |
fail("Expecting IllegalArgumentException."); |
| 1446 |
} catch (IllegalArgumentException e) { |
| 1447 |
assertEquals( |
| 1448 |
"Cannot set node attribute 'skew' to '42x'. The value '42x' is not a syntactically correct double: For input string: \"42x\".", |
| 1449 |
e.getMessage()); |
| 1450 |
} |
| 1451 |
|
| 1452 |
// set syntactically correct, but semantically invalid values |
| 1453 |
try { |
| 1454 |
DotAttributes.setSkew(n, "-100.01"); |
| 1455 |
fail("Expecting IllegalArgumentException."); |
| 1456 |
} catch (IllegalArgumentException e) { |
| 1457 |
assertEquals( |
| 1458 |
"Cannot set node attribute 'skew' to '-100.01'. The double value '-100.01' is not semantically correct: Value may not be smaller than -100.0.", |
| 1459 |
e.getMessage()); |
| 1460 |
} |
| 1461 |
} |
| 1462 |
|
| 1463 |
@Test |
| 1464 |
public void node_style() { |
| 1465 |
Node node = new Node.Builder().buildNode(); |
| 1466 |
|
| 1467 |
// set valid string values |
| 1468 |
String[] validNodeStyleItems = { "bold", "dashed", "diagonals", |
| 1469 |
"dotted", "filled", "invis", "radial", "rounded", "solid", |
| 1470 |
"striped", "wedged" }; |
| 1471 |
|
| 1472 |
for (String validNodeStyleItem : validNodeStyleItems) { |
| 1473 |
DotAttributes.setStyle(node, validNodeStyleItem); |
| 1474 |
assertEquals(validNodeStyleItem, DotAttributes.getStyle(node)); |
| 1475 |
|
| 1476 |
Style styleParsed = StyleFactory.eINSTANCE.createStyle(); |
| 1477 |
StyleItem styleItem = StyleFactory.eINSTANCE.createStyleItem(); |
| 1478 |
styleItem.setName(validNodeStyleItem); |
| 1479 |
styleParsed.getStyleItems().add(styleItem); |
| 1480 |
assertTrue(EcoreUtil.equals(styleParsed, |
| 1481 |
DotAttributes.getStyleParsed(node))); |
| 1482 |
} |
| 1483 |
|
| 1484 |
String validNodeStyle = ""; |
| 1485 |
DotAttributes.setStyle(node, validNodeStyle); |
| 1486 |
assertEquals(validNodeStyle, DotAttributes.getStyle(node)); |
| 1487 |
|
| 1488 |
// set valid parsed values |
| 1489 |
Style styleParsed = StyleFactory.eINSTANCE.createStyle(); |
| 1490 |
StyleItem styleItem1 = StyleFactory.eINSTANCE.createStyleItem(); |
| 1491 |
styleItem1.setName("bold"); |
| 1492 |
StyleItem styleItem2 = StyleFactory.eINSTANCE.createStyleItem(); |
| 1493 |
styleItem2.setName("dashed"); |
| 1494 |
|
| 1495 |
styleParsed.getStyleItems().add(styleItem1); |
| 1496 |
styleParsed.getStyleItems().add(styleItem2); |
| 1497 |
DotAttributes.setStyleParsed(node, styleParsed); |
| 1498 |
assertEquals("bold , dashed", DotAttributes.getStyle(node)); |
| 1499 |
|
| 1500 |
// set syntactically invalid values |
| 1501 |
try { |
| 1502 |
DotAttributes.setStyle(node, "bold, "); |
| 1503 |
fail("Expecting IllegalArgumentException."); |
| 1504 |
} catch (IllegalArgumentException e) { |
| 1505 |
assertEquals( |
| 1506 |
"Cannot set node attribute 'style' to 'bold, '. The value 'bold, ' is not a syntactically correct style: Mismatched input '<EOF>' expecting RULE_NAME.", |
| 1507 |
e.getMessage()); |
| 1508 |
} |
| 1509 |
|
| 1510 |
// set syntactically correct, but semantically invalid values |
| 1511 |
try { |
| 1512 |
DotAttributes.setStyle(node, "foo"); |
| 1513 |
fail("Expecting IllegalArgumentException."); |
| 1514 |
} catch (IllegalArgumentException e) { |
| 1515 |
assertEquals( |
| 1516 |
"Cannot set node attribute 'style' to 'foo'. The style value 'foo' is not semantically correct: Value should be one of 'bold', 'dashed', 'diagonals', 'dotted', 'filled', 'invis', 'radial', 'rounded', 'solid', 'striped', 'wedged'.", |
| 1517 |
e.getMessage()); |
| 1518 |
} |
| 1519 |
|
| 1520 |
try { |
| 1521 |
DotAttributes.setStyle(node, "tapered"); |
| 1522 |
fail("Expecting IllegalArgumentException."); |
| 1523 |
} catch (IllegalArgumentException e) { |
| 1524 |
assertEquals( |
| 1525 |
"Cannot set node attribute 'style' to 'tapered'. The style value 'tapered' is not semantically correct: Value should be one of 'bold', 'dashed', 'diagonals', 'dotted', 'filled', 'invis', 'radial', 'rounded', 'solid', 'striped', 'wedged'.", |
| 1126 |
e.getMessage()); |
1526 |
e.getMessage()); |
| 1127 |
} |
1527 |
} |
| 1128 |
} |
1528 |
} |
|
Lines 1183-1190
Link Here
|
| 1183 |
final String validNodeXLabel = "nodeXLabel"; |
1583 |
final String validNodeXLabel = "nodeXLabel"; |
| 1184 |
DotAttributes.setXLabel(n, validNodeXLabel); |
1584 |
DotAttributes.setXLabel(n, validNodeXLabel); |
| 1185 |
assertEquals(validNodeXLabel, DotAttributes.getXLabel(n)); |
1585 |
assertEquals(validNodeXLabel, DotAttributes.getXLabel(n)); |
| 1186 |
|
|
|
| 1187 |
// TODO: add test cases for setting invalid node xlabel |
| 1188 |
} |
1586 |
} |
| 1189 |
|
1587 |
|
| 1190 |
@Test |
1588 |
@Test |
|
Lines 1204-1210
Link Here
|
| 1204 |
assertEquals("33.0, 54.6!", DotAttributes.getXlp(n)); |
1602 |
assertEquals("33.0, 54.6!", DotAttributes.getXlp(n)); |
| 1205 |
assertTrue(EcoreUtil.equals(DotAttributes.getXlpParsed(n), xlp)); |
1603 |
assertTrue(EcoreUtil.equals(DotAttributes.getXlpParsed(n), xlp)); |
| 1206 |
|
1604 |
|
| 1207 |
// TODO: add test cases for setting invalid node exterior label |
1605 |
// set invalid string values |
| 1208 |
// positions |
1606 |
try { |
|
|
1607 |
DotAttributes.setXlp(n, "foo"); |
| 1608 |
fail("Expecting IllegalArgumentException."); |
| 1609 |
} catch (IllegalArgumentException e) { |
| 1610 |
assertEquals( |
| 1611 |
"Cannot set node attribute 'xlp' to 'foo'. The value 'foo' is not a syntactically correct point: No viable alternative at character 'f'. No viable alternative at character 'o'. No viable alternative at character 'o'.", |
| 1612 |
e.getMessage()); |
| 1613 |
} |
| 1209 |
} |
1614 |
} |
| 1210 |
} |
1615 |
} |