Changeset 13296 in josm for trunk


Ignore:
Timestamp:
2018-01-07T23:36:55+01:00 (7 years ago)
Author:
Don-vip
Message:

see #15582 - more public APIs for opening_hours parsing

File:
1 edited

Legend:

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

    r13268 r13296  
    232232            String prettifiedValue = null;
    233233            try {
    234                 prettifiedValue = (String) ((Invocable) ENGINE).invokeMethod(r, "prettifyValue");
     234                prettifiedValue = getOpeningHoursPrettifiedValues(r);
    235235            } catch (ScriptException | NoSuchMethodException e) {
    236236                Logging.warn(e);
    237237            }
    238             for (final Object i : getList(((Invocable) ENGINE).invokeMethod(r, "getErrors"))) {
     238            for (final Object i : getOpeningHoursErrors(r)) {
    239239                errors.add(new OpeningHoursTestError(getErrorMessage(key, i), Severity.ERROR, prettifiedValue));
    240240            }
    241             for (final Object i : getList(((Invocable) ENGINE).invokeMethod(r, "getWarnings"))) {
     241            for (final Object i : getOpeningHoursWarnings(r)) {
    242242                errors.add(new OpeningHoursTestError(getErrorMessage(key, i), Severity.WARNING, prettifiedValue));
    243243            }
     
    249249        }
    250250        return errors;
     251    }
     252
     253    /**
     254     * Returns the prettified value returned by the opening hours parser.
     255     * @param r result of {@link #parse}
     256     * @return the prettified value returned by the opening hours parser
     257     * @throws NoSuchMethodException if method "prettifyValue" or matching argument types cannot be found
     258     * @throws ScriptException if an error occurs during invocation of the JavaScript method
     259     * @since 13296
     260     */
     261    public final String getOpeningHoursPrettifiedValues(Object r) throws NoSuchMethodException, ScriptException {
     262        return (String) ((Invocable) ENGINE).invokeMethod(r, "prettifyValue");
     263    }
     264
     265    /**
     266     * Returns the list of errors returned by the opening hours parser.
     267     * @param r result of {@link #parse}
     268     * @return the list of errors returned by the opening hours parser
     269     * @throws NoSuchMethodException if method "getErrors" or matching argument types cannot be found
     270     * @throws ScriptException if an error occurs during invocation of the JavaScript method
     271     * @since 13296
     272     */
     273    public final List<Object> getOpeningHoursErrors(Object r) throws NoSuchMethodException, ScriptException {
     274        return getList(((Invocable) ENGINE).invokeMethod(r, "getErrors"));
     275    }
     276
     277    /**
     278     * Returns the list of warnings returned by the opening hours parser.
     279     * @param r result of {@link #parse}
     280     * @return the list of warnings returned by the opening hours parser
     281     * @throws NoSuchMethodException if method "getWarnings" or matching argument types cannot be found
     282     * @throws ScriptException if an error occurs during invocation of the JavaScript method
     283     * @since 13296
     284     */
     285    public final List<Object> getOpeningHoursWarnings(Object r) throws NoSuchMethodException, ScriptException {
     286        return getList(((Invocable) ENGINE).invokeMethod(r, "getWarnings"));
    251287    }
    252288
Note: See TracChangeset for help on using the changeset viewer.