Ignore:
Timestamp:
2014-05-09T04:49:54+02:00 (12 years ago)
Author:
Don-vip
Message:

fixes for unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyConditionTest.groovy

    r7068 r7081  
    55
    66import org.junit.*
    7 import org.openstreetmap.josm.JOSMFixture;
     7import org.openstreetmap.josm.JOSMFixture
    88import org.openstreetmap.josm.data.coor.LatLon
    99import org.openstreetmap.josm.data.osm.DataSet
     
    1717
    1818    def shouldFail = new GroovyTestCase().&shouldFail
    19    
     19
    2020    def DataSet ds;
    21    
     21
    2222    @BeforeClass
    2323    public static void createJOSMFixture(){
    2424        JOSMFixture.createUnitTestFixture().init()
    2525    }
    26    
     26
    2727    @Before
    2828    public void setUp() {
    2929        ds = new DataSet()
    3030    }
    31    
     31
    3232    def relation(id) {
    3333        def r = new Relation(id,1)
     
    3535        return r
    3636    }
    37    
     37
    3838    def node(id) {
    3939        def n = new Node(id,1)
     
    4242        return n
    4343    }
    44    
     44
    4545    @Test
    4646    public void create() {
    47        
     47
    4848        // ["a label"]
    49         Condition c = Condition.create("a key", false, false, Context.PRIMITIVE)
     49        Condition c = Condition.createKeyCondition("a key", false, Condition.KeyMatchType.FALSE, Context.PRIMITIVE)
    5050        // ["a label"?]
    51         c = Condition.create("a key", false, true, Context.PRIMITIVE)
     51        c = Condition.createKeyCondition("a key", false, Condition.KeyMatchType.TRUE, Context.PRIMITIVE)
    5252        // [!"a label"]
    53         c = Condition.create("a key", true, false, Context.PRIMITIVE)
     53        c = Condition.createKeyCondition("a key", true, Condition.KeyMatchType.FALSE, Context.PRIMITIVE)
    5454        // [!"a label"?]
    55         c = Condition.create("a key", true, true, Context.PRIMITIVE)
    56        
     55        c = Condition.createKeyCondition("a key", true, Condition.KeyMatchType.TRUE, Context.PRIMITIVE)
     56
    5757        // ["a label"]
    58         c = Condition.create("a key", false, false, Context.LINK)
     58        c = Condition.createKeyCondition("a key", false, null, Context.LINK)
    5959        // [!"a label"]
    60         c = Condition.create("a key", true, false, Context.LINK)
    61        
     60        c = Condition.createKeyCondition("a key", true, null, Context.LINK)
     61
    6262        shouldFail(MapCSSException) {
    6363            // ["a label"?]
    64            c = Condition.create("a key", false, true, Context.LINK)
     64           c = Condition.createKeyCondition("a key", false, Condition.KeyMatchType.TRUE, Context.LINK)
    6565        }
    66        
     66
    6767        shouldFail(MapCSSException) {
    6868            // [!"a label"?]
    69             c = Condition.create("a key", true, true, Context.LINK)
     69            c = Condition.createKeyCondition("a key", true, Condition.KeyMatchType.TRUE, Context.LINK)
    7070        }
    7171    }
    72    
     72
    7373    @Test
    7474    public void applies_1() {
     
    7676        Node n = node(1)
    7777        r.addMember(new RelationMember("my_role", n))
    78        
     78
    7979        Environment e = new Environment().withPrimitive(n).withParent(r).withIndex(0).withLinkContext()
    80        
    81         Condition cond = Condition.create("my_role", false, false, Context.LINK)
    82         assert cond.applies(e)       
    83        
    84         cond = Condition.create("my_role", true, false, Context.LINK)
     80
     81        Condition cond = Condition.createKeyCondition("my_role", false, null, Context.LINK)
     82        assert cond.applies(e)
     83
     84        cond = Condition.createKeyCondition("my_role", true, null, Context.LINK)
    8585        assert !cond.applies(e)
    8686    }
    87    
     87
    8888    @Test
    8989    public void applies_2() {
     
    9191        Node n = node(1)
    9292        r.addMember(new RelationMember("my_role", n))
    93        
     93
    9494        Environment e = new Environment().withPrimitive(n).withParent(r).withIndex(0).withLinkContext()
    95        
    96         Condition cond = Condition.create("another_role", false, false, Context.LINK)
     95
     96        Condition cond = Condition.createKeyCondition("another_role", false, null, Context.LINK)
    9797        assert !cond.applies(e)
    98        
    99         cond = Condition.create("another_role", true, false, Context.LINK)
     98
     99        cond = Condition.createKeyCondition("another_role", true, null, Context.LINK)
    100100        assert cond.applies(e)
    101     }   
     101    }
    102102}
    103 
Note: See TracChangeset for help on using the changeset viewer.