Changeset 6538 in josm for trunk/test/unit
- Timestamp:
- 2013-12-26T15:19:31+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r6534 r6538 4 4 import org.junit.Test; 5 5 import org.openstreetmap.josm.Main; 6 import org.openstreetmap.josm.command.ChangePropertyCommand; 6 7 import org.openstreetmap.josm.data.Preferences; 7 8 import org.openstreetmap.josm.data.osm.Node; … … 10 11 import org.openstreetmap.josm.data.osm.Tag; 11 12 import org.openstreetmap.josm.data.osm.Way; 13 import org.openstreetmap.josm.data.validation.Severity; 12 14 import org.openstreetmap.josm.tools.TextTagParser; 13 15 14 16 import java.io.StringReader; 17 import java.text.MessageFormat; 15 18 import java.util.LinkedHashSet; 16 19 import java.util.List; … … 35 38 final List<MapCSSTagChecker.TagCheck> checks = MapCSSTagChecker.TagCheck.readMapCSS(new StringReader("" + 36 39 "*[natural=marsh] {\n" + 37 " throwWarning: tr(\"{0} is deprecated\", \" natural=marsh\");\n" +38 " fixRemove: \" natural\";\n" +40 " throwWarning: tr(\"{0} is deprecated\", \"{0.tag}\");\n" + 41 " fixRemove: \"{0.key}\";\n" + 39 42 " fixAdd: \"natural=wetland\";\n" + 40 43 " fixAdd: \"wetland=marsh\";\n" + … … 43 46 final MapCSSTagChecker.TagCheck check = checks.get(0); 44 47 assertThat(check, notNullValue()); 45 assertThat(check.change.get(0).apply(null), is(new Tag("natural"))); 48 assertThat(check.getDescription(), is("{0.tag} is deprecated")); 49 assertThat(check.change.get(0).apply(null), is(new Tag("{0.key}"))); 46 50 assertThat(check.change.get(1).apply(null), is(new Tag("natural", "wetland"))); 47 51 assertThat(check.change.get(2).apply(null), is(new Tag("wetland", "marsh"))); 48 assertThat(check.errors.keySet().iterator().next(), is("natural=marsh is deprecated"));49 52 final Node n1 = new Node(); 50 53 n1.put("natural", "marsh"); 51 54 assertTrue(check.matchesPrimitive(n1)); 55 assertThat(check.getErrorForPrimitive(n1).getMessage(), is("natural=marsh is deprecated")); 56 assertThat(check.getErrorForPrimitive(n1).getSeverity(), is(Severity.WARNING)); 57 assertThat(((ChangePropertyCommand) check.fixPrimitive(n1).getChildren().iterator().next()).getTags().toString(), 58 is("{natural=}")); 52 59 final Node n2 = new Node(); 53 60 n2.put("natural", "wood"); 54 61 assertFalse(check.matchesPrimitive(n2)); 62 assertThat(MapCSSTagChecker.TagCheck.insertArguments(check.selector.get(0), "The key is {0.key} and the value is {0.value}"), 63 is("The key is natural and the value is marsh")); 55 64 } 56 65 … … 97 106 final OsmPrimitive p = createPrimitiveForAssertion(i.getKey()); 98 107 if (check.matchesPrimitive(p) != i.getValue()) { 99 final String error = "Expecting test '" + check.getMessage() + "' to " + (i.getValue() ? "" : "not ") + "match " + i.getKey() + ", i.e., " + p.getKeys(); 108 final String error = MessageFormat.format("Expecting test ''{0}'' (i.e., {1}) to {2} {3} (i.e., {4})", 109 check.getMessage(), check.selector, i.getValue() ? "match" : "not match", i.getKey(), p.getKeys()); 100 110 System.err.println(error); 101 111 assertionErrors.add(error);
Note:
See TracChangeset
for help on using the changeset viewer.