Changeset 2563 in josm for trunk/test
- Timestamp:
- 2009-12-03T19:02:25+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java
r2498 r2563 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 5 6 import static org.junit.Assert.assertNotNull; 6 7 import static org.junit.Assert.assertTrue; … … 991 992 @Test 992 993 public void newIncompleteWay() { 993 DataSet their= new DataSet();994 their.setVersion("0.6");994 DataSet source = new DataSet(); 995 source.setVersion("0.6"); 995 996 996 997 Node n1 = new Node(1); 997 their.addPrimitive(n1);998 source.addPrimitive(n1); 998 999 999 1000 Node n2 = new Node(2); 1000 their.addPrimitive(n2);1001 source.addPrimitive(n2); 1001 1002 1002 1003 Way w3 = new Way(3); 1003 1004 w3.setNodes(Arrays.asList(n1,n2)); 1004 their.addPrimitive(w3); 1005 1006 DataSet my = new DataSet(); 1007 their.setVersion("0.6"); 1008 1009 DataSetMerger visitor = new DataSetMerger(my,their); 1010 visitor.merge(); 1011 1012 assertEquals(0,visitor.getConflicts().size()); 1013 1014 OsmPrimitive p= my.getPrimitiveById(1, OsmPrimitiveType.NODE); 1005 source.addPrimitive(w3); 1006 assertTrue(w3.incomplete); 1007 1008 DataSet target = new DataSet(); 1009 target.setVersion("0.6"); 1010 1011 DataSetMerger visitor = new DataSetMerger(target,source); 1012 visitor.merge(); 1013 1014 assertEquals(0,visitor.getConflicts().size()); 1015 1016 OsmPrimitive p= target.getPrimitiveById(1, OsmPrimitiveType.NODE); 1015 1017 assertNotNull(p); 1016 1018 assertTrue(p.incomplete); 1017 p= my.getPrimitiveById(2, OsmPrimitiveType.NODE);1019 p= target.getPrimitiveById(2, OsmPrimitiveType.NODE); 1018 1020 assertNotNull(p); 1019 1021 assertTrue(p.incomplete); 1020 p= my.getPrimitiveById(3, OsmPrimitiveType.WAY);1022 p= target.getPrimitiveById(3, OsmPrimitiveType.WAY); 1021 1023 assertNotNull(p); 1022 1024 assertTrue(p.incomplete); 1023 1025 1024 Way w = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY);1026 Way w = (Way)target.getPrimitiveById(3, OsmPrimitiveType.WAY); 1025 1027 assertNotNull(w); 1026 1028 assertTrue(p.incomplete); … … 1054 1056 1055 1057 DataSet my = new DataSet(); 1056 their.setVersion("0.6");1058 my.setVersion("0.6"); 1057 1059 1058 1060 Node n4 = new Node(new LatLon(0,0)); … … 1092 1094 } 1093 1095 1096 /** 1097 * merge to complete nodes onto an incomplete way with the same two nodes, but incomplete. 1098 * => both the nodes and the way should be complete in the target dataset after merging 1099 */ 1100 @Test 1101 public void twoCompleteNodesOntoAnIncompleteWay() { 1102 1103 // -- source dataset 1104 DataSet source = new DataSet(); 1105 source.setVersion("0.6"); 1106 1107 // an complete node 1108 Node n1 = new Node(1); 1109 n1.setCoor(new LatLon(1,1)); 1110 n1.incomplete = false; 1111 source.addPrimitive(n1); 1112 1113 // another complete node 1114 Node n2 = new Node(2); 1115 n2.setCoor(new LatLon(2,2)); 1116 n2.incomplete = false; 1117 source.addPrimitive(n2); 1118 1119 // --- target daset 1120 DataSet target = new DataSet(); 1121 target.setVersion("0.6"); 1122 1123 Node n4 = new Node(1); 1124 target.addPrimitive(n4); 1125 1126 Node n5 = new Node(2); 1127 target.addPrimitive(n5); 1128 1129 Way w6 = new Way(3); 1130 w6.incomplete = false; 1131 w6.addNode(n4); 1132 w6.addNode(n5); 1133 w6.incomplete = true; 1134 target.addPrimitive(w6); 1135 1136 //-- merge it 1137 DataSetMerger visitor = new DataSetMerger(target,source); 1138 visitor.merge(); 1139 1140 // -- test it 1141 assertEquals(0,visitor.getConflicts().size()); 1142 1143 Node n = (Node)target.getPrimitiveById(1, OsmPrimitiveType.NODE); 1144 assertNotNull(n); 1145 assertFalse(n.incomplete); 1146 1147 n = (Node)target.getPrimitiveById(2, OsmPrimitiveType.NODE); 1148 assertNotNull(n); 1149 assertFalse(n.incomplete); 1150 1151 Way w = (Way)target.getPrimitiveById(3, OsmPrimitiveType.WAY); 1152 assertNotNull(w); 1153 assertFalse(w.incomplete); 1154 assertEquals(2, w.getNodesCount()); 1155 assertEquals(1, w.getNode(0).getId()); 1156 assertEquals(2, w.getNode(1).getId()); 1157 } 1094 1158 }
Note:
See TracChangeset
for help on using the changeset viewer.