Changeset 3025 in josm for trunk/test/unit/org/openstreetmap/josm
- Timestamp:
- 2010-02-19T21:43:42+01:00 (15 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/osm/APIDataSetTest.java
r2620 r3025 37 37 @Test 38 38 public void newParentChildPair() { 39 DataSet ds = new DataSet(); 39 40 Relation r1 = new Relation(); 41 ds.addPrimitive(r1); 40 42 r1.put("name", "r1"); 41 43 42 44 Relation r2 = new Relation(); 45 ds.addPrimitive(r2); 43 46 r2.put("name", "r2"); 44 47 45 48 r1.addMember(new RelationMember("", r2)); 46 47 DataSet ds = new DataSet();48 ds.addPrimitive(r1);49 ds.addPrimitive(r2);50 49 51 50 APIDataSet apiDataSet = new APIDataSet(); … … 65 64 @Test 66 65 public void oneExistingAndThreNewInAChain() { 66 DataSet ds = new DataSet(); 67 67 68 Relation r1 = new Relation(); 69 ds.addPrimitive(r1); 68 70 r1.put("name", "r1"); 69 71 70 72 Relation r2 = new Relation(); 73 ds.addPrimitive(r2); 71 74 r2.put("name", "r2"); 72 75 73 76 Relation r3 = new Relation(); 77 ds.addPrimitive(r3); 74 78 r3.put("name", "r3"); 75 79 76 80 Relation r4 = new Relation(1, 1); 81 ds.addPrimitive(r4); 77 82 r4.put("name", "r4"); 78 83 r4.setModified(true); … … 80 85 r1.addMember(new RelationMember("", r2)); 81 86 r2.addMember(new RelationMember("", r3)); 82 83 DataSet ds = new DataSet();84 ds.addPrimitive(r1);85 ds.addPrimitive(r2);86 ds.addPrimitive(r3);87 ds.addPrimitive(r4);88 87 89 88 APIDataSet apiDataSet = new APIDataSet(); … … 108 107 @Test 109 108 public void oneParentTwoNewChildren() { 109 DataSet ds = new DataSet(); 110 110 Relation r1 = new Relation(); 111 ds.addPrimitive(r1); 111 112 r1.put("name", "r1"); 112 113 113 114 Relation r2 = new Relation(); 115 ds.addPrimitive(r2); 114 116 r2.put("name", "r2"); 115 117 116 118 Relation r3 = new Relation(); 119 ds.addPrimitive(r3); 117 120 r3.put("name", "r3"); 118 121 … … 120 123 r1.addMember(new RelationMember("", r3)); 121 124 122 DataSet ds = new DataSet();123 ds.addPrimitive(r1);124 ds.addPrimitive(r2);125 ds.addPrimitive(r3);126 125 127 126 APIDataSet apiDataSet = new APIDataSet(); … … 141 140 @Test 142 141 public void oneCycle() { 142 DataSet ds = new DataSet(); 143 143 Relation r1 = new Relation(); 144 ds.addPrimitive(r1); 144 145 r1.put("name", "r1"); 145 146 146 147 Relation r2 = new Relation(); 148 ds.addPrimitive(r2); 147 149 r2.put("name", "r2"); 148 150 149 151 Relation r3 = new Relation(); 152 ds.addPrimitive(r3); 150 153 r3.put("name", "r3"); 151 154 … … 153 156 r2.addMember(new RelationMember("", r3)); 154 157 r3.addMember(new RelationMember("", r1)); 155 156 DataSet ds = new DataSet();157 ds.addPrimitive(r1);158 ds.addPrimitive(r2);159 ds.addPrimitive(r3);160 158 161 159 APIDataSet apiDataSet = new APIDataSet(); -
trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java
r2620 r3025 7 7 import static org.junit.Assert.assertTrue; 8 8 9 import java.io.StringWriter; 9 10 import java.util.Arrays; 10 11 import java.util.Calendar; … … 12 13 import java.util.GregorianCalendar; 13 14 15 import org.junit.After; 14 16 import org.junit.Before; 15 17 import org.junit.Test; … … 55 57 }*/ 56 58 59 private DataSet my; 60 private DataSet their; 61 57 62 @Before 58 63 public void setUp() { 59 64 User.clearUserMap(); 65 my = new DataSet(); 66 my.setVersion("0.6"); 67 their = new DataSet(); 68 their.setVersion("0.6"); 69 } 70 71 private void runConsistencyTests(DataSet ds) throws Exception { 72 StringWriter writer = new StringWriter(); 73 DatasetConsistencyTest test = new DatasetConsistencyTest(ds, writer); 74 test.checkReferrers(); 75 test.checkCompleteWaysWithIncompleteNodes(); 76 test.searchNodes(); 77 test.searchWays(); 78 test.referredPrimitiveNotInDataset(); 79 test.checkZeroNodesWays(); 80 String result = writer.toString(); 81 if (result.length() > 0) 82 throw new RuntimeException(result); 83 } 84 85 @After 86 public void checkDatasets() throws Exception { 87 runConsistencyTests(my); 88 runConsistencyTests(their); 60 89 } 61 90 … … 68 97 @Test 69 98 public void nodeSimple_IdenticalNoConflict() { 70 DataSet my = new DataSet();71 my.setVersion("0.6");72 99 Node n = new Node(new LatLon(0,0)); 73 100 n.setOsmId(1,1); … … 76 103 my.addPrimitive(n); 77 104 78 DataSet their = new DataSet();79 their.setVersion("0.6");80 105 Node n1 = new Node(new LatLon(0,0)); 81 106 n1.setOsmId(1,1); … … 107 132 @Test 108 133 public void nodeSimple_locallyUnmodifiedNoConflict() { 109 DataSet my = new DataSet();110 my.setVersion("0.6");111 134 Node n = new Node(new LatLon(0,0)); 112 135 n.setOsmId(1,1); … … 115 138 my.addPrimitive(n); 116 139 117 DataSet their = new DataSet();118 their.setVersion("0.6");119 140 Node n1 = new Node(new LatLon(0,0)); 120 141 n1.setOsmId(1,2); … … 151 172 @Test 152 173 public void nodeSimple_TagConflict() { 153 DataSet my = new DataSet();154 my.setVersion("0.6");155 174 Node n = new Node(new LatLon(0,0)); 156 175 n.setOsmId(1,1); … … 160 179 my.addPrimitive(n); 161 180 162 DataSet their = new DataSet();163 their.setVersion("0.6");164 181 Node n1 = new Node(new LatLon(0,0)); 165 182 n1.setOsmId(1,2); … … 189 206 @Test 190 207 public void nodeSimple_DeleteConflict() { 191 DataSet my = new DataSet();192 my.setVersion("0.6");193 208 Node n = new Node(1, 1); 194 209 n.setCoor(new LatLon(0,0)); … … 197 212 my.addPrimitive(n); 198 213 199 DataSet their = new DataSet();200 their.setVersion("0.6");201 214 Node n1 = new Node(new LatLon(0,0)); 202 215 n1.setOsmId(1,2); … … 224 237 @Test 225 238 public void nodeSimple_VisibleConflict() { 226 DataSet my = new DataSet();227 my.setVersion("0.6");228 239 Node n = new Node(new LatLon(0,0)); 229 240 n.setOsmId(1,1); … … 232 243 my.addPrimitive(n); 233 244 234 DataSet their = new DataSet();235 their.setVersion("0.6");236 245 Node n1 = new Node(new LatLon(0,0)); 237 246 n1.setOsmId(1,2); … … 260 269 @Test 261 270 public void nodeSimple_DeleteConflict_2() { 262 DataSet my = new DataSet();263 my.setVersion("0.6");264 271 Node n = new Node(new LatLon(0,0)); 265 272 n.setOsmId(1,1); … … 267 274 my.addPrimitive(n); 268 275 269 DataSet their = new DataSet();270 their.setVersion("0.6");271 276 Node n1 = new Node(new LatLon(0,0)); 272 277 n1.setOsmId(1,1); … … 293 298 @Test 294 299 public void nodeSimple_DeleteConflict_3() { 295 DataSet my = new DataSet();296 my.setVersion("0.6");297 300 Node n = new Node(new LatLon(1,1)); 298 301 n.setDeleted(true); 299 302 my.addPrimitive(n); 300 303 301 DataSet their = new DataSet();302 their.setVersion("0.6");303 304 Node n1 = new Node(new LatLon(1,1)); 304 305 their.addPrimitive(n1); … … 321 322 @Test 322 323 public void nodeSimple_DeleteConflict_4() { 323 DataSet my = new DataSet();324 my.setVersion("0.6");325 324 Node n = new Node(new LatLon(1,1)); 326 325 n.setDeleted(true); 327 326 my.addPrimitive(n); 328 327 329 DataSet their = new DataSet();330 their.setVersion("0.6");331 328 Node n1 = new Node(new LatLon(1,1)); 332 329 n1.setDeleted(true); … … 351 348 @Test 352 349 public void nodeSimple_InvisibleNodeInTheirDataset() { 353 DataSet my = new DataSet();354 my.setVersion("0.6");355 350 Node n = new Node(new LatLon(0,0)); 356 351 n.setOsmId(1,1); … … 358 353 my.addPrimitive(n); 359 354 360 DataSet their = new DataSet();361 their.setVersion("0.6");362 355 Node n1 = new Node(new LatLon(0,0)); 363 356 n1.setOsmId(2,1); … … 390 383 User theirUser = User.createOsmUser(222, "their"); 391 384 392 DataSet my = new DataSet();393 my.setVersion("0.6");394 385 Node n = new Node(); 395 386 n.setCoor(new LatLon(0,0)); … … 400 391 my.addPrimitive(n); 401 392 402 DataSet their = new DataSet();403 their.setVersion("0.6");404 393 Node n1 = new Node(); 405 394 n1.setCoor(new LatLon(0,0)); … … 434 423 public void nodeSimple_IncompleteNode() { 435 424 436 DataSet my = new DataSet();437 my.setVersion("0.6");438 425 Node n = new Node(1); 439 426 my.addPrimitive(n); 440 427 441 DataSet their = new DataSet();442 their.setVersion("0.6");443 428 Node n1 = new Node(); 444 429 n1.setCoor(new LatLon(0,0)); … … 472 457 473 458 // -- the target dataset 474 DataSet target = new DataSet();475 target.setVersion("0.6");476 459 477 460 Node n1 = new Node(); 478 461 n1.setCoor(new LatLon(0,0)); 479 462 n1.setOsmId(1,1); 480 target.addPrimitive(n1);463 my.addPrimitive(n1); 481 464 482 465 Node n2 = new Node(); … … 484 467 n2.setOsmId(2,1); 485 468 486 target.addPrimitive(n2);469 my.addPrimitive(n2); 487 470 488 471 Way myWay = new Way(); … … 491 474 myWay.addNode(n1); 492 475 myWay.addNode(n2); 493 target.addPrimitive(myWay);476 my.addPrimitive(myWay); 494 477 495 478 // -- the source data set 496 DataSet source = new DataSet();497 source.setVersion("0.6");498 479 499 480 Node n3 = new Node(new LatLon(0,0)); 500 481 n3.setOsmId(1,1); 501 source.addPrimitive(n3);482 their.addPrimitive(n3); 502 483 503 484 Node n4 = new Node(new LatLon(1,1)); 504 485 n4.setOsmId(2,1); 505 source.addPrimitive(n4);486 their.addPrimitive(n4); 506 487 507 488 Way theirWay = new Way(); … … 511 492 theirWay.addNode(n3); 512 493 theirWay.addNode(n4); 513 source.addPrimitive(theirWay);514 515 516 DataSetMerger visitor = new DataSetMerger( target,source);494 their.addPrimitive(theirWay); 495 496 497 DataSetMerger visitor = new DataSetMerger(my,their); 517 498 visitor.merge(); 518 499 519 500 // -- tests 520 Way merged = (Way) target.getPrimitiveById(3, OsmPrimitiveType.WAY);501 Way merged = (Way)my.getPrimitiveById(3, OsmPrimitiveType.WAY); 521 502 assertEquals(0,visitor.getConflicts().size()); 522 503 assertEquals("value1",merged.get("key1")); … … 528 509 assertEquals(2,merged.getNode(1).getId()); 529 510 assertTrue(merged == myWay); 530 assertTrue(merged.getDataSet() == target);531 532 Node mergedNode = (Node) target.getPrimitiveById(1, OsmPrimitiveType.NODE);511 assertTrue(merged.getDataSet() == my); 512 513 Node mergedNode = (Node)my.getPrimitiveById(1, OsmPrimitiveType.NODE); 533 514 assertTrue(mergedNode == n1); 534 mergedNode = (Node) target.getPrimitiveById(2, OsmPrimitiveType.NODE);515 mergedNode = (Node)my.getPrimitiveById(2, OsmPrimitiveType.NODE); 535 516 assertTrue(mergedNode == n2); 536 517 … … 549 530 550 531 // -- my data set 551 DataSet my = new DataSet();552 my.setVersion("0.6");553 532 554 533 Node n1 = new Node(new LatLon(0,0)); … … 567 546 568 547 // --- their data set 569 DataSet their = new DataSet();570 their.setVersion("0.6");571 548 572 549 Node n3 = new Node(new LatLon(0,0)); … … 624 601 625 602 // -- the target dataset 626 DataSet target = new DataSet();627 target.setVersion("0.6");628 603 629 604 Node n1 = new Node(new LatLon(0,0)); 630 605 n1.setOsmId(1,1); 631 target.addPrimitive(n1);606 my.addPrimitive(n1); 632 607 633 608 Node n2 = new Node(new LatLon(1,1)); 634 609 n2.setOsmId(2,1); 635 target.addPrimitive(n2);610 my.addPrimitive(n2); 636 611 637 612 Way myWay = new Way(); … … 642 617 myWay.setModified(true); 643 618 myWay.put("key1", "value1"); 644 target.addPrimitive(myWay);619 my.addPrimitive(myWay); 645 620 646 621 // -- the source dataset 647 DataSet source = new DataSet();648 source.setVersion("0.6");649 622 650 623 Node n3 = new Node(new LatLon(0,0)); 651 624 n3.setOsmId(1,1); 652 source.addPrimitive(n3);625 their.addPrimitive(n3); 653 626 654 627 Node n5 = new Node(new LatLon(1,1)); 655 628 n5.setOsmId(4,1); 656 source.addPrimitive(n5);629 their.addPrimitive(n5); 657 630 658 631 Node n4 = new Node(new LatLon(2,2)); 659 632 n4.setOsmId(2,1); 660 633 n4.put("key1", "value1"); 661 source.addPrimitive(n4);634 their.addPrimitive(n4); 662 635 663 636 … … 668 641 theirWay.addNode(n5); // insert a node 669 642 theirWay.addNode(n4); // this one is updated 670 source.addPrimitive(theirWay);671 672 673 DataSetMerger visitor = new DataSetMerger( target,source);674 visitor.merge(); 675 676 Way merged = (Way) target.getPrimitiveById(3, OsmPrimitiveType.WAY);643 their.addPrimitive(theirWay); 644 645 646 DataSetMerger visitor = new DataSetMerger(my, their); 647 visitor.merge(); 648 649 Way merged = (Way)my.getPrimitiveById(3, OsmPrimitiveType.WAY); 677 650 assertEquals(1,visitor.getConflicts().size()); 678 651 assertEquals(3,merged.getId()); … … 694 667 public void waySimple_TheirVersionNotVisible() { 695 668 696 DataSet my = new DataSet(); 697 my.setVersion("0.6"); 698 699 Node n1 = new Node(new LatLon(0,0)); 700 n1.setOsmId(1,1); 701 my.addPrimitive(n1); 702 703 Node n2 = new Node(new LatLon(1,1)); 704 n2.setOsmId(2,1); 705 my.addPrimitive(n2); 669 670 Node mn1 = new Node(new LatLon(0,0)); 671 mn1.setOsmId(1,1); 672 my.addPrimitive(mn1); 673 674 Node mn2 = new Node(new LatLon(1,1)); 675 mn2.setOsmId(2,1); 676 my.addPrimitive(mn2); 706 677 707 678 Way myWay = new Way(); 708 679 myWay.setOsmId(3,1); 709 myWay.addNode(n1); 710 myWay.addNode(n2); 680 myWay.addNode(mn1); 681 myWay.addNode(mn2); 711 682 my.addPrimitive(myWay); 712 683 713 DataSet their = new DataSet();714 their.setVersion("0.6");715 684 716 685 Way theirWay = new Way(); … … 739 708 740 709 // -- my data set 741 DataSet my = new DataSet();742 my.setVersion("0.6");743 710 744 711 Node n1 = new Node(new LatLon(0,0)); … … 756 723 757 724 // -- their data set 758 DataSet their = new DataSet();759 their.setVersion("0.6");760 725 761 726 Node n3 = new Node(new LatLon(0,0)); … … 801 766 802 767 // -- my data set 803 DataSet my = new DataSet();804 my.setVersion("0.6");805 768 806 769 Node n1 = new Node(new LatLon(0,0)); … … 816 779 817 780 // -- their data set 818 DataSet their = new DataSet();819 their.setVersion("0.6");820 781 821 782 Node n3 = new Node(new LatLon(0,0)); … … 855 816 * 856 817 * => the merged way should include two nodes only. the deleted node should still be 857 * in the data set 818 * in the data set. 858 819 * 859 820 */ … … 862 823 863 824 // -- my dataset 864 DataSet my = new DataSet(); 865 my.setVersion("0.6"); 866 867 Node n1 = new Node(new LatLon(0,0)); 868 n1.setOsmId(1,1); 869 n1.setDeleted(true); 870 my.addPrimitive(n1); 871 872 DataSet their = new DataSet(); 873 their.setVersion("0.6"); 874 875 Node n3 = new Node(new LatLon(0,0)); 876 n3.setOsmId(1,1); 877 their.addPrimitive(n3); 878 879 Node n4 = new Node(new LatLon(1,1)); 880 n4.setOsmId(2,1); 881 their.addPrimitive(n4); 882 883 Node n5 = new Node(new LatLon(2,2)); 884 n5.setOsmId(3,1); 885 their.addPrimitive(n5); 825 826 Node mn1 = new Node(new LatLon(0,0)); 827 mn1.setOsmId(1,1); 828 mn1.setDeleted(true); 829 my.addPrimitive(mn1); 830 831 832 Node tn1 = new Node(new LatLon(0,0)); 833 tn1.setOsmId(1,1); 834 their.addPrimitive(tn1); 835 836 Node tn2 = new Node(new LatLon(1,1)); 837 tn2.setOsmId(2,1); 838 their.addPrimitive(tn2); 839 840 Node tn3 = new Node(new LatLon(2,2)); 841 tn3.setOsmId(3,1); 842 their.addPrimitive(tn3); 886 843 887 844 // -- their data set 888 845 Way theirWay = new Way(); 889 846 theirWay.setOsmId(4,1); 890 theirWay.addNode( n3);891 theirWay.addNode( n4);892 theirWay.addNode( n5);847 theirWay.addNode(tn1); 848 theirWay.addNode(tn2); 849 theirWay.addNode(tn3); 893 850 User user = User.getById(1111); 894 851 if (user == null) { … … 902 859 visitor.merge(); 903 860 904 assertEquals( 0,visitor.getConflicts().size());905 906 Way myWay = (Way)my.getPrimitiveById(4,OsmPrimitiveType.WAY); 907 assertEquals( 2, myWay.getNodesCount());861 assertEquals(1, visitor.getConflicts().size()); 862 863 Way myWay = (Way)my.getPrimitiveById(4, OsmPrimitiveType.WAY); 864 assertEquals(3, myWay.getNodesCount()); 908 865 909 866 Node n = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE); … … 926 883 public void relationComplex_mergingADeletedNode() { 927 884 928 DataSet my = new DataSet();929 my.setVersion("0.6");930 885 931 886 Node n1 = new Node(new LatLon(0,0)); … … 934 889 my.addPrimitive(n1); 935 890 936 DataSet their = new DataSet();937 their.setVersion("0.6");938 891 939 892 Node n3 = new Node(new LatLon(0,0)); … … 979 932 @Test 980 933 public void newIncompleteWay() { 981 DataSet source = new DataSet();982 source.setVersion("0.6");983 934 984 935 Node n1 = new Node(1); 985 source.addPrimitive(n1);936 their.addPrimitive(n1); 986 937 987 938 Node n2 = new Node(2); 988 source.addPrimitive(n2);939 their.addPrimitive(n2); 989 940 990 941 Way w3 = new Way(3); 991 942 w3.setNodes(Arrays.asList(n1,n2)); 992 source.addPrimitive(w3);943 their.addPrimitive(w3); 993 944 assertTrue(w3.isIncomplete()); 994 945 995 DataSet target = new DataSet(); 996 target.setVersion("0.6"); 997 998 DataSetMerger visitor = new DataSetMerger(target,source); 999 visitor.merge(); 1000 1001 assertEquals(0,visitor.getConflicts().size()); 1002 1003 OsmPrimitive p= target.getPrimitiveById(1, OsmPrimitiveType.NODE); 946 947 DataSetMerger visitor = new DataSetMerger(my, their); 948 visitor.merge(); 949 950 assertEquals(0,visitor.getConflicts().size()); 951 952 OsmPrimitive p= my.getPrimitiveById(1, OsmPrimitiveType.NODE); 1004 953 assertNotNull(p); 1005 954 assertTrue(p.isIncomplete()); 1006 p= target.getPrimitiveById(2, OsmPrimitiveType.NODE);955 p= my.getPrimitiveById(2, OsmPrimitiveType.NODE); 1007 956 assertNotNull(p); 1008 957 assertTrue(p.isIncomplete()); 1009 p= target.getPrimitiveById(3, OsmPrimitiveType.WAY);958 p= my.getPrimitiveById(3, OsmPrimitiveType.WAY); 1010 959 assertNotNull(p); 1011 960 assertTrue(p.isIncomplete()); 1012 961 1013 Way w = (Way) target.getPrimitiveById(3, OsmPrimitiveType.WAY);962 Way w = (Way)my.getPrimitiveById(3, OsmPrimitiveType.WAY); 1014 963 assertNotNull(w); 1015 964 assertTrue(p.isIncomplete()); … … 1026 975 @Test 1027 976 public void incompleteWayOntoCompleteWay() { 1028 DataSet their = new DataSet();1029 their.setVersion("0.6");1030 977 1031 978 // an incomplete node … … 1042 989 their.addPrimitive(w3); 1043 990 1044 DataSet my = new DataSet();1045 my.setVersion("0.6");1046 991 1047 992 Node n4 = new Node(new LatLon(0,0)); … … 1088 1033 1089 1034 // -- source dataset 1090 DataSet source = new DataSet();1091 source.setVersion("0.6");1092 1035 1093 1036 // an complete node 1094 1037 Node n1 = new Node(1, 1); 1095 1038 n1.setCoor(new LatLon(1,1)); 1096 source.addPrimitive(n1);1039 their.addPrimitive(n1); 1097 1040 1098 1041 // another complete node 1099 1042 Node n2 = new Node(2, 1); 1100 1043 n2.setCoor(new LatLon(2,2)); 1101 source.addPrimitive(n2);1044 their.addPrimitive(n2); 1102 1045 1103 1046 // --- target dataset 1104 DataSet target = new DataSet();1105 target.setVersion("0.6");1106 1047 1107 1048 Node n4 = new Node(1); 1108 target.addPrimitive(n4);1049 my.addPrimitive(n4); 1109 1050 1110 1051 Node n5 = new Node(2); 1111 target.addPrimitive(n5);1052 my.addPrimitive(n5); 1112 1053 1113 1054 Way w6 = new Way(3, 1); 1114 1055 w6.addNode(n4); 1115 1056 w6.addNode(n5); 1116 target.addPrimitive(w6);1057 my.addPrimitive(w6); 1117 1058 1118 1059 //-- merge it 1119 DataSetMerger visitor = new DataSetMerger( target,source);1060 DataSetMerger visitor = new DataSetMerger(my, their); 1120 1061 visitor.merge(); 1121 1062 … … 1123 1064 assertEquals(0,visitor.getConflicts().size()); 1124 1065 1125 Node n = (Node) target.getPrimitiveById(1, OsmPrimitiveType.NODE);1066 Node n = (Node)my.getPrimitiveById(1, OsmPrimitiveType.NODE); 1126 1067 assertNotNull(n); 1127 1068 assertFalse(n.isIncomplete()); 1128 1069 1129 n = (Node) target.getPrimitiveById(2, OsmPrimitiveType.NODE);1070 n = (Node)my.getPrimitiveById(2, OsmPrimitiveType.NODE); 1130 1071 assertNotNull(n); 1131 1072 assertFalse(n.isIncomplete()); 1132 1073 1133 Way w = (Way) target.getPrimitiveById(3, OsmPrimitiveType.WAY);1074 Way w = (Way)my.getPrimitiveById(3, OsmPrimitiveType.WAY); 1134 1075 assertNotNull(w); 1135 1076 assertFalse(w.hasIncompleteNodes()); -
trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java
r2620 r3025 151 151 public void test_OneRelation_ExistingMembersSelected() { 152 152 DataSet source = new DataSet(); 153 Relation r1 = new Relation(1); 153 Relation r1 = new Relation(1, 1); 154 154 Node n20 = new Node(20, 1); 155 n20.setCoor(new LatLon(0, 0)); 155 156 r1.addMember(new RelationMember("node-20",n20)); 156 157 Way w30 = new Way(30, 1); 157 Node n21; 158 w30.addNode(n21 = new Node(21));159 Node n22; 160 w30.addNode(n22 = new Node(22));158 Node n21 = new Node(21); 159 w30.addNode(n21); 160 Node n22 = new Node(22); 161 w30.addNode(n22); 161 162 r1.addMember(new RelationMember("way-30",w30)); 162 163 Relation r40 = new Relation(40); … … 166 167 source.addPrimitive(n22); 167 168 source.addPrimitive(w30); 168 source.addPrimitive(r1);169 169 source.addPrimitive(r40); 170 source.addPrimitive(r1); 170 171 source.setSelected(r1,n20,w30,r40); 171 172 … … 209 210 public void test_OneRelation_ExistingMembersNotSelected() { 210 211 DataSet source = new DataSet(); 211 Relation r1 = new Relation(1); 212 Relation r1 = new Relation(1, 1); 212 213 Node n20 = new Node(20); 213 214 r1.addMember(new RelationMember("node-20",n20)); … … 224 225 source.addPrimitive(n22); 225 226 source.addPrimitive(w30); 226 source.addPrimitive(r1);227 227 source.addPrimitive(r40); 228 source.addPrimitive(r1); 228 229 source.setSelected(r1); 229 230 … … 291 292 source.addPrimitive(n22); 292 293 source.addPrimitive(w30); 293 source.addPrimitive(r1);294 294 source.addPrimitive(r40); 295 source.addPrimitive(r1); 295 296 source.setSelected(r1); 296 297 … … 335 336 public void test_OneRelation_Existing_Recursive() { 336 337 DataSet source = new DataSet(); 337 Relation r1 = new Relation(1); 338 Relation r1 = new Relation(1, 1); 338 339 r1.addMember(new RelationMember("relation-1",r1)); 339 340 source.addPrimitive(r1); … … 374 375 public void test_TwoRelation_Existing_Circular() { 375 376 DataSet source = new DataSet(); 376 Relation r1 = new Relation(1); 377 Relation r2 = new Relation(2); 377 Relation r1 = new Relation(1, 1); 378 source.addPrimitive(r1); 379 Relation r2 = new Relation(2, 3); 380 source.addPrimitive(r2); 378 381 r1.addMember(new RelationMember("relation-2",r2)); 379 382 r2.addMember(new RelationMember("relation-1",r1)); 380 source.addPrimitive(r1);381 source.addPrimitive(r2);382 383 source.setSelected(r1,r2); 383 384 -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/nodes/NodeListMergeModelTest.java
r2990 r3025 17 17 18 18 import org.junit.Test; 19 import org.openstreetmap.josm.data.osm.DatasetFactory; 19 20 import org.openstreetmap.josm.data.osm.Node; 20 21 import org.openstreetmap.josm.data.osm.Way; … … 23 24 public class NodeListMergeModelTest { 24 25 26 private DatasetFactory my = new DatasetFactory(); 27 private DatasetFactory their = new DatasetFactory(); 28 29 @SuppressWarnings("unchecked") 25 30 protected List<Node> inspectNodeList(NodeListMergeModel model, String name) { 26 31 return method("get" + name + "Entries") … … 46 51 try { 47 52 int rows[] = (int[])idx[i]; 48 if (rows == null || rows.length != 2) {53 if (rows.length != 2) { 49 54 fail("illegal selection range. Either null or not length 2: " + Arrays.toString(rows)); 50 55 } … … 65 70 NodeListMergeModel model = new NodeListMergeModel(); 66 71 67 Way myWay = new Way(1, 1); 68 myWay.addNode(new Node(2)); 69 myWay.addNode(new Node(3)); 70 Way theirWay = new Way(1); 72 Way myWay = my.addWay(1, 1); 73 myWay.addNode(my.addNode(2)); 74 myWay.addNode(my.addNode(3)); 75 76 Way theirWay = their.addWay(1); 71 77 72 78 model.populate(myWay, theirWay); … … 88 94 NodeListMergeModel model = new NodeListMergeModel(); 89 95 90 91 Way myWay = new Way(1, 1);92 myWay.addNode( new Node(2));93 myWay.addNode(new Node(3)); 94 Way theirWay = newWay(1);96 Way myWay = my.addWay(1, 1); 97 myWay.addNode(my.addNode(2)); 98 myWay.addNode(my.addNode(3)); 99 100 Way theirWay = their.addWay(1); 95 101 96 102 model.populate(myWay, theirWay); … … 111 117 } 112 118 113 114 115 116 117 119 @Test 118 120 public void test_copyMyNodesToTop_3() { 119 121 NodeListMergeModel model = new NodeListMergeModel(); 120 122 121 122 Way myWay = new Way(1, 1); 123 myWay.addNode(new Node(2)); 124 myWay.addNode(new Node(3)); 125 Way theirWay = new Way(1); 123 Way myWay = my.addWay(1, 1); 124 myWay.addNode(my.addNode(2)); 125 myWay.addNode(my.addNode(3)); 126 Way theirWay = their.addWay(1); 126 127 127 128 … … 146 147 NodeListMergeModel model = new NodeListMergeModel(); 147 148 148 149 Way myWay = new Way(1, 1); 150 myWay.addNode(new Node(2)); 151 myWay.addNode(new Node(3)); 152 myWay.addNode(new Node(4)); 153 Way theirWay = new Way(1); 149 Way myWay = my.addWay(1, 1); 150 myWay.addNode(my.addNode(2)); 151 myWay.addNode(my.addNode(3)); 152 myWay.addNode(my.addNode(4)); 153 Way theirWay = their.addWay(1); 154 154 155 155 model.populate(myWay, theirWay); … … 175 175 NodeListMergeModel model = new NodeListMergeModel(); 176 176 177 Way myWay = newWay(1, 1);178 myWay.addNode( newNode(2));179 myWay.addNode( newNode(3));180 Way theirWay = newWay(1);177 Way myWay = my.addWay(1, 1); 178 myWay.addNode(my.addNode(2)); 179 myWay.addNode(my.addNode(3)); 180 Way theirWay = their.addWay(1); 181 181 182 182 model.populate(myWay, theirWay); … … 196 196 NodeListMergeModel model = new NodeListMergeModel(); 197 197 198 Way myWay = newWay(1, 1);199 myWay.addNode( newNode(2));200 myWay.addNode( newNode(3));201 Way theirWay = newWay(1);198 Way myWay = my.addWay(1, 1); 199 myWay.addNode(my.addNode(2)); 200 myWay.addNode(my.addNode(3)); 201 Way theirWay = their.addWay(1); 202 202 203 203 model.populate(myWay, theirWay); … … 222 222 223 223 224 Way myWay = newWay(1, 1);225 myWay.addNode( newNode(2));226 myWay.addNode( newNode(3));227 Way theirWay = newWay(1);224 Way myWay = my.addWay(1, 1); 225 myWay.addNode(my.addNode(2)); 226 myWay.addNode(my.addNode(3)); 227 Way theirWay = their.addWay(1); 228 228 229 229 model.populate(myWay, theirWay); … … 249 249 250 250 251 Way myWay = newWay(1, 1);252 myWay.addNode( newNode(2));253 myWay.addNode( newNode(3));254 myWay.addNode( newNode(4));255 Way theirWay = newWay(1);251 Way myWay = my.addWay(1, 1); 252 myWay.addNode(my.addNode(2)); 253 myWay.addNode(my.addNode(3)); 254 myWay.addNode(my.addNode(4)); 255 Way theirWay = their.addWay(1); 256 256 257 257 model.populate(myWay, theirWay); … … 281 281 NodeListMergeModel model = new NodeListMergeModel(); 282 282 283 Way myWay = newWay(1, 1);284 myWay.addNode( newNode(1));285 myWay.addNode( newNode(2));286 Way theirWay = newWay(1);283 Way myWay = my.addWay(1, 1); 284 myWay.addNode(my.addNode(1)); 285 myWay.addNode(my.addNode(2)); 286 Way theirWay = their.addWay(1); 287 287 288 288 model.populate(myWay, theirWay); … … 309 309 NodeListMergeModel model = new NodeListMergeModel(); 310 310 311 Way myWay = newWay(1, 1);312 myWay.addNode( newNode(1));313 myWay.addNode( newNode(2));314 Way theirWay = newWay(1);311 Way myWay = my.addWay(1, 1); 312 myWay.addNode(my.addNode(1)); 313 myWay.addNode(my.addNode(2)); 314 Way theirWay = their.addWay(1); 315 315 316 316 model.populate(myWay, theirWay); … … 337 337 NodeListMergeModel model = new NodeListMergeModel(); 338 338 339 Way myWay = newWay(1, 1);340 myWay.addNode( newNode(1));341 myWay.addNode( newNode(2));342 Way theirWay = newWay(1);339 Way myWay = my.addWay(1, 1); 340 myWay.addNode(my.addNode(1)); 341 myWay.addNode(my.addNode(2)); 342 Way theirWay = their.addWay(1); 343 343 344 344 model.populate(myWay, theirWay); … … 356 356 357 357 try { 358 model.copyMyBeforeCurrent(new int[]{0,1}, 3);358 model.copyMyBeforeCurrent(new int[]{0,1}, 4); 359 359 fail("expected IllegalArgumentException"); 360 360 } catch(IllegalArgumentException e) { … … 370 370 NodeListMergeModel model = new NodeListMergeModel(); 371 371 372 Way myWay = newWay(1, 1);373 myWay.addNode( newNode(1));374 myWay.addNode( newNode(2));375 Way theirWay = newWay(1);372 Way myWay = my.addWay(1, 1); 373 myWay.addNode(my.addNode(1)); 374 myWay.addNode(my.addNode(2)); 375 Way theirWay = their.addWay(1); 376 376 377 377 model.populate(myWay, theirWay); … … 398 398 NodeListMergeModel model = new NodeListMergeModel(); 399 399 400 Way myWay = newWay(1, 1);401 myWay.addNode( newNode(1));402 myWay.addNode( newNode(2));403 myWay.addNode( newNode(3));404 Way theirWay = newWay(1);400 Way myWay = my.addWay(1, 1); 401 myWay.addNode(my.addNode(1)); 402 myWay.addNode(my.addNode(2)); 403 myWay.addNode(my.addNode(3)); 404 Way theirWay = their.addWay(1); 405 405 406 406 model.populate(myWay, theirWay); … … 428 428 NodeListMergeModel model = new NodeListMergeModel(); 429 429 430 Way myWay = newWay(1, 1);431 myWay.addNode( newNode(1));432 myWay.addNode( newNode(2));433 myWay.addNode( newNode(3));434 Way theirWay = newWay(1);430 Way myWay = my.addWay(1, 1); 431 myWay.addNode(my.addNode(1)); 432 myWay.addNode(my.addNode(2)); 433 myWay.addNode(my.addNode(3)); 434 Way theirWay = their.addWay(1); 435 435 436 436 model.populate(myWay, theirWay); … … 453 453 } 454 454 455 @Test456 public void test_copyMyNodesAfterCurrent_4() {457 NodeListMergeModel model = new NodeListMergeModel();458 459 Way myWay = new Way(1, 1);460 myWay.addNode(new Node(1));461 myWay.addNode(new Node(2));462 Way theirWay = new Way(1);463 464 model.populate(myWay, theirWay);465 List<Node> mergedNodes = inspectNodeList(model, "Merged");466 mergedNodes.add(new Node(10));467 mergedNodes.add(new Node(11));468 mergedNodes.add(new Node(12));469 470 try {471 model.copyMyAfterCurrent(new int[]{0,1}, -1);472 fail("expected IllegalArgumentException");473 } catch(IllegalArgumentException e) {474 // OK475 }476 477 try {478 model.copyMyAfterCurrent(new int[]{0,1}, 3);479 fail("expected IllegalArgumentException");480 } catch(IllegalArgumentException e) {481 // OK482 }483 }484 455 485 456 /* ----------------------------------------------------------------------------- */ … … 664 635 /* PropertyChangeListener */ 665 636 /* ----------------------------------------------------------------------------- */ 637 @SuppressWarnings("unchecked") 666 638 @Test 667 639 public void addPropertyChangeListener() { … … 676 648 model.addPropertyChangeListener(listener); 677 649 678 ArrayList<PropertyChangeListener> listeners = field("listeners")679 .ofType( ArrayList.class)650 List<PropertyChangeListener> listeners = field("listeners") 651 .ofType(List.class) 680 652 .in(model) 681 653 .get(); … … 685 657 } 686 658 659 @SuppressWarnings("unchecked") 687 660 @Test 688 661 public void removePropertyChangeListener() { … … 698 671 model.removePropertyChangeListener(listener); 699 672 700 ArrayList<PropertyChangeListener> listeners = field("listeners")701 .ofType( ArrayList.class)673 List<PropertyChangeListener> listeners = field("listeners") 674 .ofType(List.class) 702 675 .in(model) 703 676 .get(); -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java
r1954 r3025 2 2 package org.openstreetmap.josm.gui.conflict.properties; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.Assert.assertFalse; 5 6 import static org.junit.Assert.assertTrue; 6 import static org.junit.Assert.*;7 7 8 8 import java.util.Observable; … … 13 13 import org.openstreetmap.josm.Main; 14 14 import org.openstreetmap.josm.data.coor.LatLon; 15 import org.openstreetmap.josm.data.osm.DataSet; 15 16 import org.openstreetmap.josm.data.osm.Node; 16 17 import org.openstreetmap.josm.data.osm.Relation; … … 48 49 @Test 49 50 public void populate() { 51 DataSet d1 = new DataSet(); 52 DataSet d2 = new DataSet(); 50 53 Node n1 = new Node(1); 51 54 Node n2 = new Node(1); 55 d1.addPrimitive(n1); 56 d2.addPrimitive(n2); 52 57 model.populate(n1, n2); 53 58 54 59 Way w1 = new Way(1); 55 60 Way w2 = new Way(1); 61 d1.addPrimitive(w1); 62 d2.addPrimitive(w2); 56 63 model.populate(w2, w2); 57 64 58 65 Relation r1 = new Relation(1); 59 66 Relation r2 = new Relation(1); 67 d1.addPrimitive(r1); 68 d2.addPrimitive(r2); 60 69 model.populate(r1, r2); 61 70 } … … 63 72 @Test 64 73 public void decidingAboutCoords() { 74 DataSet d1 = new DataSet(); 75 DataSet d2 = new DataSet(); 76 65 77 Node n1 = new Node(1); 66 78 Node n2 = new Node(1); 79 d1.addPrimitive(n1); 80 d2.addPrimitive(n2); 67 81 model.populate(n1, n2); 68 82 assertFalse(model.hasCoordConflict()); … … 73 87 74 88 75 n1 =new Node(1);89 n1.cloneFrom(new Node(1)); 76 90 n2.setCoor(new LatLon(2,2)); 77 91 model.populate(n1, n2); -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagMergeModelTest.java
r2990 r3025 8 8 import java.beans.PropertyChangeEvent; 9 9 import java.beans.PropertyChangeListener; 10 import java.util. ArrayList;10 import java.util.List; 11 11 12 12 import org.junit.Test; … … 29 29 model.addPropertyChangeListener(listener); 30 30 31 ArrayList<?> list = field("listeners").ofType(ArrayList.class)31 List<?> list = field("listeners").ofType(List.class) 32 32 .in(model) 33 33 .get(); … … 48 48 model.removePropertyChangeListener(listener); 49 49 50 ArrayList<?> list = field("listeners")51 .ofType( ArrayList.class)50 List<?> list = field("listeners") 51 .ofType(List.class) 52 52 .in(model) 53 53 .get(); … … 63 63 model.populate(my, their); 64 64 65 ArrayList<TagMergeItem> list = field("tagMergeItems")66 .ofType( ArrayList.class)65 List<TagMergeItem> list = field("tagMergeItems") 66 .ofType(List.class) 67 67 .in(model) 68 68 .get(); … … 80 80 model.populate(my, their); 81 81 82 ArrayList<TagMergeItem> list = field("tagMergeItems")83 .ofType( ArrayList.class)82 List<TagMergeItem> list = field("tagMergeItems") 83 .ofType(List.class) 84 84 .in(model) 85 85 .get(); … … 96 96 model.populate(my, their); 97 97 98 ArrayList<TagMergeItem> list = field("tagMergeItems")99 .ofType( ArrayList.class)98 List<TagMergeItem> list = field("tagMergeItems") 99 .ofType(List.class) 100 100 .in(model) 101 101 .get(); … … 117 117 model.populate(my, their); 118 118 119 ArrayList<TagMergeItem> list = field("tagMergeItems")120 .ofType( ArrayList.class)119 List<TagMergeItem> list = field("tagMergeItems") 120 .ofType(List.class) 121 121 .in(model) 122 122 .get(); … … 139 139 model.populate(my, their); 140 140 141 ArrayList<TagMergeItem> list = field("tagMergeItems")142 .ofType( ArrayList.class)141 List<TagMergeItem> list = field("tagMergeItems") 142 .ofType(List.class) 143 143 .in(model) 144 144 .get(); … … 158 158 model.addItem(item); 159 159 160 ArrayList<TagMergeItem> list = field("tagMergeItems")161 .ofType( ArrayList.class)160 List<TagMergeItem> list = field("tagMergeItems") 161 .ofType(List.class) 162 162 .in(model) 163 163 .get(); … … 177 177 model.addItem(item); 178 178 179 ArrayList<TagMergeItem> list = field("tagMergeItems")180 .ofType( ArrayList.class)179 List<TagMergeItem> list = field("tagMergeItems") 180 .ofType(List.class) 181 181 .in(model) 182 182 .get(); … … 207 207 } 208 208 209 ArrayList<TagMergeItem> list = field("tagMergeItems")210 .ofType( ArrayList.class)209 List<TagMergeItem> list = field("tagMergeItems") 210 .ofType(List.class) 211 211 .in(model) 212 212 .get();
Note:
See TracChangeset
for help on using the changeset viewer.