Changeset 16616 in josm for trunk


Ignore:
Timestamp:
2020-06-14T11:24:35+02:00 (4 years ago)
Author:
simon04
Message:

fix #19380 - RelationChecker: improve validation message "Role verification problem - Role 'route' is not among expected values '<empty>/guidepost'"

Location:
trunk
Files:
2 edited

Legend:

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

    r16445 r16616  
    4444
    4545    // CHECKSTYLE.OFF: SingleSpaceSeparator
    46     /** Role ''{0}'' is not in templates ''{1}'' */
     46    /** Role ''{0}'' is not among expected values ''{1}'' */
    4747    public static final int ROLE_UNKNOWN     = 1701;
    4848    /** Empty role found when expecting one of ''{0}'' */
     
    320320        for (String key : map.keySet()) {
    321321            if (allroles.keySet().stream().noneMatch(role -> role.isRole(key))) {
    322                 String templates = allroles.keySet().stream().map(r -> r.key).collect(Collectors.joining("/"));
     322                String templates = allroles.keySet().stream()
     323                        .map(r -> r.key)
     324                        .map(r -> r == null || r.isEmpty() ? tr("<empty>") : r)
     325                        .distinct()
     326                        .collect(Collectors.joining("/"));
    323327                List<OsmPrimitive> primitives = new ArrayList<>(n.findRelationMembers(key));
    324328                primitives.add(0, n);
     
    326330                if (!key.isEmpty()) {
    327331                    errors.add(TestError.builder(this, Severity.WARNING, ROLE_UNKNOWN)
    328                             .message(ROLE_VERIF_PROBLEM_MSG, marktr("Role ''{0}'' is not in templates ''{1}''"), key, templates)
     332                            .message(ROLE_VERIF_PROBLEM_MSG, marktr("Role ''{0}'' is not among expected values ''{1}''"), key, templates)
    329333                            .primitives(primitives)
    330334                            .build());
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/RelationCheckerTest.java

    r15455 r16616  
    1010import org.junit.Rule;
    1111import org.junit.Test;
     12import org.openstreetmap.josm.data.osm.Node;
     13import org.openstreetmap.josm.data.osm.OsmUtils;
    1214import org.openstreetmap.josm.data.osm.Relation;
    1315import org.openstreetmap.josm.data.osm.RelationMember;
     
    7880        List<TestError> errors = testRelation(r);
    7981        assertEquals(1, errors.size());
    80         assertEquals("Role 'outer2' is not in templates 'outer/inner'", errors.get(0).getDescription());
     82        assertEquals("Role 'outer2' is not among expected values 'outer/inner'", errors.get(0).getDescription());
    8183    }
    8284
     
    154156        List<TestError> errors = testRelation(r);
    155157        assertEquals(1, errors.size());
    156         assertEquals("Role 'level_x' is not in templates 'outline/part/ridge/edge/entrance/level_-?\\d+'", errors.get(0).getDescription());
     158        assertEquals("Role 'level_x' is not among expected values 'outline/part/ridge/edge/entrance/level_-?\\d+'",
     159                errors.get(0).getDescription());
     160    }
     161
     162    @Test
     163    public void testHikingRouteMembers() {
     164        Relation r = createRelation("type=route route=hiking");
     165        r.addMember(new RelationMember("", OsmUtils.createPrimitive("way highway=path")));
     166        r.addMember(new RelationMember("route", OsmUtils.createPrimitive("way highway=path"))); // fails
     167        r.addMember(new RelationMember("guidepost", new Node())); // fails
     168
     169        List<TestError> errors = testRelation(r);
     170        assertEquals(2, errors.size());
     171        assertEquals("Role of relation member does not match template expression 'information=guidepost' in preset Hiking Route",
     172                errors.get(0).getDescription());
     173        assertEquals("Role 'route' is not among expected values '<empty>/guidepost'", errors.get(1).getDescription());
    157174    }
    158175
Note: See TracChangeset for help on using the changeset viewer.