Changeset 16178 in josm for trunk/src/org


Ignore:
Timestamp:
2020-03-20T21:06:06+01:00 (5 years ago)
Author:
Don-vip
Message:

fix #18956 - allow TestError to be built with an empty list of primitives + make OpeningHourTestTest work on Windows

Location:
trunk/src/org/openstreetmap/josm/data/validation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/TestError.java

    r15939 r16178  
    220220         *
    221221         * @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.
    223223         */
    224224        public TestError build() {
    225225            CheckParameterUtil.ensureParameterNotNull(message, "message not set");
    226226            CheckParameterUtil.ensureParameterNotNull(primitives, "primitives not set");
    227             CheckParameterUtil.ensureThat(!primitives.isEmpty(), "primitives is empty");
    228227            if (this.highlighted == null) {
    229228                this.highlighted = Collections.emptySet();
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java

    r16154 r16178  
    4646     * @param message The error message
    4747     * @param key The incriminated key, used for display.
     48     * @param value The incriminated value, used for comparison with prettified value.
    4849     * @param prettifiedValue The prettified value
    4950     * @param p The incriminated OSM primitive.
    5051     * @return The real test error given to JOSM validator. Can be fixable or not if a prettified values has been determined.
    5152     */
    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) {
    5354        final TestError.Builder error = TestError.builder(this, severity, 2901)
    5455                .message(tr("Opening hours syntax"), message) // todo obtain English message for ignore functionality
    55                 .primitives(p);
    56         if (prettifiedValue == null || prettifiedValue.equals(p.get(key))) {
     56                .primitives(p != null ? new OsmPrimitive[] {p} : new OsmPrimitive[] {});
     57        if (p == null || prettifiedValue == null || prettifiedValue.equals(value)) {
    5758            return error.build();
    5859        } else {
     
    9697            }
    9798        } 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));
    99100        }
    100101
    101         if (!includeOtherSeverityChecks() || Objects.equals(value, prettifiedValue) || p == null) {
     102        if (!includeOtherSeverityChecks() || Objects.equals(value, prettifiedValue)) {
    102103            return Collections.emptyList();
    103104        } else {
    104105            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));
    106107        }
    107108    }
Note: See TracChangeset for help on using the changeset viewer.