Ignore:
Timestamp:
2021-07-11T14:39:42+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #21095 - see #21041 - fix NPE when opening the preset editor with new objects

File:
1 edited

Legend:

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

    r17938 r18001  
    22package org.openstreetmap.josm.gui.tagging.presets;
    33
    4 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
     6
     7import java.util.Arrays;
     8import java.util.Locale;
     9
     10import javax.swing.JLabel;
     11
    512import org.junit.jupiter.api.BeforeEach;
    613import org.junit.jupiter.api.Test;
     
    916import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1017import org.openstreetmap.josm.data.osm.OsmUtils;
     18import org.openstreetmap.josm.data.osm.Tag;
    1119import org.openstreetmap.josm.data.validation.OsmValidator;
    1220import org.openstreetmap.josm.testutils.JOSMTestRules;
    1321
    14 import javax.swing.JLabel;
    15 
    16 import static org.junit.jupiter.api.Assertions.assertEquals;
    17 import static org.junit.jupiter.api.Assertions.assertTrue;
     22import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1823
    1924/**
     
    3136    @BeforeEach
    3237    void setUp() {
     38        Locale.setDefault(Locale.ENGLISH);
    3339        OsmValidator.initialize();
    3440    }
     
    3844     */
    3945    @Test
    40     void validate() {
     46    void testValidate() {
    4147        JLabel label = new JLabel();
    4248        OsmPrimitive primitive = OsmUtils.createPrimitive("way incline=10m width=1mm opening_hours=\"Mo-Fr 8-10\"");
     
    5359                "<li>suspicious tag combination (incline on suspicious object)</li></ul>", label.getToolTipText());
    5460    }
     61
     62    /**
     63     * Tests {@link TaggingPresetValidation#applyChangedTags}
     64     */
     65    @Test
     66    void testApplyChangedTags() {
     67        OsmPrimitive primitive = OsmUtils.createPrimitive("way incline=10m width=1mm opening_hours=\"Mo-Fr 8-10\"");
     68        new DataSet(primitive);
     69        OsmPrimitive clone = TaggingPresetValidation.applyChangedTags(primitive, Arrays.asList(new Tag("incline", "20m")));
     70        assertEquals("20m", clone.get("incline"));
     71        assertEquals("1mm", clone.get("width"));
     72    }
    5573}
Note: See TracChangeset for help on using the changeset viewer.