Changeset 14990 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
r14968 r14990 40 40 41 41 // CHECKSTYLE.OFF: SingleSpaceSeparator 42 /** Role {0} unknown in templates {1}*/42 /** Role ''{0}'' is not in templates ''{1}'' */ 43 43 public static final int ROLE_UNKNOWN = 1701; 44 /** Empty role type found when expecting one of {0}*/44 /** Empty role found when expecting one of ''{0}'' */ 45 45 public static final int ROLE_EMPTY = 1702; 46 /** Role member does not match expression {0} in template{1} */47 public static final int WRONG_ TYPE = 1703;48 /** Number of {0}roles too high ({1}) */46 /** Role of relation member does not match template expression ''{0}'' in preset {1} */ 47 public static final int WRONG_ROLE = 1708; 48 /** Number of ''{0}'' roles too high ({1}) */ 49 49 public static final int HIGH_COUNT = 1704; 50 /** Number of {0}roles too low ({1}) */50 /** Number of ''{0}'' roles too low ({1}) */ 51 51 public static final int LOW_COUNT = 1705; 52 /** Role {0}missing */52 /** Role ''{0}'' missing */ 53 53 public static final int ROLE_MISSING = 1706; 54 54 /** Relation type is unknown */ … … 56 56 /** Relation is empty */ 57 57 public static final int RELATION_EMPTY = 1708; 58 /** Type ''{0}'' of relation member with role ''{1}'' does not match accepted types ''{2}'' in preset {3} */ 59 public static final int WRONG_TYPE = 1709; 58 60 // CHECKSTYLE.ON: SingleSpaceSeparator 59 61 … … 211 213 String role = member.getRole(); 212 214 String name = null; 213 // Set of all accepted types in template215 // Set of all accepted types in preset 214 216 Collection<TaggingPresetType> types = EnumSet.noneOf(TaggingPresetType.class); 215 217 TestError possibleMatchError = null; … … 242 244 // possible match error 243 245 // we still need to iterate further, as we might have 244 // different prese nt, for which memberExpression will match246 // different preset, for which memberExpression will match 245 247 // but stash the error in case no better reason will be found later 246 possibleMatchError = TestError.builder(this, Severity.WARNING, WRONG_ TYPE)248 possibleMatchError = TestError.builder(this, Severity.WARNING, WRONG_ROLE) 247 249 .message(ROLE_VERIF_PROBLEM_MSG, 248 marktr("Role of relation member does not match expression ''{0}'' in template{1}"),250 marktr("Role of relation member does not match template expression ''{0}'' in preset {1}"), 249 251 r.memberExpression, name) 250 252 .primitives(member.getMember().isUsable() ? member.getMember() : n) … … 280 282 errors.add(TestError.builder(this, Severity.WARNING, WRONG_TYPE) 281 283 .message(ROLE_VERIF_PROBLEM_MSG, 282 marktr("Type ''{0}'' of relation member with role ''{1}'' does not match accepted types ''{2}'' in template{3}"),284 marktr("Type ''{0}'' of relation member with role ''{1}'' does not match accepted types ''{2}'' in preset {3}"), 283 285 member.getType(), member.getRole(), typesStr, name) 284 286 .primitives(member.getMember().isUsable() ? member.getMember() : n) … … 293 295 * @param n relation to validate 294 296 * @param allroles contains presets for specified relation 295 * @param map contains statistics of occurrences of specified role typesin relation297 * @param map contains statistics of occurrences of specified role in relation 296 298 */ 297 299 private void checkRoles(Relation n, Map<Role, String> allroles, Map<String, RoleInfo> map) { … … 333 335 } else { 334 336 errors.add(TestError.builder(this, Severity.WARNING, ROLE_EMPTY) 335 .message(ROLE_VERIF_PROBLEM_MSG, marktr("Empty role typefound when expecting one of ''{0}''"), templates)337 .message(ROLE_VERIF_PROBLEM_MSG, marktr("Empty role found when expecting one of ''{0}''"), templates) 336 338 .primitives(n) 337 339 .build()); -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/RelationCheckerTest.java
r14969 r14990 8 8 import java.util.List; 9 9 10 import org.junit. Before;10 import org.junit.Rule; 11 11 import org.junit.Test; 12 import org.openstreetmap.josm.JOSMFixture;13 12 import org.openstreetmap.josm.data.osm.Relation; 14 13 import org.openstreetmap.josm.data.osm.RelationMember; 15 14 import org.openstreetmap.josm.data.osm.Way; 16 15 import org.openstreetmap.josm.data.validation.TestError; 17 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 16 import org.openstreetmap.josm.testutils.JOSMTestRules; 17 18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 18 19 19 20 /** … … 21 22 */ 22 23 public class RelationCheckerTest { 23 24 24 /** 25 25 * Setup test. 26 26 */ 27 @Before 28 public void setUp() { 29 JOSMFixture.createUnitTestFixture().init(); 30 getRelationChecker(); 31 } 27 @Rule 28 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 29 public JOSMTestRules rule = new JOSMTestRules().presets(); 32 30 33 31 private static RelationChecker getRelationChecker() { 34 32 RelationChecker checker = new RelationChecker(); 35 TaggingPresets.readFromPreferences();36 33 checker.initialize(); 37 34 return checker; … … 104 101 List<TestError> errors = testRelation(r); 105 102 assertEquals(1, errors.size()); 106 assertEquals("Type 'relation' of relation member with role 'via' does not match accepted types 'node/way' in templateTurn Restriction",103 assertEquals("Type 'relation' of relation member with role 'via' does not match accepted types 'node/way' in preset Turn Restriction", 107 104 errors.get(0).getDescription()); 108 105 } … … 131 128 List<TestError> errors = testRelation(r); 132 129 assertEquals(1, errors.size()); 133 assertTrue(errors.get(0).getDescription().startsWith("Empty role typefound when expecting one of"));130 assertTrue(errors.get(0).getDescription().startsWith("Empty role found when expecting one of")); 134 131 } 135 132 … … 141 138 List<TestError> errors = testRelation(r); 142 139 assertEquals(1, errors.size()); 143 assertEquals("Role of relation member does not match expression 'power' in templatePower Route", errors.get(0).getDescription());140 assertEquals("Role of relation member does not match template expression 'power' in preset Power Route", errors.get(0).getDescription()); 144 141 } 145 142 … … 169 166 r.addMember(new RelationMember("", createPrimitive("way no-rail-way=yes"))); 170 167 assertEquals(1, testRelation(r).size()); 171 assertEquals("Role of relation member does not match expression 'railway' in templatePublic Transport Route (Rail)",168 assertEquals("Role of relation member does not match template expression 'railway' in preset Public Transport Route (Rail)", 172 169 testRelation(r).get(0).getDescription()); 173 170 … … 176 173 assertEquals(1, testRelation(r).size()); 177 174 assertEquals( 178 "Type 'way' of relation member with role 'stop' does not match accepted types 'node' in templatePublic Transport Route (Rail)",175 "Type 'way' of relation member with role 'stop' does not match accepted types 'node' in preset Public Transport Route (Rail)", 179 176 testRelation(r).get(0).getDescription()); 180 177 … … 182 179 r.addMember(new RelationMember("stop", createPrimitive("node public_transport=stop_position bus=yes"))); 183 180 assertEquals(1, testRelation(r).size()); 184 assertEquals("Role of relation member does not match expression 'public_transport=stop_position && "+185 "(train=yes || subway=yes || monorail=yes || tram=yes || light_rail=yes)' in templatePublic Transport Route (Rail)",181 assertEquals("Role of relation member does not match template expression 'public_transport=stop_position && "+ 182 "(train=yes || subway=yes || monorail=yes || tram=yes || light_rail=yes)' in preset Public Transport Route (Rail)", 186 183 testRelation(r).get(0).getDescription()); 187 184 }
Note:
See TracChangeset
for help on using the changeset viewer.