Changeset 18761 in josm for trunk/src


Ignore:
Timestamp:
2023-06-14T22:27:42+02:00 (18 months ago)
Author:
taylor.smock
Message:

Fix borked tests (see r18757)

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SplitMode.java

    r18760 r18761  
    109109    }
    110110
    111 
    112 
    113111    @Override
    114112    public void mousePressed(MouseEvent e) {
     
    229227    }
    230228
    231 
    232 
    233229    @Override
    234230    public String getModeHelpText() {
     
    442438    }
    443439
    444 
    445 
    446440    /**
    447441     * Split a specified {@link Way} at the given nodes
     
    464458         * @param selection (Optional, can be null) Selection which should be updated
    465459         */
    466         public SplitWayActionConcrete(Way splitWay, List<Node> splitNodes, List<OsmPrimitive> selection) {
     460        SplitWayActionConcrete(Way splitWay, List<Node> splitNodes, List<OsmPrimitive> selection) {
    467461            super(tr("Split way {0}", DefaultNameFormatter.getInstance().format(splitWay)),
    468462                    ImageProvider.get(splitWay.getType()));
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerAsserts.java

    r18757 r18761  
    6767            final boolean isError = pErrors.stream().anyMatch(e -> e.getTester() instanceof MapCSSTagChecker.MapCSSTagCheckerAndRule
    6868                    && ((MapCSSTagChecker.MapCSSTagCheckerAndRule) e.getTester()).rule.equals(check.rule));
    69             if (isError != i.getValue()) {
     69            final boolean iValue = Boolean.TRUE.equals(i.getValue());
     70            if (isError != iValue) {
    7071                assertionConsumer.accept(MessageFormat.format("Expecting test ''{0}'' (i.e., {1}) to {2} {3} (i.e., {4})",
    71                         check.getMessage(p), check.rule.selectors, i.getValue() ? "match" : "not match", i.getKey(), p.getKeys()));
     72                        check.getMessage(null, p), check.rule.selectors, iValue ? "match" : "not match", i.getKey(), p.getKeys()));
    7273            }
    7374            if (isError) {
     
    7677                if (fix != null && fix.executeCommand() && !MapCSSTagChecker.getErrorsForPrimitive(p, true, checksToRun).isEmpty()) {
    7778                    assertionConsumer.accept(MessageFormat.format("Autofix does not work for test ''{0}'' (i.e., {1}). Failing test: {2}",
    78                             check.getMessage(p), check.rule.selectors, i.getKey()));
     79                            check.getMessage(null, p), check.rule.selectors, i.getKey()));
    7980                }
    8081            }
     
    8485    }
    8586
     87    /**
     88     * Clear previous checks (remove from memory)
     89     */
    8690    public static void clear() {
    8791        previousChecks.clear();
     
    106110        return check.rule.selectors.stream()
    107111                .filter(s -> s instanceof Selector.GeneralSelector)
    108                 .flatMap(s -> ((Selector.GeneralSelector) s).getConditions().stream())
     112                .flatMap(s -> s.getConditions().stream())
    109113                .filter(c -> c instanceof ConditionFactory.ExpressionCondition)
    110114                .map(c -> ((ConditionFactory.ExpressionCondition) c).getExpression())
     
    112116                .map(c -> (ExpressionFactory.IsInsideFunction) c)
    113117                .map(ExpressionFactory.IsInsideFunction::getArg)
    114                 .filter(e -> e instanceof LiteralExpression)
     118                .filter(LiteralExpression.class::isInstance)
    115119                .map(e -> ((LiteralExpression) e).getLiteral())
    116                 .filter(l -> l instanceof String)
     120                .filter(String.class::isInstance)
    117121                .map(l -> ((String) l).split(",", -1)[0])
    118122                .findFirst();
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerRule.java

    r18757 r18761  
    267267     * Constructs a (localized) message for this deprecation check.
    268268     *
     269     * @param selector The selector to use
    269270     * @param p OSM primitive
    270271     * @return a message
    271272     */
    272     String getMessage(OsmPrimitive p) {
     273    String getMessage(Selector selector, OsmPrimitive p) {
    273274        if (errors.isEmpty()) {
    274275            // Return something to avoid NPEs
     
    276277        } else {
    277278            final Object val = errors.keySet().iterator().next().val;
     279            selector = selector == null ? whichSelectorMatchesPrimitive(p) : selector;
    278280            return String.valueOf(
    279281                    val instanceof Expression
    280                             ? ((Expression) val).evaluate(new Environment(p).withSelector(p == null ? null : whichSelectorMatchesPrimitive(p)))
     282                            ? ((Expression) val).evaluate(new Environment(p).withSelector(selector))
    281283                            : val
    282284            );
     
    287289     * Constructs a (localized) description for this deprecation check.
    288290     *
     291     * @param selector The selector to use
    289292     * @param p OSM primitive
    290293     * @return a description (possibly with alternative suggestions)
    291294     * @see #getDescriptionForMatchingSelector
    292295     */
    293     String getDescription(OsmPrimitive p) {
     296    String getDescription(Selector selector, OsmPrimitive p) {
    294297        if (alternatives.isEmpty()) {
    295             return getMessage(p);
     298            return getMessage(selector, p);
    296299        } else {
    297300            /* I18N: {0} is the test error message and {1} is an alternative */
    298             return tr("{0}, use {1} instead", getMessage(p), String.join(tr(" or "), alternatives));
     301            return tr("{0}, use {1} instead", getMessage(selector, p), String.join(tr(" or "), alternatives));
    299302        }
    300303    }
     
    309312     */
    310313    String getDescriptionForMatchingSelector(OsmPrimitive p, Selector matchingSelector) {
    311         return insertArguments(matchingSelector, getDescription(p), p);
     314        return insertArguments(matchingSelector, getDescription(matchingSelector, p), p);
    312315    }
    313316
     
    318321    @Override
    319322    public String toString() {
    320         return getDescription(null);
     323        return getDescription(null, null);
    321324    }
    322325
Note: See TracChangeset for help on using the changeset viewer.