Changeset 16178 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/TestError.java
r15939 r16178 220 220 * 221 221 * @return a new test error with the specified values 222 * @throws IllegalArgumentException when {@link #message} or {@link #primitives} is null /empty.222 * @throws IllegalArgumentException when {@link #message} or {@link #primitives} is null. 223 223 */ 224 224 public TestError build() { 225 225 CheckParameterUtil.ensureParameterNotNull(message, "message not set"); 226 226 CheckParameterUtil.ensureParameterNotNull(primitives, "primitives not set"); 227 CheckParameterUtil.ensureThat(!primitives.isEmpty(), "primitives is empty");228 227 if (this.highlighted == null) { 229 228 this.highlighted = Collections.emptySet(); -
trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java
r16154 r16178 46 46 * @param message The error message 47 47 * @param key The incriminated key, used for display. 48 * @param value The incriminated value, used for comparison with prettified value. 48 49 * @param prettifiedValue The prettified value 49 50 * @param p The incriminated OSM primitive. 50 51 * @return The real test error given to JOSM validator. Can be fixable or not if a prettified values has been determined. 51 52 */ 52 private TestError createTestError(Severity severity, String message, String key, String prettifiedValue, OsmPrimitive p) {53 private TestError createTestError(Severity severity, String message, String key, String value, String prettifiedValue, OsmPrimitive p) { 53 54 final TestError.Builder error = TestError.builder(this, severity, 2901) 54 55 .message(tr("Opening hours syntax"), message) // todo obtain English message for ignore functionality 55 .primitives(p );56 if (p rettifiedValue == null || prettifiedValue.equals(p.get(key))) {56 .primitives(p != null ? new OsmPrimitive[] {p} : new OsmPrimitive[] {}); 57 if (p == null || prettifiedValue == null || prettifiedValue.equals(value)) { 57 58 return error.build(); 58 59 } else { … … 96 97 } 97 98 } catch (ParseException e) { 98 return Collections.singletonList(createTestError(Severity.WARNING, e.getMessage(), key, prettifiedValue, p));99 return Collections.singletonList(createTestError(Severity.WARNING, e.getMessage(), key, value, prettifiedValue, p)); 99 100 } 100 101 101 if (!includeOtherSeverityChecks() || Objects.equals(value, prettifiedValue) || p == null) {102 if (!includeOtherSeverityChecks() || Objects.equals(value, prettifiedValue)) { 102 103 return Collections.emptyList(); 103 104 } else { 104 105 final String message = tr("{0} value can be prettified", key); 105 return Collections.singletonList(createTestError(Severity.OTHER, message, key, prettifiedValue, p));106 return Collections.singletonList(createTestError(Severity.OTHER, message, key, value, prettifiedValue, p)); 106 107 } 107 108 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java
r16114 r16178 83 83 final String key = "opening_hours"; 84 84 String value = "."; 85 assertEquals( "Vorgefunden wurde: \".\" \". \" in Zeile 0, Spalte 0\nErwartet wurde: <EOF>",85 assertEquals(String.format("Vorgefunden wurde: \".\" \". \" in Zeile 0, Spalte 0%nErwartet wurde: <EOF>"), 86 86 checkOpeningHourSyntax(key, value, Locale.GERMAN).get(0).getDescription()); 87 assertEquals( "Encountered: \".\" \". \" at line 0, column 0\nWas expecting: <EOF>",87 assertEquals(String.format("Encountered: \".\" \". \" at line 0, column 0%nWas expecting: <EOF>"), 88 88 checkOpeningHourSyntax(key, value, Locale.ENGLISH).get(0).getDescription()); 89 89 value = "Mon-Thu 12-18"; … … 140 140 final String key = "opening_hours"; 141 141 assertThat(checkOpeningHourSyntax(key, "badtext"), hasSize(1)); 142 assertEquals( "Encountered: <UNEXPECTED_CHAR> \"b \" at line 0, column 0\nWas expecting: <EOF>",142 assertEquals(String.format("Encountered: <UNEXPECTED_CHAR> \"b \" at line 0, column 0%nWas expecting: <EOF>"), 143 143 checkOpeningHourSyntax(key, "badtext").get(0).getDescription().trim()); 144 144 assertThat(checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m"), hasSize(1)); 145 assertEquals( "Encountered: <UNEXPECTED_CHAR> \"p \" at line 1, column 2\nWas expecting: <EOF>",145 assertEquals(String.format("Encountered: <UNEXPECTED_CHAR> \"p \" at line 1, column 2%nWas expecting: <EOF>"), 146 146 checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m").get(0).getDescription()); 147 147 }
Note:
See TracChangeset
for help on using the changeset viewer.