Search in sources :

Example 81 with Element

use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.

the class AddAccessActionTest method testNoSub.

/**
 * If there are no substitutions, then the exact same string is
 * used.
 */
@Test
public void testNoSub() {
    String value = "fred";
    Action act = new AddAccessAction(value, false);
    Element el = stdElement();
    act.perform(el);
    for (String accessTag : ACCESS_TAGS.keySet()) {
        assertSame("a not changed", value, el.getTag(accessTag));
    }
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Test(org.junit.Test)

Example 82 with Element

use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.

the class AddAccessActionTest method testBareSubst.

/**
 * Simple test, substituting the whole string.
 */
@Test
public void testBareSubst() {
    Action act = new AddAccessAction("${access}", false);
    Element el = stdElement();
    act.perform(el);
    for (String accessTag : ACCESS_TAGS.keySet()) {
        assertEquals("subst access", ACCESSVAL, el.getTag(accessTag));
    }
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Test(org.junit.Test)

Example 83 with Element

use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.

the class AddAccessActionTest method testNoOverwriteValue.

/**
 * If modify is set to false each single access tag should only be set
 * if it is not already set.
 */
@Test
public void testNoOverwriteValue() {
    Action act = new AddAccessAction("${access}", false);
    Element el = stdElement();
    el.addTag("mkgmap:bicycle", "yes");
    act.perform(el);
    for (String accessTag : ACCESS_TAGS.keySet()) {
        if ("mkgmap:bicycle".equals(accessTag))
            assertEquals("no overwrite", "yes", el.getTag(accessTag));
        else
            assertEquals("no overwrite", "no", el.getTag(accessTag));
    }
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Test(org.junit.Test)

Example 84 with Element

use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.

the class AddAccessActionTest method testSecondAlternativeMatches.

/**
 * Several alternatives and the second one matches.
 */
@Test
public void testSecondAlternativeMatches() {
    AddAccessAction act = new AddAccessAction("${hello}", false);
    act.add("${access}");
    act.add("${world}");
    Element el = stdElement();
    el.addTag("world", "world");
    act.perform(el);
    for (String accessTag : ACCESS_TAGS.keySet()) assertEquals(accessTag + " is set", ACCESSVAL, el.getTag(accessTag));
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Test(org.junit.Test)

Example 85 with Element

use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.

the class AddTagActionTest method testManySubs.

/**
 * Complex string with more than one substitution.
 */
@Test
public void testManySubs() {
    Action act = new AddTagAction("a", "Road ${ref}, name ${name:cy}", false);
    Element el = stdElement();
    act.perform(el);
    assertEquals("many substitutions", "Road " + REFVAL + ", name " + PLACENAME, el.getTag("a"));
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Test(org.junit.Test)

Aggregations

Element (uk.me.parabola.mkgmap.reader.osm.Element)94 Test (org.junit.Test)75 Way (uk.me.parabola.mkgmap.reader.osm.Way)48 GType (uk.me.parabola.mkgmap.reader.osm.GType)25 TestUtils.makeRuleSet (func.lib.TestUtils.makeRuleSet)23 Action (uk.me.parabola.mkgmap.osmstyle.actions.Action)15 Rule (uk.me.parabola.mkgmap.reader.osm.Rule)8 ArrayList (java.util.ArrayList)7 Node (uk.me.parabola.mkgmap.reader.osm.Node)7 Relation (uk.me.parabola.mkgmap.reader.osm.Relation)7 Coord (uk.me.parabola.imgfmt.app.Coord)5 StringStyleFileLoader (func.lib.StringStyleFileLoader)4 Map (java.util.Map)4 GeneralRelation (uk.me.parabola.mkgmap.reader.osm.GeneralRelation)4 TypeResult (uk.me.parabola.mkgmap.reader.osm.TypeResult)4 HashMap (java.util.HashMap)3 IdentityHashMap (java.util.IdentityHashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Area (uk.me.parabola.imgfmt.app.Area)2