Changeset 9382 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r9023 r9382 444 444 // misspelled preset key 445 445 String i = marktr("Key ''{0}'' looks like ''{1}''."); 446 errors.add(new FixableTestError(this, Severity.WARNING, tr("Misspelled property key"), 447 tr(i, key, fixedKey), 448 MessageFormat.format(i, key, fixedKey), MISSPELLED_KEY, p, 449 new ChangePropertyKeyCommand(p, key, fixedKey))); 446 final TestError error; 447 if (p.hasKey(fixedKey)) { 448 error = new TestError(this, Severity.WARNING, tr("Misspelled property key"), 449 tr(i, key, fixedKey), 450 MessageFormat.format(i, key, fixedKey), MISSPELLED_KEY, p); 451 } else { 452 error = new FixableTestError(this, Severity.WARNING, tr("Misspelled property key"), 453 tr(i, key, fixedKey), 454 MessageFormat.format(i, key, fixedKey), MISSPELLED_KEY, p, 455 new ChangePropertyKeyCommand(p, key, fixedKey)); 456 } 457 errors.add(error); 450 458 withErrors.put(p, "WPK"); 451 459 } else { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java
r9231 r9382 45 45 */ 46 46 @Test 47 public void test InvalidKey() throws IOException {47 public void testMisspelledKey1() throws IOException { 48 48 final List<TestError> errors = test(OsmUtils.createPrimitive("node Name=Main")); 49 49 assertEquals(1, errors.size()); 50 50 assertEquals("Misspelled property key", errors.get(0).getMessage()); 51 51 assertEquals("Key 'Name' looks like 'name'.", errors.get(0).getDescription()); 52 assertEquals(true, errors.get(0).isFixable()); 52 53 } 53 54 … … 57 58 */ 58 59 @Test 59 public void testMisspelledKey () throws IOException {60 public void testMisspelledKey2() throws IOException { 60 61 final List<TestError> errors = test(OsmUtils.createPrimitive("node landuse;=forest")); 61 62 assertEquals(1, errors.size()); 62 63 assertEquals("Misspelled property key", errors.get(0).getMessage()); 63 64 assertEquals("Key 'landuse;' looks like 'landuse'.", errors.get(0).getDescription()); 65 assertEquals(true, errors.get(0).isFixable()); 66 } 67 68 /** 69 * Check for mispelled key where the suggested alternative is in use. The error should not be fixable. 70 * @throws IOException if any I/O error occurs 71 */ 72 @Test 73 public void testMisspelledKeyButAlternativeInUse() throws IOException { 74 // ticket 12329 75 final List<TestError> errors = test(OsmUtils.createPrimitive("node amenity=fuel brand=bah Brand=foo")); 76 assertEquals(1, errors.size()); 77 assertEquals("Misspelled property key", errors.get(0).getMessage()); 78 assertEquals("Key 'Brand' looks like 'brand'.", errors.get(0).getDescription()); 79 assertEquals(false, errors.get(0).isFixable()); 64 80 } 65 81
Note:
See TracChangeset
for help on using the changeset viewer.