Ignore:
Timestamp:
2015-10-12T22:58:25+02:00 (6 years ago)
Author:
Don-vip
Message:

major code cleanup/refactoring of tagging presets: slay the monster TaggingPresetItems (60 Kb, 1600 lines) and extract all its internal classes to a new package gui.tagging.presets.items

Location:
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets
Files:
1 added
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/PresetClassificationsTest.java

    r8862 r8863  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.tagging;
     2package org.openstreetmap.josm.gui.tagging.presets;
    33
    44import static org.junit.Assert.assertFalse;
     
    1818import org.openstreetmap.josm.data.osm.OsmUtils;
    1919import org.openstreetmap.josm.data.osm.Way;
     20import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSelector.PresetClassification;
     21import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSelector.PresetClassifications;
    2022import org.openstreetmap.josm.tools.Utils;
    2123import org.xml.sax.SAXException;
    2224
     25/**
     26 * Unit tests of {@link PresetClassifications} class.
     27 */
    2328public class PresetClassificationsTest {
    2429
    25     static final TaggingPresetSelector.PresetClassifications classifications = new TaggingPresetSelector.PresetClassifications();
     30    static final PresetClassifications classifications = new PresetClassifications();
    2631
    2732    /**
    2833     * Setup test.
     34     * @throws SAXException if any XML error occurs
     35     * @throws IOException if any I/O error occurs
    2936     */
    3037    @BeforeClass
     
    3542    }
    3643
    37     private List<TaggingPresetSelector.PresetClassification> getMatchingPresets(String searchText, OsmPrimitive w) {
     44    private List<PresetClassification> getMatchingPresets(String searchText, OsmPrimitive w) {
    3845        return classifications.getMatchingPresets(searchText, true, true, EnumSet.of(TaggingPresetType.forPrimitive(w)),
    3946                Collections.singleton(w));
     
    4148
    4249    private List<String> getMatchingPresetNames(String searchText, OsmPrimitive w) {
    43         return Utils.transform(getMatchingPresets(searchText, w), new Utils.Function<TaggingPresetSelector.PresetClassification, String>() {
     50        return Utils.transform(getMatchingPresets(searchText, w), new Utils.Function<PresetClassification, String>() {
    4451            @Override
    45             public String apply(TaggingPresetSelector.PresetClassification x) {
     52            public String apply(PresetClassification x) {
    4653                return x.preset.name;
    4754            }
     
    4956    }
    5057
     58    /**
     59     * Test building preset.
     60     */
    5161    @Test
    52     public void testBuilding() throws Exception {
     62    public void testBuilding() {
    5363        final Way w = new Way();
    5464        final Node n1 = new Node();
     
    6171    }
    6272
     73    /**
     74     * Test public transport tram relations presets.
     75     */
    6376    @Test
    6477    public void testRelationsForTram() {
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java

    r8862 r8863  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.tagging;
     2package org.openstreetmap.josm.gui.tagging.presets;
    33
    44import static org.CustomMatchers.hasSize;
     
    1515import org.openstreetmap.josm.JOSMFixture;
    1616import org.openstreetmap.josm.TestUtils;
     17import org.openstreetmap.josm.gui.tagging.presets.items.Check;
     18import org.openstreetmap.josm.gui.tagging.presets.items.Key;
    1719import org.openstreetmap.josm.tools.Utils;
    1820import org.xml.sax.SAXException;
     
    3335    /**
    3436     * #8954 - last checkbox in the preset is not added
     37     * @throws SAXException if any XML error occurs
     38     * @throws IOException if any I/O error occurs
    3539     */
    3640    @Test
     
    4246        Assert.assertEquals("Number of entries", 1, preset.data.size());
    4347        final TaggingPresetItem item = preset.data.get(0);
    44         Assert.assertTrue("Entry is not checkbox", item instanceof TaggingPresetItems.Check);
     48        Assert.assertTrue("Entry is not checkbox", item instanceof Check);
    4549    }
    4650
     51    /**
     52     * Test nested chunks
     53     * @throws SAXException if any XML error occurs
     54     * @throws IOException if any I/O error occurs
     55     */
    4756    @Test
    48     public void testNestedChunks() throws Exception {
     57    public void testNestedChunks() throws SAXException, IOException {
    4958        final Collection<TaggingPreset> presets = TaggingPresetReader.readAll(TestUtils.getTestDataRoot() + "preset_chunk.xml", true);
    5059        assertThat(presets, hasSize(1));
     
    5362            @Override
    5463            public String apply(TaggingPresetItem x) {
    55                 return ((TaggingPresetItems.Key) x).key;
     64                return ((Key) x).key;
    5665            }
    5766        });
     
    6271     * Validate internal presets
    6372     * See #9027
     73     * @throws SAXException if any XML error occurs
     74     * @throws IOException if any I/O error occurs
    6475     */
    6576    @Test
Note: See TracChangeset for help on using the changeset viewer.