Ignore:
Timestamp:
2018-03-03T20:33:09+01:00 (6 years ago)
Author:
Don-vip
Message:

fix #16044 - Autofix invalid URL with the wrong type of slashes

Location:
trunk/test/unit/org/openstreetmap/josm/data/validation/tests
Files:
3 edited

Legend:

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

    r10945 r13489  
    22package org.openstreetmap.josm.data.validation.tests;
    33
     4import static org.junit.Assert.assertEquals;
    45import static org.junit.Assert.assertNotNull;
    56import static org.junit.Assert.assertNull;
     7import static org.openstreetmap.josm.tools.I18n.tr;
    68
    79import org.junit.Rule;
    810import org.junit.Test;
    9 import org.openstreetmap.josm.data.osm.OsmUtils;
     11import org.openstreetmap.josm.TestUtils;
    1012import org.openstreetmap.josm.data.validation.TestError;
    1113import org.openstreetmap.josm.data.validation.routines.AbstractValidator;
     
    7577    }
    7678
    77     private static void testKey(String key, String value, boolean valid, AbstractValidator validator, int code) {
    78         TestError error = TEST.validateTag(OsmUtils.createPrimitive("node "+key+"="+value+""), key, validator, code);
     79    /**
     80     * Test of invalid slashes.
     81     */
     82    @Test
     83    public void testInvalidSlashes() {
     84        TestError error = testUrl("website", "http:\\\\www.sjoekurs.no", false);
     85        assertEquals(tr("''{0}'': {1}", "website", tr("URL contains backslashes instead of slashes")), error.getDescription());
     86        assertNotNull(error.getFix());
     87    }
     88
     89    private static TestError testKey(String key, String value, boolean valid, AbstractValidator validator, int code) {
     90        TestError error = TEST.validateTag(TestUtils.addFakeDataSet(TestUtils.newNode(key+"="+value+"")), key, validator, code);
    7991        if (valid) {
    8092            assertNull(error != null ? error.getMessage() : null, error);
     
    8294            assertNotNull(error);
    8395        }
     96        return error;
    8497    }
    8598
    86     private static void testUrl(String key, String value, boolean valid) {
    87         testKey(key, value, valid, UrlValidator.getInstance(), InternetTags.INVALID_URL);
     99    private static TestError testUrl(String key, String value, boolean valid) {
     100        return testKey(key, value, valid, UrlValidator.getInstance(), InternetTags.INVALID_URL);
    88101    }
    89102
    90     private static void testEmail(String key, String value, boolean valid) {
    91         testKey(key, value, valid, EmailValidator.getInstance(), InternetTags.INVALID_EMAIL);
     103    private static TestError testEmail(String key, String value, boolean valid) {
     104        return testKey(key, value, valid, EmailValidator.getInstance(), InternetTags.INVALID_EMAIL);
    92105    }
    93106}
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    r13195 r13489  
    102102    @Test
    103103    public void testTicket10913() throws ParseException {
    104         final OsmPrimitive p = OsmUtils.createPrimitive("way highway=tertiary construction=yes");
     104        final OsmPrimitive p = TestUtils.addFakeDataSet(TestUtils.newWay("highway=tertiary construction=yes"));
    105105        final TagCheck check = TagCheck.readMapCSS(new StringReader("way {" +
    106106                "throwError: \"error\";" +
     
    108108                "fixAdd: \"highway=construction\";\n" +
    109109                "}")).parseChecks.get(0);
    110         new DataSet(p);
    111110        final Command command = check.fixPrimitive(p);
    112111        assertTrue(command instanceof SequenceCommand);
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java

    r13435 r13489  
    1212import org.junit.Rule;
    1313import org.junit.Test;
    14 import org.openstreetmap.josm.data.osm.DataSet;
     14import org.openstreetmap.josm.TestUtils;
    1515import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1616import org.openstreetmap.josm.data.osm.OsmUtils;
     
    3434
    3535    List<TestError> test(OsmPrimitive primitive) throws IOException {
    36         new DataSet(primitive);
    3736        final TagChecker checker = new TagChecker();
    3837        checker.initialize();
    3938        checker.startTest(null);
    40         checker.check(primitive);
     39        checker.check(TestUtils.addFakeDataSet(primitive));
    4140        return checker.getErrors();
    4241    }
Note: See TracChangeset for help on using the changeset viewer.