Changeset 14990 in josm for trunk/test


Ignore:
Timestamp:
2019-04-14T17:29:33+02:00 (5 years ago)
Author:
GerdP
Message:

see #17567: improve messages created by RelationChecker

  • new error code 1709 for " Type {0} of relation member with role {1} does not match accepted types {2} in preset {3}"
  • role type -> role
  • replace template by preset where appropriate
  • adapt unit test and improve speed
File:
1 edited

Legend:

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

    r14969 r14990  
    88import java.util.List;
    99
    10 import org.junit.Before;
     10import org.junit.Rule;
    1111import org.junit.Test;
    12 import org.openstreetmap.josm.JOSMFixture;
    1312import org.openstreetmap.josm.data.osm.Relation;
    1413import org.openstreetmap.josm.data.osm.RelationMember;
    1514import org.openstreetmap.josm.data.osm.Way;
    1615import org.openstreetmap.josm.data.validation.TestError;
    17 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
     16import org.openstreetmap.josm.testutils.JOSMTestRules;
     17
     18import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1819
    1920/**
     
    2122 */
    2223public class RelationCheckerTest {
    23 
    2424    /**
    2525     * Setup test.
    2626     */
    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();
    3230
    3331    private static RelationChecker getRelationChecker() {
    3432        RelationChecker checker = new RelationChecker();
    35         TaggingPresets.readFromPreferences();
    3633        checker.initialize();
    3734        return checker;
     
    104101        List<TestError> errors = testRelation(r);
    105102        assertEquals(1, errors.size());
    106         assertEquals("Type 'relation' of relation member with role 'via' does not match accepted types 'node/way' in template Turn Restriction",
     103        assertEquals("Type 'relation' of relation member with role 'via' does not match accepted types 'node/way' in preset Turn Restriction",
    107104                errors.get(0).getDescription());
    108105    }
     
    131128        List<TestError> errors = testRelation(r);
    132129        assertEquals(1, errors.size());
    133         assertTrue(errors.get(0).getDescription().startsWith("Empty role type found when expecting one of"));
     130        assertTrue(errors.get(0).getDescription().startsWith("Empty role found when expecting one of"));
    134131    }
    135132
     
    141138        List<TestError> errors = testRelation(r);
    142139        assertEquals(1, errors.size());
    143         assertEquals("Role of relation member does not match expression 'power' in template Power 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());
    144141    }
    145142
     
    169166        r.addMember(new RelationMember("", createPrimitive("way no-rail-way=yes")));
    170167        assertEquals(1, testRelation(r).size());
    171         assertEquals("Role of relation member does not match expression 'railway' in template Public Transport Route (Rail)",
     168        assertEquals("Role of relation member does not match template expression 'railway' in preset Public Transport Route (Rail)",
    172169                testRelation(r).get(0).getDescription());
    173170
     
    176173        assertEquals(1, testRelation(r).size());
    177174        assertEquals(
    178                 "Type 'way' of relation member with role 'stop' does not match accepted types 'node' in template Public Transport Route (Rail)",
     175                "Type 'way' of relation member with role 'stop' does not match accepted types 'node' in preset Public Transport Route (Rail)",
    179176                testRelation(r).get(0).getDescription());
    180177
     
    182179        r.addMember(new RelationMember("stop", createPrimitive("node public_transport=stop_position bus=yes")));
    183180        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 template Public 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)",
    186183                testRelation(r).get(0).getDescription());
    187184    }
Note: See TracChangeset for help on using the changeset viewer.