Changeset 1948 in josm for trunk/test/unit/org
- Timestamp:
- 2009-08-10T13:13:31+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeVisitorTest.java
r1926 r1948 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNotNull; 5 6 import static org.junit.Assert.assertTrue; 6 7 import static org.junit.Assert.fail; … … 8 9 import java.io.File; 9 10 import java.text.MessageFormat; 11 import java.util.Arrays; 10 12 import java.util.Calendar; 13 import java.util.Collections; 11 14 import java.util.Date; 12 15 import java.util.GregorianCalendar; … … 21 24 import org.openstreetmap.josm.data.osm.DataSet; 22 25 import org.openstreetmap.josm.data.osm.Node; 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 27 import org.openstreetmap.josm.data.osm.Relation; 24 28 import org.openstreetmap.josm.data.osm.RelationMember; … … 978 982 } 979 983 980 981 982 984 /** 985 * Merge an incomplete way with two incomplete nodes into an empty dataset. 986 * 987 * Use case: a way loaded with a multiget, i.e. GET /api/0.6/ways?ids=123456 988 */ 989 @Test 990 public void newIncompleteWay() { 991 DataSet their = new DataSet(); 992 their.version = "0.6"; 993 994 Node n1 = new Node(1); 995 n1.version = 1; 996 n1.incomplete = true; 997 their.addPrimitive(n1); 998 999 Node n2 = new Node(2); 1000 n2.version = 1; 1001 n2.incomplete = true; 1002 their.addPrimitive(n2); 1003 1004 Way w3 = new Way(3); 1005 w3.incomplete = true; 1006 w3.setNodes(Arrays.asList(n1,n2)); 1007 their.addPrimitive(w3); 1008 1009 DataSet my = new DataSet(); 1010 their.version = "0.6"; 1011 1012 MergeVisitor visitor = new MergeVisitor(my,their); 1013 visitor.merge(); 1014 1015 assertEquals(0,visitor.getConflicts().size()); 1016 1017 OsmPrimitive p= my.getPrimitiveById(1); 1018 assertNotNull(p); 1019 assertTrue(p.incomplete); 1020 p= my.getPrimitiveById(2); 1021 assertNotNull(p); 1022 assertTrue(p.incomplete); 1023 p= my.getPrimitiveById(3); 1024 assertNotNull(p); 1025 assertTrue(p.incomplete); 1026 1027 Way w = (Way)my.getPrimitiveById(3); 1028 assertNotNull(w); 1029 assertTrue(p.incomplete); 1030 assertEquals(2, w.getNodesCount()); 1031 assertTrue(w.getNode(0).incomplete); 1032 assertTrue(w.getNode(1).incomplete); 1033 } 1034 1035 /** 1036 * Merge an incomplete way with two incomplete nodes into a dataset where the way already exists as complete way. 1037 * 1038 * Use case: a way loaded with a multiget, i.e. GET /api/0.6/ways?ids=123456 after a "Update selection " of this way 1039 */ 1040 @Test 1041 public void incompleteWayOntoCompleteWay() { 1042 DataSet their = new DataSet(); 1043 their.version = "0.6"; 1044 1045 Node n1 = new Node(1); 1046 n1.version = 1; 1047 n1.incomplete = true; 1048 their.addPrimitive(n1); 1049 1050 Node n2 = new Node(2); 1051 n2.version = 1; 1052 n2.incomplete = true; 1053 their.addPrimitive(n2); 1054 1055 Way w3 = new Way(3); 1056 w3.incomplete = true; 1057 w3.setNodes(Arrays.asList(n1,n2)); 1058 their.addPrimitive(w3); 1059 1060 DataSet my = new DataSet(); 1061 their.version = "0.6"; 1062 1063 Node n4 = new Node(new LatLon(0,0)); 1064 n4.id = 1; 1065 n4.version = 1; 1066 n4.incomplete = false; 1067 my.addPrimitive(n4); 1068 1069 Node n5 = new Node(new LatLon(1,1)); 1070 n5.id = 2; 1071 n5.version = 1; 1072 n5.incomplete = false; 1073 my.addPrimitive(n5); 1074 1075 Way w6 = new Way(3); 1076 w6.incomplete = false; 1077 w6.setNodes(Arrays.asList(n4,n5)); 1078 my.addPrimitive(w6); 1079 1080 MergeVisitor visitor = new MergeVisitor(my,their); 1081 visitor.merge(); 1082 1083 assertEquals(0,visitor.getConflicts().size()); 1084 1085 OsmPrimitive p= my.getPrimitiveById(1); 1086 assertNotNull(p); 1087 assertTrue(!p.incomplete); 1088 p= my.getPrimitiveById(2); 1089 assertNotNull(p); 1090 assertTrue(!p.incomplete); 1091 p= my.getPrimitiveById(3); 1092 assertNotNull(p); 1093 assertTrue(!p.incomplete); 1094 1095 Way w = (Way)my.getPrimitiveById(3); 1096 assertNotNull(w); 1097 assertTrue(!p.incomplete); 1098 assertEquals(2, w.getNodesCount()); 1099 assertTrue(!w.getNode(0).incomplete); 1100 assertTrue(!w.getNode(1).incomplete); 1101 } 983 1102 }
Note:
See TracChangeset
for help on using the changeset viewer.