Changeset 14508 in josm for trunk/test


Ignore:
Timestamp:
2018-12-04T08:08:46+01:00 (12 months ago)
Author:
GerdP
Message:

see #17055 improve TagChecker

  • allow Levenshtein distance of 2 so that residentail is found as typo
  • disable Fix for typos where the correct value is not known, e.g. services can be service or services
  • don't suggest values if all preset values are short, e.g.

layer=6 should not say "6 looks like one of [1,2,3,4,5]"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java

    r14490 r14508  
    1616import org.openstreetmap.josm.data.osm.OsmUtils;
    1717import org.openstreetmap.josm.data.osm.Tag;
     18import org.openstreetmap.josm.data.validation.Severity;
    1819import org.openstreetmap.josm.data.validation.TestError;
    1920import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    7879        assertEquals("Misspelled property key", errors.get(0).getMessage());
    7980        assertEquals("Key 'Brand' looks like 'brand'.", errors.get(0).getDescription());
     81        assertEquals(Severity.WARNING, errors.get(0).getSeverity());
    8082        assertFalse(errors.get(0).isFixable());
    8183    }
     
    9193        assertEquals("Presets do not contain property key", errors.get(0).getMessage());
    9294        assertEquals("Key 'namez' not in presets.", errors.get(0).getDescription());
     95        assertEquals(Severity.OTHER, errors.get(0).getSeverity());
     96        assertFalse(errors.get(0).isFixable());
    9397    }
    9498
     
    103107        assertEquals("Misspelled property value", errors.get(0).getMessage());
    104108        assertEquals("Value 'forrest' for key 'landuse' looks like 'forest'.", errors.get(0).getDescription());
     109        assertEquals(Severity.WARNING, errors.get(0).getSeverity());
     110        assertTrue(errors.get(0).isFixable());
    105111    }
    106112
     
    115121        assertEquals("Misspelled property value", errors.get(0).getMessage());
    116122        assertEquals("Value 'servics' for key 'highway' looks like one of [service, services].", errors.get(0).getDescription());
     123        assertEquals(Severity.WARNING, errors.get(0).getSeverity());
     124        assertFalse(errors.get(0).isFixable());
     125    }
     126
     127    /**
     128     * Check for misspelled value.
     129     * @throws IOException if any I/O error occurs
     130     */
     131    @Test
     132    public void testMisspelledTag3() throws IOException {
     133        final List<TestError> errors = test(OsmUtils.createPrimitive("node highway=residentail"));
     134        assertEquals(1, errors.size());
     135        assertEquals("Misspelled property value", errors.get(0).getMessage());
     136        assertEquals("Value 'residentail' for key 'highway' looks like 'residential'.", errors.get(0).getDescription());
     137        assertEquals(Severity.WARNING, errors.get(0).getSeverity());
     138        assertTrue(errors.get(0).isFixable());
     139    }
     140    /**
     141     * Check for misspelled value.
     142     * @throws IOException if any I/O error occurs
     143     */
     144    @Test
     145    public void testShortValNotInPreset() throws IOException {
     146        final List<TestError> errors = test(OsmUtils.createPrimitive("node layer=6"));
     147        assertEquals(1, errors.size());
     148        assertEquals("Presets do not contain property value", errors.get(0).getMessage());
     149        assertEquals("Value '6' for key 'layer' not in presets.", errors.get(0).getDescription());
     150        assertEquals(Severity.OTHER, errors.get(0).getSeverity());
     151        assertFalse(errors.get(0).isFixable());
    117152    }
    118153
Note: See TracChangeset for help on using the changeset viewer.