Changeset 7051 in josm
- Timestamp:
- 2014-05-02T06:16:05+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java
r7005 r7051 33 33 /** 34 34 * Setup test. 35 * @throws Exception if test cannot be initialized 35 36 */ 36 37 @Before … … 40 41 } 41 42 43 /** 44 * Test #1 of opening_hours syntax. 45 */ 42 46 @Test 43 public void testCheckOpeningHourSyntax1() throws Exception{47 public void testCheckOpeningHourSyntax1() { 44 48 final String key = "opening_hours"; 45 49 // frequently used tags according to https://taginfo.openstreetmap.org/keys/opening_hours#values … … 53 57 } 54 58 59 /** 60 * Test #2 of opening_hours syntax. 61 */ 55 62 @Test 56 public void testCheckOpeningHourSyntax2() throws Exception{63 public void testCheckOpeningHourSyntax2() { 57 64 final String key = "opening_hours"; 58 65 final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Tue"); 59 66 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\".)")); 61 68 assertThat(errors.get(0).getSeverity(), is(Severity.WARNING)); 62 69 } 63 70 71 /** 72 * Test #3 of opening_hours syntax. 73 */ 64 74 @Test 65 public void testCheckOpeningHourSyntax3() throws Exception{75 public void testCheckOpeningHourSyntax3() { 66 76 final String key = "opening_hours"; 67 77 final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Sa-Su 10.00-20.00"); 68 78 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)")); 70 80 assertThat(errors.get(0).getSeverity(), is(Severity.WARNING)); 71 81 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)")); 73 83 assertThat(errors.get(1).getSeverity(), is(Severity.WARNING)); 74 84 } 75 85 86 /** 87 * Test #4 of opening_hours syntax. 88 */ 76 89 @Test 77 public void testCheckOpeningHourSyntax4() throws Exception{90 public void testCheckOpeningHourSyntax4() { 78 91 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(null, null), isEmpty()); 79 92 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(null, ""), isEmpty()); … … 81 94 } 82 95 96 /** 97 * Test #5 of opening_hours syntax. 98 */ 83 99 @Test 84 public void testCheckOpeningHourSyntax5() throws Exception{100 public void testCheckOpeningHourSyntax5() { 85 101 final String key = "opening_hours"; 86 102 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "badtext"), hasSize(1)); 87 103 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.)")); 89 105 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m"), hasSize(1)); 90 106 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?)")); 92 108 } 93 109 110 /** 111 * Test #6 of opening_hours syntax. 112 */ 94 113 @Test 95 public void testCheckOpeningHourSyntax6() throws Exception{114 public void testCheckOpeningHourSyntax6() { 96 115 final String key = "opening_hours"; 97 116 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "PH open \"always open on public holidays\""), isEmpty()); 98 117 } 99 118 119 /** 120 * Test #7 of opening_hours syntax. 121 */ 100 122 @Test 101 public void testCheckOpeningHourSyntax7() throws Exception{123 public void testCheckOpeningHourSyntax7() { 102 124 final String key = "opening_hours"; 103 125 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "9:00-18:00"), hasSize(1)); … … 106 128 } 107 129 130 /** 131 * Non-regression Test of opening_hours syntax for bug #9367. 132 */ 108 133 @Test 109 public void testCheckOpeningHourSyntaxTicket9367() throws Exception{134 public void testCheckOpeningHourSyntaxTicket9367() { 110 135 final String key = "opening_hours"; 111 136 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\".)")); 113 139 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getPrettifiedValue(), is("Mo,Tu 04:00-17:00")); 114 140 } 115 141 142 /** 143 * Test #1 of service_times syntax. 144 */ 116 145 @Test 117 public void testCheckServiceTimeSyntax1() throws Exception{146 public void testCheckServiceTimeSyntax1() { 118 147 final String key = "service_times"; 119 148 // frequently used tags according to https://taginfo.openstreetmap.org/keys/service_times#values … … 128 157 } 129 158 159 /** 160 * Test #1 of collection_times syntax. 161 */ 130 162 @Test 131 public void testCheckCollectionTimeSyntax1() throws Exception{163 public void testCheckCollectionTimeSyntax1() { 132 164 final String key = "collection_times"; 133 165 // frequently used tags according to https://taginfo.openstreetmap.org/keys/collection_times#values … … 141 173 } 142 174 175 /** 176 * Tests that predefined values in presets are correct. 177 */ 143 178 @Test 144 public void testPresetValues() throws Exception{179 public void testPresetValues() { 145 180 final Collection<TaggingPreset> presets = TaggingPresetReader.readFromPreferences(false, false); 146 181 final Set<Tag> values = new LinkedHashSet<>();
Note:
See TracChangeset
for help on using the changeset viewer.