Changeset 18918 in josm for trunk/test/unit/org
- Timestamp:
- 2023-12-19T17:09:19+01:00 (11 months ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java
r18870 r18918 225 225 assertEquals("Value 'Residential' for key 'highway' is unknown, maybe 'residential' is meant?", 226 226 errors.get(0).getDescription()); 227 assertEquals(Severity.WARNING, errors.get(0).getSeverity()); 228 assertFalse(errors.get(0).isFixable()); 229 } 230 231 @Test 232 void testRegionKey() throws IOException { 233 final List<TestError> errors = test(OsmUtils.createPrimitive("node highway=crossing crossing_ref=zebra")); 234 assertEquals(1, errors.size()); 235 assertEquals("Invalid region for this preset", errors.get(0).getMessage()); 236 assertEquals("Preset Pedestrian Crossing should not have the key crossing_ref", errors.get(0).getDescription()); 237 assertEquals(Severity.WARNING, errors.get(0).getSeverity()); 238 assertFalse(errors.get(0).isFixable()); 239 240 } 241 242 @Test 243 void testRegionTag() throws IOException { 244 final List<TestError> errors = test(OsmUtils.createPrimitive("relation type=waterway ref:gnis=123456")); 245 assertEquals(1, errors.size()); 246 assertEquals("Invalid region for this preset", errors.get(0).getMessage()); 247 assertEquals("Preset Waterway should not have the key ref:gnis", errors.get(0).getDescription()); 227 248 assertEquals(Severity.WARNING, errors.get(0).getSeverity()); 228 249 assertFalse(errors.get(0).isFixable()); -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/CheckGroupTest.java
r18853 r18918 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 import javax.swing.JPanel; 9 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 4 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 5 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 6 13 7 /** 14 8 * Unit tests of {@link CheckGroup} class. 15 9 */ 16 class CheckGroupTest { 17 /** 18 * Unit test for {@link CheckGroup#addToPanel}. 19 */ 20 @Test 21 void testAddToPanel() { 22 CheckGroup cg = new CheckGroup(); 23 JPanel p = new JPanel(); 24 assertEquals(0, p.getComponentCount()); 25 assertFalse(cg.addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 26 assertTrue(p.getComponentCount() > 0); 10 class CheckGroupTest implements TaggingPresetItemTest { 11 @Override 12 public TaggingPresetItem getInstance() { 13 return new CheckGroup(); 27 14 } 28 15 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/CheckTest.java
r18870 r18918 9 9 import org.junit.jupiter.api.Test; 10 10 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 11 12 import org.openstreetmap.josm.testutils.annotations.Main; 12 13 … … 15 16 */ 16 17 @Main 17 class CheckTest { 18 class CheckTest implements RegionSpecificTest, TaggingPresetItemTest { 19 @Override 20 public Check getInstance() { 21 final Check check = new Check(); 22 check.key = "crossing:island"; 23 return check; 24 } 25 18 26 /** 19 27 * Unit test for {@link Check#addToPanel}. 20 28 */ 29 @Override 21 30 @Test 22 void testAddToPanel() {31 public void testAddToPanel() { 23 32 JPanel p = new JPanel(); 24 33 assertEquals(0, p.getComponentCount()); 25 assertTrue( new Check().addToPanel(p, TaggingPresetItemGuiSupport.create(false)));34 assertTrue(getInstance().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 26 35 assertTrue(p.getComponentCount() > 0); 27 36 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboTest.java
r18870 r18918 13 13 import org.openstreetmap.josm.data.osm.OsmUtils; 14 14 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 15 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 15 16 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 16 17 import org.openstreetmap.josm.testutils.annotations.I18n; … … 23 24 @I18n("de") 24 25 @Main 25 class ComboTest { 26 class ComboTest implements TaggingPresetItemTest { 27 @Override 28 public Combo getInstance() { 29 return new Combo(); 30 } 31 26 32 /** 27 * Unit test for {@link C ombo#addToPanel}.33 * Unit test for {@link Check#addToPanel}. 28 34 */ 35 @Override 29 36 @Test 30 void testAddToPanel() {37 public void testAddToPanel() { 31 38 JPanel p = new JPanel(); 32 39 assertEquals(0, p.getComponentCount()); 33 assertTrue( new Combo().addToPanel(p, TaggingPresetItemGuiSupport.create(false)));40 assertTrue(getInstance().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 34 41 assertTrue(p.getComponentCount() > 0); 35 42 } … … 40 47 @Test 41 48 void testUseLastAsDefault() { 42 Combo combo = new Combo();49 final Combo combo = getInstance(); 43 50 combo.key = "addr:country"; 44 51 combo.values_from = "java.util.Locale#getISOCountries"; … … 119 126 @Test 120 127 void testColor() { 121 Combo combo = new Combo();128 final Combo combo = getInstance(); 122 129 combo.key = "colour"; 123 130 combo.values = "red;green;blue;black"; -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ItemSeparatorTest.java
r18853 r18918 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 import javax.swing.JPanel; 9 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 4 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 5 13 6 /** 14 7 * Unit tests of {@link ItemSeparator} class. 15 8 */ 16 class ItemSeparatorTest { 17 /** 18 * Unit test for {@link ItemSeparator#addToPanel}. 19 */ 20 @Test 21 void testAddToPanel() { 22 JPanel p = new JPanel(); 23 assertEquals(0, p.getComponentCount()); 24 assertFalse(new ItemSeparator().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 25 assertTrue(p.getComponentCount() > 0); 9 class ItemSeparatorTest implements TaggingPresetItemTest { 10 @Override 11 public ItemSeparator getInstance() { 12 return new ItemSeparator(); 26 13 } 27 14 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/KeyTest.java
r18853 r18918 9 9 import org.junit.jupiter.api.Test; 10 10 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 11 12 12 13 /** 13 14 * Unit tests of {@link Key} class. 14 15 */ 15 class KeyTest { 16 class KeyTest implements RegionSpecificTest, TaggingPresetItemTest { 17 @Override 18 public Key getInstance() { 19 final Key key = new Key(); 20 key.key = "highway"; 21 key.value = "residential"; 22 return key; 23 } 24 16 25 /** 17 26 * Unit test for {@link Key#addToPanel}. 18 27 */ 19 28 @Test 20 void testAddToPanel() { 29 @Override 30 public void testAddToPanel() { 21 31 JPanel p = new JPanel(); 22 32 assertEquals(0, p.getComponentCount()); -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/LabelTest.java
r18853 r18918 9 9 import org.junit.jupiter.api.Test; 10 10 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 11 12 12 13 /** 13 14 * Unit tests of {@link Label} class. 14 15 */ 15 class LabelTest { 16 class LabelTest implements TaggingPresetItemTest { 17 @Override 18 public Label getInstance() { 19 return new Label(); 20 } 21 16 22 /** 17 * Unit test for {@link Label#addToPanel}.23 * Unit test for {@link Check#addToPanel}. 18 24 */ 25 @Override 19 26 @Test 20 void testAddToPanel() {27 public void testAddToPanel() { 21 28 JPanel p = new JPanel(); 22 29 assertEquals(0, p.getComponentCount()); 23 assertTrue( new Label().addToPanel(p, TaggingPresetItemGuiSupport.create(false)));30 assertTrue(getInstance().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 24 31 assertTrue(p.getComponentCount() > 0); 25 32 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/LinkTest.java
r18853 r18918 10 10 import org.junit.jupiter.api.Test; 11 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 12 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 13 import org.openstreetmap.josm.spi.preferences.Config; 13 14 … … 15 16 * Unit tests of {@link Link} class. 16 17 */ 17 class LinkTest { 18 class LinkTest implements TaggingPresetItemTest { 19 @Override 20 public Link getInstance() { 21 return new Link(); 22 } 23 18 24 /** 19 25 * Unit test for {@link Link#addToPanel}. 20 26 */ 27 @Override 21 28 @Test 22 void testAddToPanel() {23 Link l = new Link();29 public void testAddToPanel() { 30 Link l = getInstance(); 24 31 JPanel p = new JPanel(); 25 32 assertEquals(0, p.getComponentCount()); -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/MultiSelectTest.java
r18870 r18918 9 9 import org.junit.jupiter.api.Test; 10 10 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 11 12 import org.openstreetmap.josm.testutils.annotations.Main; 12 13 … … 15 16 */ 16 17 @Main 17 class MultiSelectTest { 18 class MultiSelectTest implements TaggingPresetItemTest { 19 @Override 20 public MultiSelect getInstance() { 21 return new MultiSelect(); 22 } 23 18 24 /** 19 * Unit test for {@link MultiSelect#addToPanel}.25 * Unit test for {@link Check#addToPanel}. 20 26 */ 27 @Override 21 28 @Test 22 void testAddToPanel() {29 public void testAddToPanel() { 23 30 JPanel p = new JPanel(); 24 31 assertEquals(0, p.getComponentCount()); 25 assertTrue( new MultiSelect().addToPanel(p, TaggingPresetItemGuiSupport.create(false)));32 assertTrue(getInstance().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 26 33 assertTrue(p.getComponentCount() > 0); 27 34 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/OptionalTest.java
r18853 r18918 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 import javax.swing.JPanel; 9 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 4 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 5 13 6 /** 14 7 * Unit tests of {@link Optional} class. 15 8 */ 16 class OptionalTest { 17 /** 18 * Unit test for {@link Optional#addToPanel}. 19 */ 20 @Test 21 void testAddToPanel() { 22 JPanel p = new JPanel(); 23 assertEquals(0, p.getComponentCount()); 24 assertFalse(new Optional().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 25 assertTrue(p.getComponentCount() > 0); 9 class OptionalTest implements TaggingPresetItemTest { 10 @Override 11 public Optional getInstance() { 12 return new Optional(); 26 13 } 27 14 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/PresetLinkTest.java
r18870 r18918 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 import javax.swing.JPanel; 9 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 4 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 5 import org.openstreetmap.josm.testutils.annotations.TaggingPresets; 13 6 … … 16 9 */ 17 10 @TaggingPresets 18 class PresetLinkTest { 19 /** 20 * Unit test for {@link PresetLink#addToPanel}. 21 */ 22 @Test 23 void testAddToPanel() { 24 PresetLink l = new PresetLink(); 25 l.preset_name = "River"; 26 JPanel p = new JPanel(); 27 assertEquals(0, p.getComponentCount()); 28 assertFalse(l.addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 29 assertTrue(p.getComponentCount() > 0); 11 class PresetLinkTest implements TaggingPresetItemTest { 12 @Override 13 public PresetLink getInstance() { 14 PresetLink presetLink = new PresetLink(); 15 presetLink.preset_name = "River"; 16 return presetLink; 30 17 } 31 18 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/RolesTest.java
r18853 r18918 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 import javax.swing.JPanel; 9 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 4 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 5 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 6 13 7 /** 14 8 * Unit tests of {@link Roles} class. 15 9 */ 16 class RolesTest { 17 /** 18 * Unit test for {@link Roles#addToPanel}. 19 */ 20 @Test 21 void testAddToPanel() { 22 JPanel p = new JPanel(); 23 assertEquals(0, p.getComponentCount()); 24 assertFalse(new Roles().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 25 assertTrue(p.getComponentCount() > 0); 10 class RolesTest implements TaggingPresetItemTest { 11 @Override 12 public TaggingPresetItem getInstance() { 13 return new Roles(); 26 14 } 27 15 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/SpaceTest.java
r18853 r18918 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 import javax.swing.JPanel; 9 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 4 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 5 13 6 /** 14 7 * Unit tests of {@link Space} class. 15 8 */ 16 class SpaceTest { 17 /** 18 * Unit test for {@link Space#addToPanel}. 19 */ 20 @Test 21 void testAddToPanel() { 22 JPanel p = new JPanel(); 23 assertEquals(0, p.getComponentCount()); 24 assertFalse(new Space().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 25 assertTrue(p.getComponentCount() > 0); 9 class SpaceTest implements TaggingPresetItemTest { 10 @Override 11 public Space getInstance() { 12 return new Space(); 26 13 } 27 14 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/TextTest.java
r18870 r18918 9 9 import org.junit.jupiter.api.Test; 10 10 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 11 12 import org.openstreetmap.josm.testutils.annotations.Main; 12 13 … … 15 16 */ 16 17 @Main 17 class TextTest { 18 class TextTest implements TaggingPresetItemTest { 19 @Override 20 public Text getInstance() { 21 return new Text(); 22 } 23 18 24 /** 19 * Unit test for {@link Text#addToPanel}.25 * Unit test for {@link Check#addToPanel}. 20 26 */ 27 @Override 21 28 @Test 22 void testAddToPanel() {29 public void testAddToPanel() { 23 30 JPanel p = new JPanel(); 24 31 assertEquals(0, p.getComponentCount()); 25 assertTrue( new Text().addToPanel(p, TaggingPresetItemGuiSupport.create(false)));32 assertTrue(getInstance().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 26 33 assertTrue(p.getComponentCount() > 0); 27 34 } -
trunk/test/unit/org/openstreetmap/josm/testutils/annotations/TaggingPresets.java
r18867 r18918 9 9 import java.util.Collection; 10 10 11 import org.junit.jupiter.api.extension.BeforeAllCallback; 11 12 import org.junit.jupiter.api.extension.BeforeEachCallback; 12 13 import org.junit.jupiter.api.extension.ExtendWith; … … 25 26 @Target({ ElementType.METHOD, ElementType.TYPE }) 26 27 @BasicPreferences 28 @Territories 27 29 @ExtendWith(TaggingPresets.TaggingPresetsExtension.class) 28 30 public @interface TaggingPresets { 29 31 30 class TaggingPresetsExtension implements BeforeEachCallback {32 class TaggingPresetsExtension implements BeforeEachCallback, BeforeAllCallback { 31 33 private static int expectedHashcode = 0; 34 35 @Override 36 public void beforeAll(ExtensionContext extensionContext) throws Exception { 37 setup(); 38 } 32 39 33 40 @Override … … 37 44 38 45 /** 39 * Set up the tagging presets46 * Set up the tagging presets 40 47 */ 41 48 public static synchronized void setup() {
Note:
See TracChangeset
for help on using the changeset viewer.