Changeset 10710 in josm for trunk/src


Ignore:
Timestamp:
2016-08-02T22:18:08+02:00 (9 years ago)
Author:
simon04
Message:

fix #12570 - Group MapCSS tag checker tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r10674 r10710  
    255255
    256256    public static class TagCheck implements Predicate<OsmPrimitive> {
     257        /** The selector of this {@code TagCheck} */
    257258        protected final GroupedMapCSSRule rule;
     259        /** Commands to apply in order to fix a matching primitive */
    258260        protected final List<FixCommand> fixCommands = new ArrayList<>();
     261        /** Tags (or arbitraty strings) of alternatives to be presented to the user */
    259262        protected final List<String> alternatives = new ArrayList<>();
     263        /** An {@link Instruction.AssignmentInstruction}-{@link Severity} pair.
     264         * Is evaluated on the matching primitive to give the error message. Map is checked to contain exactly one element. */
    260265        protected final Map<Instruction.AssignmentInstruction, Severity> errors = new HashMap<>();
     266        /** Unit tests */
    261267        protected final Map<String, Boolean> assertions = new HashMap<>();
     268        /** MapCSS Classes to set on matching primitives */
    262269        protected final Set<String> setClassExpressions = new HashSet<>();
     270        /** Denotes whether the object should be deleted for fixing it */
    263271        protected boolean deletion;
     272        /** A string used to group similar tests */
     273        protected String group;
    264274
    265275        TagCheck(GroupedMapCSSRule rule) {
     
    324334                    } else if ("assertNoMatch".equals(ai.key) && val != null) {
    325335                        check.assertions.put(val, Boolean.FALSE);
     336                    } else if ("group".equals(ai.key) && val != null) {
     337                        check.group = val;
    326338                    } else {
    327339                        throw new IllegalDataException("Cannot add instruction " + ai.key + ": " + ai.val + '!');
     
    563575                final Command fix = fixPrimitive(p);
    564576                final String description = getDescriptionForMatchingSelector(p, matchingSelector);
     577                final String description1 = group == null ? description : group;
     578                final String description2 = group == null ? null : description;
    565579                final List<OsmPrimitive> primitives;
    566580                if (env.child != null) {
     
    570584                }
    571585                if (fix != null) {
    572                     return new FixableTestError(null, getSeverity(), description, null, matchingSelector.toString(), 3000, primitives, fix);
     586                    return new FixableTestError(null, getSeverity(), description1, description2, matchingSelector.toString(), 3000, primitives, fix);
    573587                } else {
    574                     return new TestError(null, getSeverity(), description, null, matchingSelector.toString(), 3000, primitives);
     588                    return new TestError(null, getSeverity(), description1, description2, matchingSelector.toString(), 3000, primitives);
    575589                }
    576590            } else {
Note: See TracChangeset for help on using the changeset viewer.