Changeset 13145 in josm for trunk/test


Ignore:
Timestamp:
2017-11-22T21:37:46+01:00 (21 months ago)
Author:
Don-vip
Message:

see #15582 - simplify our usage of opening_hours.js library (drop mode: it is deduced from tag key) + make the parse method public so it can be called from opening_hours plugin

File:
1 edited

Legend:

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

    r11890 r13145  
    7777    @Test
    7878    public void testI18n() {
    79         assertTrue(openingHourTest.checkOpeningHourSyntax("opening_hours", ".", OpeningHourTest.CheckMode.POINTS_IN_TIME, false, "de")
     79        assertTrue(openingHourTest.checkOpeningHourSyntax("opening_hours", ".", false, "de")
    8080                .get(0).toString().contains("Unerwartetes Zeichen"));
    81         assertFalse(openingHourTest.checkOpeningHourSyntax("opening_hours", ".", OpeningHourTest.CheckMode.POINTS_IN_TIME, false, "en")
     81        assertFalse(openingHourTest.checkOpeningHourSyntax("opening_hours", ".", false, "en")
    8282                .get(0).toString().contains("Unerwartetes Zeichen"));
    8383    }
     
    121121        assertThat(openingHourTest.checkOpeningHourSyntax(null, null), isEmpty());
    122122        assertThat(openingHourTest.checkOpeningHourSyntax(null, ""), isEmpty());
    123         assertEquals("null - The value contains nothing meaningful which can be parsed.",
     123        assertEquals("opening_hours - The value contains nothing meaningful which can be parsed.",
     124                openingHourTest.checkOpeningHourSyntax("opening_hours", " ").get(0).getMessage());
     125        assertEquals("null - The optional_conf_parm[\"tag_key\"] parameter is of unknown type. Given object, expected string.",
    124126                openingHourTest.checkOpeningHourSyntax(null, " ").get(0).getMessage());
    125127    }
     
    180182        final String key = "service_times";
    181183        // frequently used tags according to https://taginfo.openstreetmap.org/keys/service_times#values
    182         assertThat(openingHourTest.checkOpeningHourSyntax(key, "Su 10:00", OpeningHourTest.CheckMode.BOTH), isEmpty());
    183         assertThat(openingHourTest.checkOpeningHourSyntax(key, "automatic", OpeningHourTest.CheckMode.BOTH), not(isEmpty()));
    184         assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Sa 09:00-18:00", OpeningHourTest.CheckMode.BOTH), isEmpty());
    185         assertThat(openingHourTest.checkOpeningHourSyntax(key, "Su 09:30; We 19:30", OpeningHourTest.CheckMode.BOTH), isEmpty());
    186         assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 00:00-00:30,04:00-00:30; Sa,Su,PH 00:00-24:00",
    187                 OpeningHourTest.CheckMode.BOTH), isEmpty());
    188         assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00",
    189                 OpeningHourTest.CheckMode.BOTH), hasSize(1));
     184        assertThat(openingHourTest.checkOpeningHourSyntax(key, "Su 10:00"), isEmpty());
     185        assertThat(openingHourTest.checkOpeningHourSyntax(key, "automatic"), not(isEmpty()));
     186        assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Sa 09:00-18:00"), isEmpty());
     187        assertThat(openingHourTest.checkOpeningHourSyntax(key, "Su 09:30; We 19:30"), isEmpty());
     188        assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 00:00-00:30,04:00-00:30; Sa,Su,PH 00:00-24:00"), isEmpty());
     189        assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00"), hasSize(1));
    190190        assertEquals("Mo-Fr 00:00-00:30,04:00-00:30; Sa,Su,PH 00:00-24:00",
    191                 openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00",
    192                 OpeningHourTest.CheckMode.BOTH).get(0).getPrettifiedValue());
     191                openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00").get(0).getPrettifiedValue());
    193192        assertEquals("Mo-Fr 00:00-00:30,04:00-00:30; Sa,Su,PH 00:00-24:00",
    194                 openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00",
    195                 OpeningHourTest.CheckMode.BOTH).get(0).getPrettifiedValue());
     193                openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00").get(0).getPrettifiedValue());
    196194    }
    197195
     
    203201        final String key = "collection_times";
    204202        // frequently used tags according to https://taginfo.openstreetmap.org/keys/collection_times#values
    205         assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Sa 09:00", OpeningHourTest.CheckMode.BOTH), isEmpty());
    206         assertThat(openingHourTest.checkOpeningHourSyntax(key, "fixme", OpeningHourTest.CheckMode.BOTH), not(isEmpty()));
    207         assertThat(openingHourTest.checkOpeningHourSyntax(key, "daily", OpeningHourTest.CheckMode.BOTH), not(isEmpty()));
    208         assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 13:30,17:45,19:00; Sa 15:00; Su 11:00",
    209                 OpeningHourTest.CheckMode.BOTH), isEmpty());
    210         assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00",
    211                 OpeningHourTest.CheckMode.BOTH), hasSize(1));
     203        assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Sa 09:00"), isEmpty());
     204        assertThat(openingHourTest.checkOpeningHourSyntax(key, "fixme"), not(isEmpty()));
     205        assertThat(openingHourTest.checkOpeningHourSyntax(key, "daily"), not(isEmpty()));
     206        assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 13:30,17:45,19:00; Sa 15:00; Su 11:00"), isEmpty());
     207        assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00"), hasSize(1));
    212208        assertEquals(Severity.OTHER,
    213                 openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00",
    214                 OpeningHourTest.CheckMode.BOTH).get(0).getSeverity());
     209                openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00").get(0).getSeverity());
    215210        assertEquals("Mo-Fr 13:30,17:45,19:00; Sa 15:00; Su 11:00",
    216                 openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00",
    217                 OpeningHourTest.CheckMode.BOTH).get(0).getPrettifiedValue());
     211                openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00").get(0).getPrettifiedValue());
    218212    }
    219213
Note: See TracChangeset for help on using the changeset viewer.