Changeset 7051 in josm for trunk


Ignore:
Timestamp:
2014-05-02T06:16:05+02:00 (6 years ago)
Author:
Don-vip
Message:

fix opening_hours unit test

File:
1 edited

Legend:

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

    r7005 r7051  
    3333    /**
    3434     * Setup test.
     35     * @throws Exception if test cannot be initialized
    3536     */
    3637    @Before
     
    4041    }
    4142
     43    /**
     44     * Test #1 of opening_hours syntax.
     45     */
    4246    @Test
    43     public void testCheckOpeningHourSyntax1() throws Exception {
     47    public void testCheckOpeningHourSyntax1() {
    4448        final String key = "opening_hours";
    4549        // frequently used tags according to https://taginfo.openstreetmap.org/keys/opening_hours#values
     
    5357    }
    5458
     59    /**
     60     * Test #2 of opening_hours syntax.
     61     */
    5562    @Test
    56     public void testCheckOpeningHourSyntax2() throws Exception {
     63    public void testCheckOpeningHourSyntax2() {
    5764        final String key = "opening_hours";
    5865        final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Tue");
    5966        assertThat(errors, hasSize(1));
    60         assertThat(errors.get(0).getMessage(), is("Mo-Tue <--- (Please use the abbreviation \"Tu\" for \"tue\".)"));
     67        assertThat(errors.get(0).getMessage(), is(key + " - Mo-Tue <--- (Please use the abbreviation \"Tu\" for \"tue\".)"));
    6168        assertThat(errors.get(0).getSeverity(), is(Severity.WARNING));
    6269    }
    6370
     71    /**
     72     * Test #3 of opening_hours syntax.
     73     */
    6474    @Test
    65     public void testCheckOpeningHourSyntax3() throws Exception {
     75    public void testCheckOpeningHourSyntax3() {
    6676        final String key = "opening_hours";
    6777        final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Sa-Su 10.00-20.00");
    6878        assertThat(errors, hasSize(2));
    69         assertThat(errors.get(0).getMessage(), is("Sa-Su 10. <--- (Please use \":\" as hour/minute-separator)"));
     79        assertThat(errors.get(0).getMessage(), is(key + " - Sa-Su 10. <--- (Please use \":\" as hour/minute-separator)"));
    7080        assertThat(errors.get(0).getSeverity(), is(Severity.WARNING));
    7181        assertThat(errors.get(0).getPrettifiedValue(), is("Sa-Su 10:00-20:00"));
    72         assertThat(errors.get(1).getMessage(), is("Sa-Su 10.00-20. <--- (Please use \":\" as hour/minute-separator)"));
     82        assertThat(errors.get(1).getMessage(), is(key + " - Sa-Su 10.00-20. <--- (Please use \":\" as hour/minute-separator)"));
    7383        assertThat(errors.get(1).getSeverity(), is(Severity.WARNING));
    7484    }
    7585
     86    /**
     87     * Test #4 of opening_hours syntax.
     88     */
    7689    @Test
    77     public void testCheckOpeningHourSyntax4() throws Exception {
     90    public void testCheckOpeningHourSyntax4() {
    7891        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(null, null), isEmpty());
    7992        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(null, ""), isEmpty());
     
    8194    }
    8295
     96    /**
     97     * Test #5 of opening_hours syntax.
     98     */
    8399    @Test
    84     public void testCheckOpeningHourSyntax5() throws Exception {
     100    public void testCheckOpeningHourSyntax5() {
    85101        final String key = "opening_hours";
    86102        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "badtext"), hasSize(1));
    87103        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "badtext").get(0).getMessage(),
    88                 is("opening_hours - ba <--- (Unexpected token: \"b\" This means that the syntax is not valid at that point or it is currently not supported.)"));
     104                is(key + " - ba <--- (Unexpected token: \"b\" Invalid/unsupported syntax.)"));
    89105        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m"), hasSize(1));
    90106        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m").get(0).getMessage(),
    91                 is("opening_hours - 5.00 p <--- (hyphen (-) or open end (+) in time range expected. For working with points in time, the mode for opening_hours.js has to be altered. Maybe wrong tag?)"));
     107                is(key + " - 5.00 p <--- (hyphen (-) or open end (+) in time range expected. For working with points in time, the mode for opening_hours.js has to be altered. Maybe wrong tag?)"));
    92108    }
    93109
     110    /**
     111     * Test #6 of opening_hours syntax.
     112     */
    94113    @Test
    95     public void testCheckOpeningHourSyntax6() throws Exception {
     114    public void testCheckOpeningHourSyntax6() {
    96115        final String key = "opening_hours";
    97116        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "PH open \"always open on public holidays\""), isEmpty());
    98117    }
    99118
     119    /**
     120     * Test #7 of opening_hours syntax.
     121     */
    100122    @Test
    101     public void testCheckOpeningHourSyntax7() throws Exception {
     123    public void testCheckOpeningHourSyntax7() {
    102124        final String key = "opening_hours";
    103125        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "9:00-18:00"), hasSize(1));
     
    106128    }
    107129
     130    /**
     131     * Non-regression Test of opening_hours syntax for bug #9367.
     132     */
    108133    @Test
    109     public void testCheckOpeningHourSyntaxTicket9367() throws Exception {
     134    public void testCheckOpeningHourSyntaxTicket9367() {
    110135        final String key = "opening_hours";
    111136        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getSeverity(), is(Severity.WARNING));
    112         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getMessage(), is("Mo,Tu 04-17 <--- (Time range without minutes specified. Not very explicit! Please use this syntax instead e.g. \"12:00-14:00\".)"));
     137        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getMessage(),
     138                is(key + " - Mo,Tu 04-17 <--- (Time range without minutes specified. Not very explicit! Please use this syntax instead e.g. \"12:00-14:00\".)"));
    113139        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getPrettifiedValue(), is("Mo,Tu 04:00-17:00"));
    114140    }
    115141
     142    /**
     143     * Test #1 of service_times syntax.
     144     */
    116145    @Test
    117     public void testCheckServiceTimeSyntax1() throws Exception {
     146    public void testCheckServiceTimeSyntax1() {
    118147        final String key = "service_times";
    119148        // frequently used tags according to https://taginfo.openstreetmap.org/keys/service_times#values
     
    128157    }
    129158
     159    /**
     160     * Test #1 of collection_times syntax.
     161     */
    130162    @Test
    131     public void testCheckCollectionTimeSyntax1() throws Exception {
     163    public void testCheckCollectionTimeSyntax1() {
    132164        final String key = "collection_times";
    133165        // frequently used tags according to https://taginfo.openstreetmap.org/keys/collection_times#values
     
    141173    }
    142174
     175    /**
     176     * Tests that predefined values in presets are correct.
     177     */
    143178    @Test
    144     public void testPresetValues() throws Exception {
     179    public void testPresetValues() {
    145180        final Collection<TaggingPreset> presets = TaggingPresetReader.readFromPreferences(false, false);
    146181        final Set<Tag> values = new LinkedHashSet<>();
Note: See TracChangeset for help on using the changeset viewer.