Changeset 17591 in josm


Ignore:
Timestamp:
2021-03-19T19:52:15+01:00 (4 years ago)
Author:
simon04
Message:

see #20626 - OpeningHoursParser: report multiple parse exceptions

Location:
trunk
Files:
2 edited

Legend:

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

    r16832 r17591  
    1111import java.util.Locale;
    1212import java.util.Objects;
     13import java.util.stream.Collectors;
    1314
    1415import javax.swing.JCheckBox;
    1516import javax.swing.JPanel;
    1617
     18import ch.poole.openinghoursparser.OpeningHoursParseException;
    1719import ch.poole.openinghoursparser.OpeningHoursParser;
    18 import ch.poole.openinghoursparser.ParseException;
    1920import ch.poole.openinghoursparser.Rule;
    2021import ch.poole.openinghoursparser.Util;
     
    106107                new OpeningHoursParser(new StringReader(value)).rules(true);
    107108            }
    108         } catch (ParseException e) {
    109             return Collections.singletonList(createTestError(Severity.WARNING, e.getMessage(), key, value, prettifiedValue, p));
     109        } catch (OpeningHoursParseException e) {
     110            String message = e.getExceptions().stream()
     111                    .map(OpeningHoursParseException::getMessage)
     112                    .distinct()
     113                    .collect(Collectors.joining("; "));
     114            return Collections.singletonList(createTestError(Severity.WARNING, message, key, value, prettifiedValue, p));
    110115        }
    111116
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java

    r17590 r17591  
    9090                checkOpeningHourSyntax(key, value, Locale.ENGLISH).get(0).getDescription());
    9191        value = "Mon-Thu 12-18";
    92         assertEquals("Wochentag mit 3 Buchstaben in Zeile 1, Spalte 4",
     92        assertEquals("Wochentag mit 3 Buchstaben in Zeile 1, Spalte 4; Wochentag mit 3 Buchstaben in Zeile 1, Spalte 9; Stunden ohne Minuten",
    9393                checkOpeningHourSyntax(key, value, Locale.GERMAN).get(0).getDescription());
    94         assertEquals("Three character weekday at line 1, column 4",
     94        assertEquals("Three character weekday at line 1, column 4; Three character weekday at line 1, column 9; Hours without minutes",
    9595                checkOpeningHourSyntax(key, value, Locale.ENGLISH).get(0).getDescription());
    9696    }
     
    118118        assertThat(errors, hasSize(1));
    119119        assertFixEquals("Sa-Su 10:00-20:00", errors.get(0));
    120         assertEquals("Invalid minutes at line 1, column 12", errors.get(0).getDescription());
     120        assertEquals("Invalid minutes at line 1, column 12; Invalid minutes at line 1, column 17", errors.get(0).getDescription());
    121121        assertEquals(Severity.WARNING, errors.get(0).getSeverity());
    122122    }
     
    145145                checkOpeningHourSyntax(key, "badtext").get(0).getDescription().trim());
    146146        assertThat(checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m"), hasSize(1));
    147         assertEquals(String.format("Encountered:  <UNEXPECTED_CHAR> \"p \" at line 1, column 3%nWas expecting: <EOF>"),
     147        assertEquals(String.format("Encountered:  <UNEXPECTED_CHAR> \"p \" at line 1, column 3%nWas expecting: <EOF>; " +
     148                        "Encountered:  <UNEXPECTED_CHAR> \"p \" at line 1, column 13%n" +
     149                        "Was expecting: <EOF>"),
    148150                checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m").get(0).getDescription());
    149151    }
Note: See TracChangeset for help on using the changeset viewer.