Changeset 7073 in josm for trunk


Ignore:
Timestamp:
2014-05-07T23:21:47+02:00 (6 years ago)
Author:
bastiK
Message:

see #9691 - really fix broken MapCSSTagChecker unit test

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r7013 r7073  
    5555 * Dataset is threadsafe - accessing Dataset simultaneously from different threads should never
    5656 * lead to data corruption or ConccurentModificationException. However when for example one thread
    57  * removes primitive and other thread try to add another primitive reffering to the removed primitive,
     57 * removes primitive and other thread try to add another primitive referring to the removed primitive,
    5858 * DataIntegrityException will occur.
    5959 *
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r7069 r7073  
    4848import org.openstreetmap.josm.io.UTFInputStreamReader;
    4949import org.openstreetmap.josm.tools.CheckParameterUtil;
    50 import org.openstreetmap.josm.tools.MultiMap;
    5150import org.openstreetmap.josm.tools.Predicate;
    5251import org.openstreetmap.josm.tools.Utils;
     
    192191            removeMetaRules(source);
    193192            // group rules with common declaration block
    194             MultiMap<MapCSSRule.Declaration, MapCSSRule> rules = new MultiMap<>();
     193            Map<Declaration, List<Selector>> g = new LinkedHashMap<>();
    195194            for (MapCSSRule rule : source.rules) {
    196                 rules.put(rule.declaration, rule);
     195                if (!g.containsKey(rule.declaration)) {
     196                    List<Selector> sels = new ArrayList<>();
     197                    sels.add(rule.selector);
     198                    g.put(rule.declaration, sels);
     199                } else {
     200                    g.get(rule.declaration).add(rule.selector);
     201                }
    197202            }
    198203            List<TagCheck> result = new ArrayList<>();
    199             for (Collection<MapCSSRule> rulesCommonDecl : rules.values()) {
    200                 List<Selector> selectors = new ArrayList<>();
    201                 for (MapCSSRule rule : rulesCommonDecl) {
    202                     selectors.add(rule.selector);
    203                 }
    204                 if (!rulesCommonDecl.isEmpty()) {
    205                     result.add(TagCheck.ofMapCSSRule(
    206                             new GroupedMapCSSRule(selectors, rulesCommonDecl.iterator().next().declaration)));
    207                 }
     204            for (Map.Entry<Declaration, List<Selector>> map : g.entrySet()) {
     205                result.add(TagCheck.ofMapCSSRule(
     206                        new GroupedMapCSSRule(map.getValue(), map.getKey())));
    208207            }
    209208            return result;
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    r7068 r7073  
    6464        n2.put("natural", "wood");
    6565        assertFalse(check.evaluate(n2));
    66         assertThat(MapCSSTagChecker.TagCheck.insertArguments(check.rule.selector, "The key is {0.key} and the value is {0.value}"),
     66        assertThat(MapCSSTagChecker.TagCheck.insertArguments(check.rule.selectors.get(0), "The key is {0.key} and the value is {0.value}"),
    6767                is("The key is natural and the value is marsh"));
    6868    }
     
    8888                if (isError != i.getValue()) {
    8989                    final String error = MessageFormat.format("Expecting test ''{0}'' (i.e., {1}) to {2} {3} (i.e., {4})",
    90                             check.getMessage(p), check.rule.selector, i.getValue() ? "match" : "not match", i.getKey(), p.getKeys());
     90                            check.getMessage(p), check.rule.selectors, i.getValue() ? "match" : "not match", i.getKey(), p.getKeys());
    9191                    System.err.println(error);
    9292                    assertionErrors.add(error);
Note: See TracChangeset for help on using the changeset viewer.