Ignore:
Timestamp:
2019-10-16T17:23:02+02:00 (5 years ago)
Author:
GerdP
Message:

fix #17837 and #18223, add unit tests

TODO:

  • Will havily blow up size of preferences.xml when user ignores lots of "single elements" instead of the group.
  • Maybe ignore entries in preferences with many (how many?) elements, as those probably were caused by error #18223 and are meaningless
File:
1 edited

Legend:

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

    r14138 r15459  
    22package org.openstreetmap.josm.data.validation;
    33
     4import static org.junit.Assert.assertFalse;
     5import static org.junit.Assert.assertTrue;
     6
     7import org.junit.Before;
    48import org.junit.Rule;
    59import org.junit.Test;
     
    1923    @Rule
    2024    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    21     public JOSMTestRules test = new JOSMTestRules();
     25    public JOSMTestRules test = new JOSMTestRules().projection();
    2226
     27    /**
     28     * Setup test.
     29     * @throws Exception if an error occurs
     30     */
     31    @Before
     32    public void setUp() throws Exception {
     33        OsmValidator.clearIgnoredErrors();
     34    }
    2335    /**
    2436     * Tests that {@code OsmValidator} satisfies utility class criterias.
     
    2941        UtilityClassTestUtil.assertUtilityClassWellDefined(OsmValidator.class);
    3042    }
     43
     44    /**
     45     * Test that {@link OsmValidator#cleanupIgnoredErrors()} really removes entry with element IDs when group is ignored
     46     */
     47    @Test
     48    public void testCleanupIgnoredErrors1() {
     49        OsmValidator.addIgnoredError("1351:n_2449148994:w_236955234", "Way end node near other way");
     50        OsmValidator.addIgnoredError("1351:n_6871910559:w_733713588", "Way end node near other way");
     51        OsmValidator.addIgnoredError("1351");
     52        OsmValidator.cleanupIgnoredErrors();
     53        assertTrue(OsmValidator.hasIgnoredError("1351"));
     54        assertFalse(OsmValidator.hasIgnoredError("1351:n_6871910559:w_733713588"));
     55        assertFalse(OsmValidator.hasIgnoredError("1351:n_2449148994:w_236955234"));
     56    }
     57
     58    /**
     59     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/17837">Bug #17837</a>.
     60     * {@link OsmValidator#cleanupIgnoredErrors()} must not remove entry 1201 when 120 is before it.
     61     */
     62    @Test
     63    public void testCleanupIgnoredErrorsTicket17837() {
     64        OsmValidator.addIgnoredError("120");
     65        OsmValidator.addIgnoredError("3000");
     66        OsmValidator.addIgnoredError("1201"); // starts with 120, but has different code
     67        OsmValidator.cleanupIgnoredErrors();
     68        assertTrue(OsmValidator.hasIgnoredError("1201"));
     69    }
     70
     71    /**
     72     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/18223">Bug #18223</a>.
     73     * {@link OsmValidator#cleanupIgnoredErrors()} must not combine primitives.
     74     */
     75    @Test
     76    public void testCleanupIgnoredErrorsTicket18223() {
     77        OsmValidator.addIgnoredError("1351:n_2449148994:w_236955234", "Way end node near other way");
     78        OsmValidator.addIgnoredError("1351:n_6871910559:w_733713588", "Way end node near other way");
     79        OsmValidator.cleanupIgnoredErrors();
     80        assertFalse(OsmValidator.hasIgnoredError("1351"));
     81        assertTrue(OsmValidator.hasIgnoredError("1351:n_2449148994:w_236955234"));
     82        assertTrue(OsmValidator.hasIgnoredError("1351:n_6871910559:w_733713588"));
     83    }
     84
    3185}
Note: See TracChangeset for help on using the changeset viewer.