Changeset 6601 in josm for trunk/test


Ignore:
Timestamp:
2014-01-02T23:58:58+01:00 (6 years ago)
Author:
simon04
Message:

see #9414 fix #9485 - MapCSSTagChecker: add support for set class_name instruction and .class_name condition

Location:
trunk/test/unit/org/openstreetmap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/TestUtils.java

    r6592 r6601  
    6060        assertThat(p.get("railway"), is("rail"));
    6161    }
     62
     63    @Test(expected = IllegalArgumentException.class)
     64    public void testCreatePrimitiveFail() throws Exception {
     65        TestUtils.createPrimitive("noway name=Foo");
     66    }
     67
    6268}
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    r6592 r6601  
    99import org.openstreetmap.josm.data.osm.Node;
    1010import org.openstreetmap.josm.data.osm.OsmPrimitive;
    11 import org.openstreetmap.josm.data.osm.Relation;
    1211import org.openstreetmap.josm.data.osm.Tag;
    13 import org.openstreetmap.josm.data.osm.Way;
    1412import org.openstreetmap.josm.data.validation.Severity;
    15 import org.openstreetmap.josm.tools.TextTagParser;
     13import org.openstreetmap.josm.data.validation.TestError;
     14import org.openstreetmap.josm.tools.Predicate;
     15import org.openstreetmap.josm.tools.Predicates;
     16import org.openstreetmap.josm.tools.Utils;
    1617
    1718import java.io.StringReader;
     
    6263        n2.put("natural", "wood");
    6364        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}"),
    6566                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");
    7167    }
    7268
     
    8076            for (final Map.Entry<String, Boolean> i : check.assertions.entrySet()) {
    8177                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()) {
    8386                    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());
    8588                    System.err.println(error);
    8689                    assertionErrors.add(error);
Note: See TracChangeset for help on using the changeset viewer.