Changeset 7356 in josm for trunk/test/unit/org/openstreetmap/josm/data
- Timestamp:
- 2014-08-01T19:17:40+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r7275 r7356 8 8 9 9 import java.io.StringReader; 10 import java.text.MessageFormat;11 10 import java.util.LinkedHashSet; 12 11 import java.util.List; 13 import java.util.Map;14 12 import java.util.Set; 15 13 … … 17 15 import org.junit.Test; 18 16 import org.openstreetmap.josm.JOSMFixture; 19 import org.openstreetmap.josm. TestUtils;17 import org.openstreetmap.josm.Main; 20 18 import org.openstreetmap.josm.command.ChangePropertyCommand; 21 19 import org.openstreetmap.josm.data.osm.Node; 22 import org.openstreetmap.josm.data.osm.OsmPrimitive;23 20 import org.openstreetmap.josm.data.osm.Tag; 24 21 import org.openstreetmap.josm.data.validation.Severity; 25 import org.openstreetmap.josm.data.validation.TestError;26 22 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.TagCheck; 27 import org.openstreetmap.josm.tools.Predicate;28 import org.openstreetmap.josm.tools.Utils;29 23 24 /** 25 * JUnit Test of MapCSS TagChecker. 26 */ 30 27 public class MapCSSTagCheckerTest { 31 28 … … 72 69 @Test 73 70 public void testInit() throws Exception { 74 finalMapCSSTagChecker c = new MapCSSTagChecker();71 MapCSSTagChecker c = new MapCSSTagChecker(); 75 72 c.initialize(); 76 73 77 LinkedHashSet<String> assertionErrors = new LinkedHashSet<>(); 78 for (final Set<TagCheck> schecks : c.checks.values()) { 79 for (final TagCheck check : schecks) { 80 System.out.println("Check: "+check); 81 for (final Map.Entry<String, Boolean> i : check.assertions.entrySet()) { 82 System.out.println("- Assertion: "+i); 83 final OsmPrimitive p = TestUtils.createPrimitive(i.getKey()); 84 final boolean isError = Utils.exists(c.getErrorsForPrimitive(p, true), new Predicate<TestError>() { 85 @Override 86 public boolean evaluate(TestError e) { 87 //noinspection EqualsBetweenInconvertibleTypes 88 return e.getTester().equals(check.rule); 89 } 90 }); 91 if (isError != i.getValue()) { 92 final String error = MessageFormat.format("Expecting test ''{0}'' (i.e., {1}) to {2} {3} (i.e., {4})", 93 check.getMessage(p), check.rule.selectors, i.getValue() ? "match" : "not match", i.getKey(), p.getKeys()); 94 System.err.println(error); 95 assertionErrors.add(error); 96 } 97 } 98 } 74 Set<String> assertionErrors = new LinkedHashSet<>(); 75 for (Set<TagCheck> schecks : c.checks.values()) { 76 assertionErrors.addAll(c.checkAsserts(schecks)); 77 } 78 for (String msg : assertionErrors) { 79 Main.error(msg); 99 80 } 100 81 assertTrue("not all assertions included in the tests are met", assertionErrors.isEmpty());
Note:
See TracChangeset
for help on using the changeset viewer.