Changeset 8863 in josm for trunk/test


Ignore:
Timestamp:
2015-10-12T22:58:25+02:00 (9 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
Files:
1 added
5 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/ConditionalKeysTest.groovy

    r7938 r8863  
    33
    44import org.openstreetmap.josm.JOSMFixture
    5 import org.openstreetmap.josm.gui.tagging.TaggingPresets
     5import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    66
    77class ConditionalKeysTest extends GroovyTestCase {
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java

    r8857 r8863  
    2121import org.openstreetmap.josm.data.osm.Tag;
    2222import org.openstreetmap.josm.data.validation.Severity;
    23 import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    24 import org.openstreetmap.josm.gui.tagging.TaggingPresetItem;
    25 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems;
    26 import org.openstreetmap.josm.gui.tagging.TaggingPresetReader;
     23import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset;
     24import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem;
     25import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader;
     26import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem;
    2727
    2828/**
     
    213213        for (final TaggingPreset p : presets) {
    214214            for (final TaggingPresetItem i : p.data) {
    215                 if (i instanceof TaggingPresetItems.KeyedItem &&
    216                         Arrays.asList("opening_hours", "service_times", "collection_times").contains(((TaggingPresetItems.KeyedItem) i).key)) {
    217                     for (final String v : ((TaggingPresetItems.KeyedItem) i).getValues()) {
    218                         values.add(new Tag(((TaggingPresetItems.KeyedItem) i).key, v));
     215                if (i instanceof KeyedItem &&
     216                        Arrays.asList("opening_hours", "service_times", "collection_times").contains(((KeyedItem) i).key)) {
     217                    for (final String v : ((KeyedItem) i).getValues()) {
     218                        values.add(new Tag(((KeyedItem) i).key, v));
    219219                    }
    220220                }
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/RelationCheckerTest.groovy

    r7938 r8863  
    99import org.openstreetmap.josm.data.osm.Way
    1010import org.openstreetmap.josm.data.validation.TestError
    11 import org.openstreetmap.josm.gui.tagging.TaggingPresets
     11import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    1212
    1313class RelationCheckerTest extends GroovyTestCase {
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java

    r8857 r8863  
    1313import org.openstreetmap.josm.data.osm.OsmUtils;
    1414import org.openstreetmap.josm.data.validation.TestError;
    15 import org.openstreetmap.josm.gui.tagging.TaggingPresets;
     15import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    1616
    1717/**
  • trunk/test/unit/org/openstreetmap/josm/gui/DefaultNameFormatterTest.java

    r8857 r8863  
    2020import org.openstreetmap.josm.data.osm.Relation;
    2121import org.openstreetmap.josm.data.osm.Way;
    22 import org.openstreetmap.josm.gui.tagging.TaggingPresetReader;
    23 import org.openstreetmap.josm.gui.tagging.TaggingPresets;
     22import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader;
     23import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    2424import org.openstreetmap.josm.io.Compression;
    2525import org.openstreetmap.josm.io.IllegalDataException;
  • 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.