Changeset 7081 in josm for trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyValueConditionTest.groovy
- Timestamp:
- 2014-05-09T04:49:54+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyValueConditionTest.groovy
r7068 r7081 5 5 6 6 import org.junit.* 7 import org.openstreetmap.josm.JOSMFixture ;7 import org.openstreetmap.josm.JOSMFixture 8 8 import org.openstreetmap.josm.data.coor.LatLon 9 9 import org.openstreetmap.josm.data.osm.DataSet … … 19 19 20 20 def shouldFail = new GroovyTestCase().&shouldFail 21 21 22 22 def DataSet ds; 23 23 24 24 @BeforeClass 25 25 public static void createJOSMFixture(){ 26 26 JOSMFixture.createUnitTestFixture().init() 27 27 } 28 28 29 29 @Before 30 30 public void setUp() { 31 31 ds = new DataSet() 32 32 } 33 33 34 34 def relation(id) { 35 35 def r = new Relation(id,1) … … 37 37 return r 38 38 } 39 39 40 40 def node(id) { 41 41 def n = new Node(id,1) … … 44 44 return n 45 45 } 46 46 47 47 @Test 48 48 public void create() { 49 Condition c = Condition.create ("a key", "a value", Op.EQ, Context.PRIMITIVE)50 51 c = Condition.create ("role", "a role", Op.EQ, Context.LINK)52 c = Condition.create ("RoLe", "a role", Op.EQ, Context.LINK)53 49 Condition c = Condition.createKeyValueCondition("a key", "a value", Op.EQ, Context.PRIMITIVE, false) 50 51 c = Condition.createKeyValueCondition("role", "a role", Op.EQ, Context.LINK, false) 52 c = Condition.createKeyValueCondition("RoLe", "a role", Op.EQ, Context.LINK, false) 53 54 54 shouldFail(MapCSSException) { 55 c = Condition.create ("an arbitry tag", "a role", Op.EQ, Context.LINK)55 c = Condition.createKeyValueCondition("an arbitry tag", "a role", Op.EQ, Context.LINK, false) 56 56 } 57 57 } 58 58 59 59 @Test 60 60 public void applies_1() { … … 62 62 Node n = node(1) 63 63 r.addMember(new RelationMember("my_role", n)) 64 64 65 65 Environment e = new Environment().withPrimitive(n).withParent(r).withLinkContext().withIndex(0) 66 66 67 67 Condition cond = new Condition.RoleCondition("my_role", Op.EQ) 68 assert cond.applies(e) 69 68 assert cond.applies(e) 69 70 70 cond = new Condition.RoleCondition("another_role", Op.EQ) 71 71 assert !cond.applies(e) 72 72 } 73 73 74 74 @Test 75 75 public void applies_2() { … … 77 77 Node n = node(1) 78 78 r.addMember(new RelationMember("my_role", n)) 79 79 80 80 Environment e = new Environment().withPrimitive(n).withParent(r).withIndex(0).withLinkContext() 81 82 Condition cond = Condition.create ("role", "my_role", Op.NEQ, Context.LINK)81 82 Condition cond = Condition.createKeyValueCondition("role", "my_role", Op.NEQ, Context.LINK, false) 83 83 assert !cond.applies(e) 84 85 cond = Condition.create ("role", "another_role", Op.NEQ, Context.LINK)84 85 cond = Condition.createKeyValueCondition("role", "another_role", Op.NEQ, Context.LINK, false) 86 86 assert cond.applies(e) 87 87 } 88 89 90 91 88 } 92
Note: See TracChangeset
for help on using the changeset viewer.