Changeset 6601 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2014-01-02T23:58:58+01:00 (11 years ago)
- Location:
- trunk/test/unit/org/openstreetmap
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/TestUtils.java
r6592 r6601 60 60 assertThat(p.get("railway"), is("rail")); 61 61 } 62 63 @Test(expected = IllegalArgumentException.class) 64 public void testCreatePrimitiveFail() throws Exception { 65 TestUtils.createPrimitive("noway name=Foo"); 66 } 67 62 68 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r6592 r6601 9 9 import org.openstreetmap.josm.data.osm.Node; 10 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 import org.openstreetmap.josm.data.osm.Relation;12 11 import org.openstreetmap.josm.data.osm.Tag; 13 import org.openstreetmap.josm.data.osm.Way;14 12 import org.openstreetmap.josm.data.validation.Severity; 15 import org.openstreetmap.josm.tools.TextTagParser; 13 import org.openstreetmap.josm.data.validation.TestError; 14 import org.openstreetmap.josm.tools.Predicate; 15 import org.openstreetmap.josm.tools.Predicates; 16 import org.openstreetmap.josm.tools.Utils; 16 17 17 18 import java.io.StringReader; … … 62 63 n2.put("natural", "wood"); 63 64 assertFalse(check.matchesPrimitive(n2)); 64 assertThat(MapCSSTagChecker.TagCheck.insertArguments(check. selector.get(0), "The key is {0.key} and the value is {0.value}"),65 assertThat(MapCSSTagChecker.TagCheck.insertArguments(check.rule.selectors.get(0), "The key is {0.key} and the value is {0.value}"), 65 66 is("The key is natural and the value is marsh")); 66 }67 68 @Test(expected = IllegalArgumentException.class)69 public void testCreatePrimitiveForAssertionFail() throws Exception {70 final OsmPrimitive p = TestUtils.createPrimitive("noway name=Foo");71 67 } 72 68 … … 80 76 for (final Map.Entry<String, Boolean> i : check.assertions.entrySet()) { 81 77 final OsmPrimitive p = TestUtils.createPrimitive(i.getKey()); 82 if (check.matchesPrimitive(p) != i.getValue()) { 78 final boolean isError = Utils.exists(c.getErrorsForPrimitive(p), new Predicate<TestError>() { 79 @Override 80 public boolean evaluate(TestError e) { 81 //noinspection EqualsBetweenInconvertibleTypes 82 return e.getTester().equals(check.rule); 83 } 84 }); 85 if (isError != i.getValue()) { 83 86 final String error = MessageFormat.format("Expecting test ''{0}'' (i.e., {1}) to {2} {3} (i.e., {4})", 84 check.getMessage(), check. selector, i.getValue() ? "match" : "not match", i.getKey(), p.getKeys());87 check.getMessage(), check.rule.selectors, i.getValue() ? "match" : "not match", i.getKey(), p.getKeys()); 85 88 System.err.println(error); 86 89 assertionErrors.add(error);
Note:
See TracChangeset
for help on using the changeset viewer.