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


Ignore:
Timestamp:
2017-08-26T00:40:19+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15182 - move SearchCompiler from actions.search to data.osm.search

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
1 added
7 edited
2 moved

Legend:

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

    r11104 r12656  
    1313import org.openstreetmap.josm.TestUtils;
    1414import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;
    15 import org.openstreetmap.josm.actions.search.SearchCompiler;
    16 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    1715import org.openstreetmap.josm.command.SequenceCommand;
    1816import org.openstreetmap.josm.data.osm.DataSet;
     
    2018import org.openstreetmap.josm.data.osm.RelationMember;
    2119import org.openstreetmap.josm.data.osm.Way;
     20import org.openstreetmap.josm.data.osm.search.SearchParseError;
     21import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    2222import org.openstreetmap.josm.io.OsmReader;
    2323import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    5656    @SuppressWarnings("unchecked")
    5757    private static Pair<SequenceCommand, Relation> createMultipolygonCommand(Collection<Way> ways, String pattern, Relation r)
    58             throws ParseError {
     58            throws SearchParseError {
    5959        return CreateMultipolygonAction.createMultipolygonCommand(
    6060            (Collection<Way>) (Collection<?>) SubclassFilteredCollection.filter(ways, SearchCompiler.compile(regexpSearch(pattern))), r);
  • trunk/test/unit/org/openstreetmap/josm/actions/OrthogonalizeActionTest.java

    r12636 r12656  
    1212import org.openstreetmap.josm.TestUtils;
    1313import org.openstreetmap.josm.actions.OrthogonalizeAction.Direction;
    14 import org.openstreetmap.josm.actions.search.SearchCompiler;
    1514import org.openstreetmap.josm.data.coor.LatLon;
    1615import org.openstreetmap.josm.data.osm.DataSet;
    1716import org.openstreetmap.josm.data.osm.Node;
    1817import org.openstreetmap.josm.data.osm.Way;
     18import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    1919import org.openstreetmap.josm.gui.MainApplication;
    2020import org.openstreetmap.josm.gui.layer.OsmDataLayer;
  • trunk/test/unit/org/openstreetmap/josm/actions/search/SearchActionTest.java

    r11978 r12656  
    66import org.openstreetmap.josm.TestUtils;
    77import org.openstreetmap.josm.actions.search.SearchAction.SearchMode;
     8import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    89import org.openstreetmap.josm.testutils.JOSMTestRules;
    910
  • trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java

    r11973 r12656  
    1717import org.junit.Test;
    1818import org.openstreetmap.josm.actions.search.SearchAction.SearchMode;
    19 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    2019import org.openstreetmap.josm.data.coor.LatLon;
    2120import org.openstreetmap.josm.data.osm.Filter.FilterPreferenceEntry;
     21import org.openstreetmap.josm.data.osm.search.SearchParseError;
    2222import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2323import org.openstreetmap.josm.io.OsmReader;
     
    4141
    4242    @Test
    43     public void testBasic() throws ParseError {
     43    public void testBasic() throws SearchParseError {
    4444        DataSet ds = new DataSet();
    4545        Node n1 = new Node(LatLon.ZERO);
  • trunk/test/unit/org/openstreetmap/josm/data/osm/search/PushbackTokenizerTest.java

    r12651 r12656  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.actions.search;
     2package org.openstreetmap.josm.data.osm.search;
    33
    44import org.junit.Rule;
    55import org.junit.Test;
    66import org.openstreetmap.josm.TestUtils;
    7 import org.openstreetmap.josm.actions.search.PushbackTokenizer.Token;
     7import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Token;
    88import org.openstreetmap.josm.testutils.JOSMTestRules;
    99
  • trunk/test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java

    r12651 r12656  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.actions.search;
     2package org.openstreetmap.josm.data.osm.search;
    33
    44import static org.junit.Assert.assertEquals;
     
    2020import org.openstreetmap.josm.TestUtils;
    2121import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;
    22 import org.openstreetmap.josm.actions.search.SearchCompiler.ExactKeyValue;
    23 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
    24 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    2522import org.openstreetmap.josm.data.coor.LatLon;
    2623import org.openstreetmap.josm.data.osm.DataSet;
     
    3532import org.openstreetmap.josm.data.osm.Way;
    3633import org.openstreetmap.josm.data.osm.WayData;
     34import org.openstreetmap.josm.data.osm.search.SearchCompiler.ExactKeyValue;
     35import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
    3736import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset;
    3837import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetMenu;
     
    6968        private final Match n;
    7069
    71         private SearchContext(String state) throws ParseError {
     70        private SearchContext(String state) throws SearchParseError {
    7271            m = SearchCompiler.compile(state);
    7372            n = SearchCompiler.compile('-' + state);
     
    107106    /**
    108107     * Search anything.
    109      * @throws ParseError if an error has been encountered while compiling
    110      */
    111     @Test
    112     public void testAny() throws ParseError {
     108     * @throws SearchParseError if an error has been encountered while compiling
     109     */
     110    @Test
     111    public void testAny() throws SearchParseError {
    113112        final SearchCompiler.Match c = SearchCompiler.compile("foo");
    114113        assertTrue(c.match(newPrimitive("foobar", "true")));
     
    120119    /**
    121120     * Search by equality key=value.
    122      * @throws ParseError if an error has been encountered while compiling
    123      */
    124     @Test
    125     public void testEquals() throws ParseError {
     121     * @throws SearchParseError if an error has been encountered while compiling
     122     */
     123    @Test
     124    public void testEquals() throws SearchParseError {
    126125        final SearchCompiler.Match c = SearchCompiler.compile("foo=bar");
    127126        assertFalse(c.match(newPrimitive("foobar", "true")));
     
    134133    /**
    135134     * Search by comparison.
    136      * @throws ParseError if an error has been encountered while compiling
    137      */
    138     @Test
    139     public void testCompare() throws ParseError {
     135     * @throws SearchParseError if an error has been encountered while compiling
     136     */
     137    @Test
     138    public void testCompare() throws SearchParseError {
    140139        final SearchCompiler.Match c1 = SearchCompiler.compile("start_date>1950");
    141140        assertTrue(c1.match(newPrimitive("start_date", "1950-01-01")));
     
    174173    /**
    175174     * Search by nth.
    176      * @throws ParseError if an error has been encountered while compiling
    177      */
    178     @Test
    179     public void testNth() throws ParseError {
     175     * @throws SearchParseError if an error has been encountered while compiling
     176     */
     177    @Test
     178    public void testNth() throws SearchParseError {
    180179        final DataSet dataSet = new DataSet();
    181180        final Way way = new Way();
     
    202201    /**
    203202     * Search by negative nth.
    204      * @throws ParseError if an error has been encountered while compiling
    205      */
    206     @Test
    207     public void testNthParseNegative() throws ParseError {
     203     * @throws SearchParseError if an error has been encountered while compiling
     204     */
     205    @Test
     206    public void testNthParseNegative() throws SearchParseError {
    208207        assertEquals("Nth{nth=-1, modulo=false}", SearchCompiler.compile("nth:-1").toString());
    209208    }
     
    211210    /**
    212211     * Search by modified status.
    213      * @throws ParseError if an error has been encountered while compiling
    214      */
    215     @Test
    216     public void testModified() throws ParseError {
     212     * @throws SearchParseError if an error has been encountered while compiling
     213     */
     214    @Test
     215    public void testModified() throws SearchParseError {
    217216        SearchContext sc = new SearchContext("modified");
    218217        // Not modified but new
     
    247246    /**
    248247     * Search by selected status.
    249      * @throws ParseError if an error has been encountered while compiling
    250      */
    251     @Test
    252     public void testSelected() throws ParseError {
     248     * @throws SearchParseError if an error has been encountered while compiling
     249     */
     250    @Test
     251    public void testSelected() throws SearchParseError {
    253252        SearchContext sc = new SearchContext("selected");
    254253        // Not selected
     
    267266    /**
    268267     * Search by incomplete status.
    269      * @throws ParseError if an error has been encountered while compiling
    270      */
    271     @Test
    272     public void testIncomplete() throws ParseError {
     268     * @throws SearchParseError if an error has been encountered while compiling
     269     */
     270    @Test
     271    public void testIncomplete() throws SearchParseError {
    273272        SearchContext sc = new SearchContext("incomplete");
    274273        // Not incomplete
     
    293292    /**
    294293     * Search by untagged status.
    295      * @throws ParseError if an error has been encountered while compiling
    296      */
    297     @Test
    298     public void testUntagged() throws ParseError {
     294     * @throws SearchParseError if an error has been encountered while compiling
     295     */
     296    @Test
     297    public void testUntagged() throws SearchParseError {
    299298        SearchContext sc = new SearchContext("untagged");
    300299        // Untagged
     
    313312    /**
    314313     * Search by closed status.
    315      * @throws ParseError if an error has been encountered while compiling
    316      */
    317     @Test
    318     public void testClosed() throws ParseError {
     314     * @throws SearchParseError if an error has been encountered while compiling
     315     */
     316    @Test
     317    public void testClosed() throws SearchParseError {
    319318        SearchContext sc = new SearchContext("closed");
    320319        // Closed
     
    332331    /**
    333332     * Search by new status.
    334      * @throws ParseError if an error has been encountered while compiling
    335      */
    336     @Test
    337     public void testNew() throws ParseError {
     333     * @throws SearchParseError if an error has been encountered while compiling
     334     */
     335    @Test
     336    public void testNew() throws SearchParseError {
    338337        SearchContext sc = new SearchContext("new");
    339338        // New
     
    352351    /**
    353352     * Search for node objects.
    354      * @throws ParseError if an error has been encountered while compiling
    355      */
    356     @Test
    357     public void testTypeNode() throws ParseError {
     353     * @throws SearchParseError if an error has been encountered while compiling
     354     */
     355    @Test
     356    public void testTypeNode() throws SearchParseError {
    358357        final SearchContext sc = new SearchContext("type:node");
    359358        for (OsmPrimitive p : new OsmPrimitive[]{sc.n1, sc.n2, sc.w1, sc.w2, sc.r1, sc.r2}) {
     
    364363    /**
    365364     * Search for way objects.
    366      * @throws ParseError if an error has been encountered while compiling
    367      */
    368     @Test
    369     public void testTypeWay() throws ParseError {
     365     * @throws SearchParseError if an error has been encountered while compiling
     366     */
     367    @Test
     368    public void testTypeWay() throws SearchParseError {
    370369        final SearchContext sc = new SearchContext("type:way");
    371370        for (OsmPrimitive p : new OsmPrimitive[]{sc.n1, sc.n2, sc.w1, sc.w2, sc.r1, sc.r2}) {
     
    376375    /**
    377376     * Search for relation objects.
    378      * @throws ParseError if an error has been encountered while compiling
    379      */
    380     @Test
    381     public void testTypeRelation() throws ParseError {
     377     * @throws SearchParseError if an error has been encountered while compiling
     378     */
     379    @Test
     380    public void testTypeRelation() throws SearchParseError {
    382381        final SearchContext sc = new SearchContext("type:relation");
    383382        for (OsmPrimitive p : new OsmPrimitive[]{sc.n1, sc.n2, sc.w1, sc.w2, sc.r1, sc.r2}) {
     
    388387    /**
    389388     * Search for users.
    390      * @throws ParseError if an error has been encountered while compiling
    391      */
    392     @Test
    393     public void testUser() throws ParseError {
     389     * @throws SearchParseError if an error has been encountered while compiling
     390     */
     391    @Test
     392    public void testUser() throws SearchParseError {
    394393        final SearchContext foobar = new SearchContext("user:foobar");
    395394        foobar.n1.setUser(User.createLocalUser("foobar"));
     
    410409            SearchCompiler.compile("foo type bar");
    411410            fail();
    412         } catch (ParseError parseError) {
     411        } catch (SearchParseError parseError) {
    413412            assertEquals("<html>Expecting <code>:</code> after <i>type</i>", parseError.getMessage());
    414413        }
     
    417416    /**
    418417     * Search for primitive timestamps.
    419      * @throws ParseError if an error has been encountered while compiling
    420      */
    421     @Test
    422     public void testTimestamp() throws ParseError {
     418     * @throws SearchParseError if an error has been encountered while compiling
     419     */
     420    @Test
     421    public void testTimestamp() throws SearchParseError {
    423422        final Match search = SearchCompiler.compile("timestamp:2010/2011");
    424423        final Node n1 = new Node();
     
    431430    /**
    432431     * Tests the implementation of the Boolean logic.
    433      * @throws ParseError if an error has been encountered while compiling
    434      */
    435     @Test
    436     public void testBooleanLogic() throws ParseError {
     432     * @throws SearchParseError if an error has been encountered while compiling
     433     */
     434    @Test
     435    public void testBooleanLogic() throws SearchParseError {
    437436        final SearchCompiler.Match c1 = SearchCompiler.compile("foo AND bar AND baz");
    438437        assertTrue(c1.match(newPrimitive("foobar", "baz")));
     
    454453    /**
    455454     * Tests {@code buildSearchStringForTag}.
    456      * @throws ParseError if an error has been encountered while compiling
    457      */
    458     @Test
    459     public void testBuildSearchStringForTag() throws ParseError {
     455     * @throws SearchParseError if an error has been encountered while compiling
     456     */
     457    @Test
     458    public void testBuildSearchStringForTag() throws SearchParseError {
    460459        final Tag tag1 = new Tag("foo=", "bar\"");
    461460        final Tag tag2 = new Tag("foo=", "=bar");
     
    472471    /**
    473472     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/13870">Bug #13870</a>.
    474      * @throws ParseError always
    475      */
    476     @Test(expected = ParseError.class)
    477     public void testPattern13870() throws ParseError {
     473     * @throws SearchParseError always
     474     */
     475    @Test(expected = SearchParseError.class)
     476    public void testPattern13870() throws SearchParseError {
    478477        // https://bugs.openjdk.java.net/browse/JI-9044959
    479478        SearchSetting setting = new SearchSetting();
     
    503502    /**
    504503     * Robustness test for preset searching. Ensures that the query 'preset:' is not accepted.
    505      * @throws ParseError always
     504     * @throws SearchParseError always
    506505     * @since 12464
    507506     */
    508     @Test(expected = ParseError.class)
    509     public void testPresetSearchMissingValue() throws ParseError {
     507    @Test(expected = SearchParseError.class)
     508    public void testPresetSearchMissingValue() throws SearchParseError {
    510509        SearchSetting settings = new SearchSetting();
    511510        settings.text = "preset:";
     
    520519     * Robustness test for preset searching. Validates that it is not possible to search for
    521520     * non existing presets.
    522      * @throws ParseError always
     521     * @throws SearchParseError always
    523522     * @since 12464
    524523     */
    525     @Test(expected = ParseError.class)
    526     public void testPresetNotExist() throws ParseError {
     524    @Test(expected = SearchParseError.class)
     525    public void testPresetNotExist() throws SearchParseError {
    527526        String testPresetName = "groupnamethatshouldnotexist/namethatshouldnotexist";
    528527        SearchSetting settings = new SearchSetting();
     
    539538     * Robustness tests for preset searching. Ensures that combined preset names (having more than
    540539     * 1 word) must be enclosed with " .
    541      * @throws ParseError always
     540     * @throws SearchParseError always
    542541     * @since 12464
    543542     */
    544     @Test(expected = ParseError.class)
    545     public void testPresetMultipleWords() throws ParseError {
     543    @Test(expected = SearchParseError.class)
     544    public void testPresetMultipleWords() throws SearchParseError {
    546545        TaggingPreset testPreset = new TaggingPreset();
    547546        testPreset.name = "Test Combined Preset Name";
     
    562561
    563562    /**
    564      * Ensures that correct presets are stored in the {@link org.openstreetmap.josm.actions.search.SearchCompiler.Preset}
     563     * Ensures that correct presets are stored in the {@link org.openstreetmap.josm.data.osm.search.SearchCompiler.Preset}
    565564     * class against which the osm primitives are tested.
    566      * @throws ParseError if an error has been encountered while compiling
     565     * @throws SearchParseError if an error has been encountered while compiling
    567566     * @throws NoSuchFieldException if there is no field called 'presets'
    568567     * @throws IllegalAccessException if cannot access the field where all matching presets are stored
     
    570569     */
    571570    @Test
    572     public void testPresetLookup() throws ParseError, NoSuchFieldException, IllegalAccessException {
     571    public void testPresetLookup() throws SearchParseError, NoSuchFieldException, IllegalAccessException {
    573572        TaggingPreset testPreset = new TaggingPreset();
    574573        testPreset.name = "Test Preset Name";
     
    601600    /**
    602601     * Ensures that the wildcard search works and that correct presets are stored in
    603      * the {@link org.openstreetmap.josm.actions.search.SearchCompiler.Preset} class against which
     602     * the {@link org.openstreetmap.josm.data.osm.search.SearchCompiler.Preset} class against which
    604603     * the osm primitives are tested.
    605      * @throws ParseError if an error has been encountered while compiling
     604     * @throws SearchParseError if an error has been encountered while compiling
    606605     * @throws NoSuchFieldException if there is no field called 'presets'
    607606     * @throws IllegalAccessException if cannot access the field where all matching presets are stored
     
    609608     */
    610609    @Test
    611     public void testPresetLookupWildcard() throws ParseError, NoSuchFieldException, IllegalAccessException {
     610    public void testPresetLookupWildcard() throws SearchParseError, NoSuchFieldException, IllegalAccessException {
    612611        TaggingPresetMenu group = new TaggingPresetMenu();
    613612        group.name = "TestPresetGroup";
     
    650649    /**
    651650     * Ensures that correct primitives are matched against the specified preset.
    652      * @throws ParseError if an error has been encountered while compiling
     651     * @throws SearchParseError if an error has been encountered while compiling
    653652     * @since 12464
    654653     */
    655654    @Test
    656     public void testPreset() throws ParseError {
     655    public void testPreset() throws SearchParseError {
    657656        final String presetName = "Test Preset Name";
    658657        final String presetGroupName = "Test Preset Group";
     
    689688    }
    690689}
    691 
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/RecentTagCollectionTest.java

    r10962 r12656  
    1212import org.junit.Test;
    1313import org.openstreetmap.josm.actions.search.SearchAction;
    14 import org.openstreetmap.josm.actions.search.SearchCompiler;
    1514import org.openstreetmap.josm.data.osm.Tag;
     15import org.openstreetmap.josm.data.osm.search.SearchParseError;
    1616import org.openstreetmap.josm.data.preferences.CollectionProperty;
    1717import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    3434     * Performs various tests on a {@link RecentTagCollection}.
    3535     *
    36      * @throws SearchCompiler.ParseError if an error has been encountered while compiling
     36     * @throws SearchParseError if an error has been encountered while compiling
    3737     */
    3838    @Test
    39     public void testVarious() throws SearchCompiler.ParseError {
     39    public void testVarious() throws SearchParseError {
    4040        final RecentTagCollection recentTags = new RecentTagCollection(2);
    4141        assertTrue(recentTags.isEmpty());
  • trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java

    r10657 r12656  
    99import org.junit.Test;
    1010import org.openstreetmap.josm.TestUtils;
    11 import org.openstreetmap.josm.actions.search.SearchCompiler;
    1211import org.openstreetmap.josm.data.coor.EastNorth;
    1312import org.openstreetmap.josm.data.osm.DataSet;
    1413import org.openstreetmap.josm.data.osm.Relation;
    1514import org.openstreetmap.josm.data.osm.Way;
     15import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    1616import org.openstreetmap.josm.io.OsmReader;
    1717import org.openstreetmap.josm.testutils.JOSMTestRules;
  • trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateParserTest.java

    r12548 r12656  
    99import org.junit.Test;
    1010import org.openstreetmap.josm.JOSMFixture;
    11 import org.openstreetmap.josm.actions.search.SearchCompiler;
    12 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
    1311import org.openstreetmap.josm.data.osm.Node;
    1412import org.openstreetmap.josm.data.osm.Relation;
    1513import org.openstreetmap.josm.data.osm.RelationMember;
     14import org.openstreetmap.josm.data.osm.search.SearchCompiler;
     15import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
     16import org.openstreetmap.josm.data.osm.search.SearchParseError;
    1617import org.openstreetmap.josm.testutils.DatasetFactory;
    1718import org.unitils.reflectionassert.ReflectionAssert;
     
    7980    }
    8081
    81     private static Match compile(String expression) throws SearchCompiler.ParseError {
     82    private static Match compile(String expression) throws SearchParseError {
    8283        return SearchCompiler.compile(expression);
    8384    }
     
    8687     * Test to parse a search expression condition.
    8788     * @throws ParseError if the template cannot be parsed
    88      * @throws SearchCompiler.ParseError if an error has been encountered while compiling
    89      */
    90     @Test
    91     public void testConditionSearchExpression() throws ParseError, SearchCompiler.ParseError {
     89     * @throws SearchParseError if an error has been encountered while compiling
     90     */
     91    @Test
     92    public void testConditionSearchExpression() throws ParseError, SearchParseError {
    9293        TemplateParser parser = new TemplateParser("?{ admin_level = 2 'NUTS 1' | admin_level = 4 'NUTS 2' |  '{admin_level}'}");
    9394        Condition condition = new Condition();
Note: See TracChangeset for help on using the changeset viewer.