Changeset 12740 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2017-09-05T20:28:46+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java
r12731 r12740 41 41 private static Map<String, String> getRefToRoleMap(Relation relation) { 42 42 Map<String, String> refToRole = new TreeMap<>(); 43 String ref = relation.get("ref"); 44 if (ref != null) { 45 refToRole.put(ref, "outer"); 46 } 43 47 for (RelationMember i : relation.getMembers()) { 44 Stringref = i.getMember().get("ref");48 ref = i.getMember().get("ref"); 45 49 if (ref != null) { 46 50 refToRole.put(ref, i.getRole()); … … 58 62 59 63 @SuppressWarnings("unchecked") 60 private static Pair<SequenceCommand, Relation> createMultipolygonCommand(Collection<Way> ways, String pattern, Relation r)64 private static Relation createMultipolygon(Collection<Way> ways, String pattern, Relation r, boolean runCmd) 61 65 throws SearchParseError { 62 returnCreateMultipolygonAction.createMultipolygonCommand(66 Pair<SequenceCommand, Relation> cmd = CreateMultipolygonAction.createMultipolygonCommand( 63 67 (Collection<Way>) (Collection<?>) SubclassFilteredCollection.filter(ways, SearchCompiler.compile(regexpSearch(pattern))), r); 68 if (runCmd) { 69 cmd.a.executeCommand(); 70 } 71 return cmd.b; 64 72 } 65 73 … … 75 83 public void testCreate2() throws Exception { 76 84 DataSet ds = OsmReader.parseDataSet(new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null); 77 Pair<SequenceCommand, Relation> mp = createMultipolygonCommand(ds.getWays(), "ref=1 OR ref:1.1.", null);78 assertEquals("{1=outer, 1.1.1=inner, 1.1.2=inner}", getRefToRoleMap(mp .b).toString());85 Relation mp = createMultipolygon(ds.getWays(), "ref=1 OR ref:1.1.", null, true); 86 assertEquals("{1=outer, 1.1.1=inner, 1.1.2=inner}", getRefToRoleMap(mp).toString()); 79 87 } 80 88 … … 82 90 public void testUpdate1() throws Exception { 83 91 DataSet ds = OsmReader.parseDataSet(new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null); 84 Pair<SequenceCommand, Relation> mp = createMultipolygonCommand(ds.getWays(), "ref=\".*1$\"", null); 85 mp.a.executeCommand(); 86 assertEquals(3, mp.b.getMembersCount()); 87 assertEquals("{1=outer, 1.1=inner, 1.1.1=outer}", getRefToRoleMap(mp.b).toString()); 88 Pair<SequenceCommand, Relation> mp2 = createMultipolygonCommand(ds.getWays(), "ref=1.2", mp.b); 89 assertEquals(4, mp2.b.getMembersCount()); 90 assertEquals("{1=outer, 1.1=inner, 1.1.1=outer, 1.2=inner}", getRefToRoleMap(mp2.b).toString()); 92 Relation mp = createMultipolygon(ds.getWays(), "ref=\".*1$\"", null, true); 93 assertEquals(3, mp.getMembersCount()); 94 assertEquals("{1=outer, 1.1=inner, 1.1.1=outer}", getRefToRoleMap(mp).toString()); 95 Relation mp2 = createMultipolygon(ds.getWays(), "ref=1.2", mp, true); 96 assertEquals(4, mp2.getMembersCount()); 97 assertEquals("{1=outer, 1.1=inner, 1.1.1=outer, 1.2=inner}", getRefToRoleMap(mp2).toString()); 91 98 } 92 99 … … 94 101 public void testUpdate2() throws Exception { 95 102 DataSet ds = OsmReader.parseDataSet(new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null); 96 Pair<SequenceCommand, Relation> mp = createMultipolygonCommand(ds.getWays(), "ref=1 OR ref:1.1.1", null); 97 mp.a.executeCommand(); 98 assertEquals("{1=outer, 1.1.1=inner}", getRefToRoleMap(mp.b).toString()); 99 Pair<SequenceCommand, Relation> mp2 = createMultipolygonCommand(ds.getWays(), "ref=1.1 OR ref=1.2 OR ref=1.1.2", mp.b); 100 assertEquals("{1=outer, 1.1=inner, 1.1.1=outer, 1.1.2=outer, 1.2=inner}", getRefToRoleMap(mp2.b).toString()); 103 Relation mp = createMultipolygon(ds.getWays(), "ref=1 OR ref:1.1.1", null, true); 104 assertEquals("{1=outer, 1.1.1=inner}", getRefToRoleMap(mp).toString()); 105 Relation mp2 = createMultipolygon(ds.getWays(), "ref=1.1 OR ref=1.2 OR ref=1.1.2", mp, false); 106 assertEquals("{1=outer, 1.1=inner, 1.1.1=outer, 1.1.2=outer, 1.2=inner}", getRefToRoleMap(mp2).toString()); 101 107 } 102 108 }
Note:
See TracChangeset
for help on using the changeset viewer.