Changeset 10991 in josm for trunk/test/unit
- Timestamp:
- 2016-09-11T02:15:50+02:00 (8 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/data/validation/tests
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MultipolygonTestTest.java
r10945 r10991 5 5 import static org.junit.Assert.assertFalse; 6 6 import static org.junit.Assert.assertTrue; 7 import static org.junit.Assert.fail;8 7 9 import java.io.FileInputStream;10 import java.io.InputStream;11 8 import java.util.ArrayList; 12 import java.util.Arrays;13 9 import java.util.List; 14 import java.util.Set; 15 import java.util.TreeSet; 10 import java.util.stream.Collectors; 16 11 17 12 import org.junit.Rule; … … 22 17 import org.openstreetmap.josm.data.osm.Relation; 23 18 import org.openstreetmap.josm.data.osm.Way; 24 import org.openstreetmap.josm.data.validation.TestError;25 import org.openstreetmap.josm.gui.DefaultNameFormatter;26 19 import org.openstreetmap.josm.gui.mappaint.ElemStyles; 27 import org.openstreetmap.josm.io.OsmReader;28 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 29 21 … … 90 82 @Test 91 83 public void testMultipolygonFile() throws Exception { 92 try (InputStream is = new FileInputStream("data_nodist/multipolygon.osm")) { 93 for (Relation r : OsmReader.parseDataSet(is, null).getRelations()) { 94 if (r.isMultipolygon()) { 95 String name = DefaultNameFormatter.getInstance().format(r); 96 String codes = r.get("josm_error_codes"); 97 if (codes != null) { 98 List<TestError> errors = new ArrayList<>(); 99 for (org.openstreetmap.josm.data.validation.Test test : Arrays.asList(MULTIPOLYGON_TEST, RELATION_TEST)) { 100 test.initialize(); 101 test.startTest(null); 102 test.visit(r); 103 test.endTest(); 104 errors.addAll(test.getErrors()); 105 } 106 Set<Integer> expectedCodes = new TreeSet<>(); 107 for (String code : codes.split(",")) { 108 expectedCodes.add(Integer.parseInt(code)); 109 } 110 Set<Integer> actualCodes = new TreeSet<>(); 111 for (TestError error : errors) { 112 Integer code = error.getCode(); 113 assertTrue(name + " does not expect JOSM error code " + code + ": " + error.getDescription(), 114 expectedCodes.contains(code)); 115 actualCodes.add(code); 116 } 117 assertEquals(name + " " + expectedCodes + " => " + actualCodes, 118 expectedCodes.size(), actualCodes.size()); 119 } else if (r.hasKey("name") && (r.getName().startsWith("06") || r.getName().startsWith("07"))) { 120 fail(name + " lacks josm_error_codes tag"); 121 } 122 } 123 } 124 } 84 ValidatorTestUtils.testSampleFile("data_nodist/multipolygon.osm", 85 ds -> ds.getRelations().stream().filter(Relation::isMultipolygon).collect(Collectors.toList()), 86 name -> name.startsWith("06") || name.startsWith("07"), MULTIPOLYGON_TEST, RELATION_TEST); 125 87 } 126 88 }
Note:
See TracChangeset
for help on using the changeset viewer.