Changeset 8266 in josm for trunk/test/unit/org/openstreetmap/josm/data
- Timestamp:
- 2015-04-25T19:13:12+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r8265 r8266 8 8 9 9 import java.io.StringReader; 10 import java.util.Collection; 10 11 import java.util.Iterator; 11 12 import java.util.LinkedHashSet; … … 26 27 import org.openstreetmap.josm.data.osm.OsmUtils; 27 28 import org.openstreetmap.josm.data.validation.Severity; 29 import org.openstreetmap.josm.data.validation.TestError; 28 30 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.TagCheck; 31 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException; 29 32 30 33 /** … … 39 42 public static void setUp() { 40 43 JOSMFixture.createUnitTestFixture().init(); 44 } 45 46 static MapCSSTagChecker buildTagChecker(String css) throws ParseException { 47 final MapCSSTagChecker test = new MapCSSTagChecker(); 48 test.checks.putAll("test", TagCheck.readMapCSS(new StringReader(css))); 49 return test; 41 50 } 42 51 … … 69 78 n2.put("natural", "wood"); 70 79 assertFalse(check.evaluate(n2)); 71 assertThat(MapCSSTagChecker.TagCheck.insertArguments(check.rule.selectors.get(0), "The key is {0.key} and the value is {0.value}"), 80 assertThat(MapCSSTagChecker.TagCheck.insertArguments(check.rule.selectors.get(0), "The key is {0.key} and the value is {0.value}", null), 72 81 is("The key is natural and the value is marsh")); 73 82 } … … 89 98 90 99 @Test 100 public void test9782() throws Exception { 101 final MapCSSTagChecker test = buildTagChecker("*[/.+_name/][!name] {" + 102 "throwWarning: tr(\"has {0} but not {1}\", \"{0.key}\", \"{1.key}\");}"); 103 final OsmPrimitive p = OsmUtils.createPrimitive("way alt_name=Foo"); 104 final Collection<TestError> errors = test.getErrorsForPrimitive(p, false); 105 assertThat(errors.size(), is(1)); 106 assertThat(errors.iterator().next().getMessage(), is("has alt_name but not name")); 107 } 108 109 @Test 110 public void test10859() throws Exception { 111 final MapCSSTagChecker test = buildTagChecker("way[highway=footway][foot?!] {\n" + 112 " throwWarning: tr(\"{0} used with {1}\", \"{0.value}\", \"{1.tag}\");}"); 113 final OsmPrimitive p = OsmUtils.createPrimitive("way highway=footway foot=no"); 114 final Collection<TestError> errors = test.getErrorsForPrimitive(p, false); 115 assertThat(errors.size(), is(1)); 116 assertThat(errors.iterator().next().getMessage(), is("footway used with foot=no")); 117 } 118 119 @Test 91 120 public void testInit() throws Exception { 92 121 MapCSSTagChecker c = new MapCSSTagChecker();
Note:
See TracChangeset
for help on using the changeset viewer.