Changeset 6592 in josm for trunk/test/unit/org/openstreetmap/josm
- Timestamp:
- 2014-01-01T15:27:25+01:00 (11 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/data/validation/tests
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r6548 r6592 3 3 import org.junit.Before; 4 4 import org.junit.Test; 5 import org.openstreetmap.TestUtils; 5 6 import org.openstreetmap.josm.Main; 6 7 import org.openstreetmap.josm.command.ChangePropertyCommand; … … 65 66 } 66 67 67 OsmPrimitive createPrimitiveForAssertion(String assertion) {68 final String[] x = assertion.split("\\s+", 2);69 final OsmPrimitive p = "n".equals(x[0]) || "node".equals(x[0])70 ? new Node()71 : "w".equals(x[0]) || "way".equals(x[0])72 ? new Way()73 : "r".equals(x[0]) || "relation".equals(x[0])74 ? new Relation()75 : null;76 if (p == null) {77 throw new IllegalArgumentException("Expecting n/node/w/way/r/relation, but got " + x[0]);78 }79 for (final Map.Entry<String, String> i : TextTagParser.readTagsFromText(x[1]).entrySet()) {80 p.put(i.getKey(), i.getValue());81 }82 return p;83 }84 85 @Test86 public void testCreatePrimitiveForAssertion() throws Exception {87 final OsmPrimitive p = createPrimitiveForAssertion("way name=Foo railway=rail");88 assertTrue(p instanceof Way);89 assertThat(p.keySet().size(), is(2));90 assertThat(p.get("name"), is("Foo"));91 assertThat(p.get("railway"), is("rail"));92 }93 94 68 @Test(expected = IllegalArgumentException.class) 95 69 public void testCreatePrimitiveForAssertionFail() throws Exception { 96 final OsmPrimitive p = createPrimitiveForAssertion("noway name=Foo");70 final OsmPrimitive p = TestUtils.createPrimitive("noway name=Foo"); 97 71 } 98 72 … … 105 79 for (final MapCSSTagChecker.TagCheck check : c.checks) { 106 80 for (final Map.Entry<String, Boolean> i : check.assertions.entrySet()) { 107 final OsmPrimitive p = createPrimitiveForAssertion(i.getKey());81 final OsmPrimitive p = TestUtils.createPrimitive(i.getKey()); 108 82 if (check.matchesPrimitive(p) != i.getValue()) { 109 83 final String error = MessageFormat.format("Expecting test ''{0}'' (i.e., {1}) to {2} {3} (i.e., {4})",
Note:
See TracChangeset
for help on using the changeset viewer.