Ignore:
Timestamp:
2015-10-01T21:06:10+02:00 (6 years ago)
Author:
simon04
Message:

see #11916 - Refactoring of SearchAction/SearchCompiler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.groovy

    r7938 r8811  
    55import org.openstreetmap.josm.JOSMFixture
    66import org.openstreetmap.josm.TestUtils
     7import org.openstreetmap.josm.actions.search.SearchAction
    78import org.openstreetmap.josm.actions.search.SearchCompiler
    89import org.openstreetmap.josm.data.osm.Relation
     
    2627    }
    2728
     29    static def regexpSearch(String search) {
     30        def setting = new SearchAction.SearchSetting()
     31        setting.text = search
     32        setting.regexSearch = true
     33        return setting
     34    }
     35
    2836    @Test
    2937    public void testCreate1() {
     
    3745    public void testCreate2() {
    3846        def ds = OsmReader.parseDataSet(new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null);
    39         def ways = Utils.filter(ds.getWays(), SearchCompiler.compile("ref=1 OR ref:1.1.", false, false))
     47        def ways = Utils.filter(ds.getWays(), SearchCompiler.compile("ref=1 OR ref:1.1."))
    4048        def mp = CreateMultipolygonAction.createMultipolygonCommand(ways as Collection<Way>, null)
    4149        assert getRefToRoleMap(mp.b).toString() == "[1:outer, 1.1.1:inner, 1.1.2:inner]"
     
    4553    public void testUpdate1() {
    4654        def ds = OsmReader.parseDataSet(new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null);
    47         def ways = Utils.filter(ds.getWays(), SearchCompiler.compile("ref=\".*1\$\"", false, true))
     55        def ways = Utils.filter(ds.getWays(), SearchCompiler.compile(regexpSearch("ref=\".*1\$\"")))
    4856        def mp = CreateMultipolygonAction.createMultipolygonCommand(ways as Collection<Way>, null)
    4957        assert mp.b.getMembersCount() == 3
    5058        assert getRefToRoleMap(mp.b).toString() == "[1:outer, 1.1:inner, 1.1.1:outer]"
    51         def ways2 = Utils.filter(ds.getWays(), SearchCompiler.compile("ref=1.2", false, true))
     59        def ways2 = Utils.filter(ds.getWays(), SearchCompiler.compile(regexpSearch("ref=1.2")))
    5260        def mp2 = CreateMultipolygonAction.createMultipolygonCommand(ways2 as Collection<Way>, mp.b)
    5361        assert mp2.b.getMembersCount() == 4
     
    5866    public void testUpdate2() {
    5967        def ds = OsmReader.parseDataSet(new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null);
    60         def ways = Utils.filter(ds.getWays(), SearchCompiler.compile("ref=1 OR ref:1.1.1", false, false))
     68        def ways = Utils.filter(ds.getWays(), SearchCompiler.compile("ref=1 OR ref:1.1.1"))
    6169        def mp = CreateMultipolygonAction.createMultipolygonCommand(ways as Collection<Way>, null)
    6270        assert getRefToRoleMap(mp.b).toString() == "[1:outer, 1.1.1:inner]"
    63         def ways2 = Utils.filter(ds.getWays(), SearchCompiler.compile("ref=1.1 OR ref=1.2 OR ref=1.1.2", false, true))
     71        def ways2 = Utils.filter(ds.getWays(), SearchCompiler.compile(regexpSearch("ref=1.1 OR ref=1.2 OR ref=1.1.2")))
    6472        def mp2 = CreateMultipolygonAction.createMultipolygonCommand(ways2 as Collection<Way>, mp.b)
    6573        assert getRefToRoleMap(mp2.b).toString() == "[1:outer, 1.1:inner, 1.1.1:outer, 1.1.2:outer, 1.2:inner]"
Note: See TracChangeset for help on using the changeset viewer.