Changeset 8265 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2015-04-25T18:33:40+02:00 (10 years ago)
Author:
simon04
Message:

fix #10913 - MapCSS validator: retain sequence of fixing commands

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    r7937 r8265  
    88
    99import java.io.StringReader;
     10import java.util.Iterator;
    1011import java.util.LinkedHashSet;
    1112import java.util.List;
     
    1718import org.openstreetmap.josm.Main;
    1819import org.openstreetmap.josm.command.ChangePropertyCommand;
     20import org.openstreetmap.josm.command.ChangePropertyKeyCommand;
     21import org.openstreetmap.josm.command.Command;
     22import org.openstreetmap.josm.command.PseudoCommand;
     23import org.openstreetmap.josm.command.SequenceCommand;
    1924import org.openstreetmap.josm.data.osm.Node;
    20 import org.openstreetmap.josm.data.osm.Tag;
     25import org.openstreetmap.josm.data.osm.OsmPrimitive;
     26import org.openstreetmap.josm.data.osm.OsmUtils;
    2127import org.openstreetmap.josm.data.validation.Severity;
    2228import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.TagCheck;
     
    4955        assertThat(check, notNullValue());
    5056        assertThat(check.getDescription(null), is("{0.key}=null is deprecated"));
    51         assertThat(check.change.get(0).apply(null), is(new Tag("{0.key}")));
    52         assertThat(check.change.get(1).apply(null), is(new Tag("natural", "wetland")));
    53         assertThat(check.change.get(2).apply(null), is(new Tag("wetland", "marsh")));
     57        assertThat(check.fixCommands.get(0).toString(), is("fixRemove: {0.key}"));
     58        assertThat(check.fixCommands.get(1).toString(), is("fixAdd: natural=wetland"));
     59        assertThat(check.fixCommands.get(2).toString(), is("fixAdd: wetland=marsh"));
    5460        final Node n1 = new Node();
    5561        n1.put("natural", "marsh");
     
    6571        assertThat(MapCSSTagChecker.TagCheck.insertArguments(check.rule.selectors.get(0), "The key is {0.key} and the value is {0.value}"),
    6672                is("The key is natural and the value is marsh"));
     73    }
     74
     75    @Test
     76    public void test10913() throws Exception {
     77        final OsmPrimitive p = OsmUtils.createPrimitive("way highway=tertiary construction=yes");
     78        final TagCheck check = TagCheck.readMapCSS(new StringReader("way {" +
     79                "throwError: \"error\";" +
     80                "fixChangeKey: \"highway => construction\";\n" +
     81                "fixAdd: \"highway=construction\";\n" +
     82                "}")).get(0);
     83        final Command command = check.fixPrimitive(p);
     84        assertThat(command instanceof SequenceCommand, is(true));
     85        final Iterator<PseudoCommand> it = command.getChildren().iterator();
     86        assertThat(it.next() instanceof ChangePropertyKeyCommand, is(true));
     87        assertThat(it.next() instanceof ChangePropertyCommand, is(true));
    6788    }
    6889
Note: See TracChangeset for help on using the changeset viewer.