Changeset 6415 in josm for trunk/test


Ignore:
Timestamp:
2013-11-26T02:15:33+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #9364 - service_times reported as "opening_hours - (...)" in validator

File:
1 edited

Legend:

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

    r6378 r6415  
    2828    @Test
    2929    public void testCheckOpeningHourSyntax1() throws Exception {
     30        final String key = "opening_hours";
    3031        // frequently used tags according to http://taginfo.openstreetmap.org/keys/opening_hours#values
    31         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("24/7").isEmpty(), is(true));
    32         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Mo-Fr 08:30-20:00").isEmpty(), is(true));
    33         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("09:00-21:00").isEmpty(), is(true));
    34         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Su-Th sunset-24:00, 04:00-sunrise; Fr-Sa sunset-sunrise").isEmpty(), is(true));
     32        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "24/7").isEmpty(), is(true));
     33        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 08:30-20:00").isEmpty(), is(true));
     34        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "09:00-21:00").isEmpty(), is(true));
     35        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Su-Th sunset-24:00, 04:00-sunrise; Fr-Sa sunset-sunrise").isEmpty(), is(true));
    3536    }
    3637
    3738    @Test
    3839    public void testCheckOpeningHourSyntax2() throws Exception {
    39         final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax("Mo-Tue");
     40        final String key = "opening_hours";
     41        final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Tue");
    4042        assertThat(errors.size(), is(1));
    4143        assertThat(errors.get(0).getMessage(), is("Mo-Tue <--- (Please use the abbreviation \"Tu\" for \"tue\".)"));
     
    4547    @Test
    4648    public void testCheckOpeningHourSyntax3() throws Exception {
    47         final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax("Sa-Su 10.00-20.00");
     49        final String key = "opening_hours";
     50        final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Sa-Su 10.00-20.00");
    4851        assertThat(errors.size(), is(2));
    4952        assertThat(errors.get(0).getMessage(), is("Sa-Su 10. <--- (Please use \":\" as hour/minute-separator)"));
     
    5659    @Test
    5760    public void testCheckOpeningHourSyntax4() throws Exception {
    58         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(null).isEmpty(), is(true));
    59         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("").isEmpty(), is(true));
    60         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(" ").isEmpty(), is(true));
     61        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(null, null).isEmpty(), is(true));
     62        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(null, "").isEmpty(), is(true));
     63        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(null, " ").isEmpty(), is(true));
    6164    }
    6265
    6366    @Test
    6467    public void testCheckOpeningHourSyntax5() throws Exception {
    65         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("badtext").size(), is(1));
    66         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("badtext").get(0).getMessage(),
     68        final String key = "opening_hours";
     69        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "badtext").size(), is(1));
     70        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "badtext").get(0).getMessage(),
    6771                is("opening_hours - ba <--- (Unexpected token: \"b\" This means that the syntax is not valid at that point or it is currently not supported.)"));
    68         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("5.00 p.m-11.00 p.m").size(), is(1));
    69         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("5.00 p.m-11.00 p.m").get(0).getMessage(),
     72        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m").size(), is(1));
     73        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m").get(0).getMessage(),
    7074                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?)"));
    7175    }
     
    7377    @Test
    7478    public void testCheckOpeningHourSyntax6() throws Exception {
    75         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("PH open \"always open on public holidays\"").isEmpty(), is(true));
     79        final String key = "opening_hours";
     80        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "PH open \"always open on public holidays\"").isEmpty(), is(true));
    7681    }
    7782
    7883    @Test
    7984    public void testCheckServiceTimeSyntax1() throws Exception {
     85        final String key = "service_times";
    8086        // frequently used tags according to http://taginfo.openstreetmap.org/keys/service_times#values
    81         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Su 10:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
    82         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("automatic", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(false));
    83         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Mo-Sa 09:00-18:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
    84         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Su 09:30; We 19:30", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
    85         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
     87        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Su 10:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
     88        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "automatic", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(false));
     89        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Sa 09:00-18:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
     90        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Su 09:30; We 19:30", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
     91        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
    8692    }
    8793
    8894    @Test
    8995    public void testCheckCollectionTimeSyntax1() throws Exception {
     96        final String key = "collection_times";
    9097        // frequently used tags according to http://taginfo.openstreetmap.org/keys/collection_times#values
    91         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Mo-Sa 09:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
    92         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("fixme", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(false));
    93         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("daily", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(false));
    94         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
     98        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Sa 09:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
     99        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "fixme", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(false));
     100        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "daily", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(false));
     101        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
    95102    }
    96103}
Note: See TracChangeset for help on using the changeset viewer.