Ignore:
Timestamp:
2023-03-21T14:49:10+01:00 (22 months ago)
Author:
taylor.smock
Message:

See #16567: Convert most plugin tests to JUnit 5

Location:
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/FullGraphCreationTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core;
    33
    4 import static org.junit.Assert.assertSame;
     4
     5import static org.junit.jupiter.api.Assertions.assertSame;
    56
    67import java.util.Arrays;
    78import java.util.Collection;
     9import java.util.Collections;
    810import java.util.HashMap;
    911import java.util.Iterator;
     
    1214import java.util.Map;
    1315
    14 import org.junit.Test;
     16import org.junit.jupiter.api.Test;
    1517import org.openstreetmap.josm.plugins.graphview.core.TestDataSource.TestNode;
    1618import org.openstreetmap.josm.plugins.graphview.core.TestDataSource.TestRelation;
     
    3335import org.openstreetmap.josm.plugins.graphview.plugin.preferences.VehiclePropertyStringParser.PropertyValueSyntaxException;
    3436
    35 public class FullGraphCreationTest {
     37class FullGraphCreationTest {
    3638
    3739    private static final AccessParameters ACCESS_PARAMS;
     
    4446            ACCESS_PARAMS = new PreferenceAccessParameters(
    4547                    "test_vehicle",
    46                     Arrays.asList(AccessType.UNDEFINED),
     48                    Collections.singletonList(AccessType.UNDEFINED),
    4749                    vehiclePropertyValues);
    4850        } catch (PropertyValueSyntaxException e) {
     
    5456        @Override
    5557        public java.util.List<String> getAccessHierarchyAncestors(String transportMode) {
    56             return Arrays.asList(transportMode);
     58            return Collections.singletonList(transportMode);
    5759        }
    5860
    5961        @Override
    6062        public Collection<Tag> getBaseTags() {
    61             return Arrays.asList(new Tag("highway", "test"));
     63            return Collections.singletonList(new Tag("highway", "test"));
    6264        }
    6365
     
    6971
    7072    @Test
    71     public void testTJunction() {
     73    void testTJunction() {
    7274
    7375        TestDataSource ds = new TestDataSource();
     
    125127
    126128    @Test
    127     public void testBarrier() {
     129    void testBarrier() {
    128130
    129131        TestDataSource ds = new TestDataSource();
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/access/AccessRulesetReaderTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core.access;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertNotNull;
    7 import static org.junit.Assert.assertSame;
    8 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNotNull;
     7import static org.junit.jupiter.api.Assertions.assertSame;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    99
    1010import java.io.FileInputStream;
     
    1515import java.util.Map;
    1616
    17 import org.junit.Test;
     17import org.junit.jupiter.api.Test;
    1818import org.openstreetmap.josm.TestUtils;
    1919import org.openstreetmap.josm.plugins.graphview.core.data.MapBasedTagGroup;
     
    2121import org.openstreetmap.josm.plugins.graphview.core.data.TagGroup;
    2222
    23 public class AccessRulesetReaderTest {
     23class AccessRulesetReaderTest {
    2424
    2525    @Test
    26     public void testReadAccessRuleset_valid_classes() throws IOException {
     26    void testReadAccessRulesetValidClasses() throws IOException {
    2727
    2828        InputStream is = new FileInputStream(TestUtils.getTestDataRoot()+"accessRuleset_valid.xml");
     
    5050
    5151    @Test
    52     public void testReadAccessRuleset_valid_basetags() throws IOException {
     52    void testReadAccessRulesetValidBasetags() throws IOException {
    5353
    5454        InputStream is = new FileInputStream(TestUtils.getTestDataRoot()+"accessRuleset_valid.xml");
     
    6666
    6767    @Test
    68     public void testReadAccessRuleset_valid_implications() throws IOException {
     68    void testReadAccessRulesetValidImplications() throws IOException {
    6969
    7070        InputStream is = new FileInputStream(TestUtils.getTestDataRoot()+"accessRuleset_valid.xml");
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadInclineTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core.property;
    33
    4 import org.junit.Test;
     4import org.junit.jupiter.api.Test;
    55import org.openstreetmap.josm.plugins.graphview.core.data.Tag;
    66
    7 public class RoadInclineTest extends RoadPropertyTest {
     7class RoadInclineTest implements RoadPropertyTest {
    88
    99    private static void testIncline(Float expectedInclineForward, Float expectedInclineBackward,
    1010            String inclineString) {
    1111
    12         testEvaluateW(new RoadIncline(),
     12        RoadPropertyTest.testEvaluateW(new RoadIncline(),
    1313                expectedInclineForward, expectedInclineBackward,
    1414                new Tag("incline", inclineString));
     
    1616
    1717    @Test
    18     public void testEvaluate() {
     18    void testEvaluate() {
    1919        testIncline(5f, -5f, "5 %");
    2020        testIncline(9.5f, -9.5f, "9.5 %");
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadMaxspeedTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core.property;
    33
    4 import org.junit.Test;
     4import org.junit.jupiter.api.Test;
    55import org.openstreetmap.josm.plugins.graphview.core.data.Tag;
    66
    7 public class RoadMaxspeedTest extends RoadPropertyTest {
     7class RoadMaxspeedTest implements RoadPropertyTest {
    88
    99    private static void testMaxspeed(float expectedMaxspeed, String maxspeedString) {
    10         testEvaluateBoth(new RoadMaxspeed(), expectedMaxspeed, new Tag("maxspeed", maxspeedString));
     10        RoadPropertyTest.testEvaluateBoth(new RoadMaxspeed(), expectedMaxspeed, new Tag("maxspeed", maxspeedString));
    1111    }
    1212
    1313    @Test
    14     public void testEvaluate_numeric() {
     14    void testEvaluateNumeric() {
    1515        testMaxspeed(30, "30");
    1616        testMaxspeed(48.3f, "48.3");
     
    1818
    1919    @Test
    20     public void testEvaluate_kmh() {
     20    void testEvaluateKmh() {
    2121        testMaxspeed(50, "50 km/h");
    2222        testMaxspeed(120, "120km/h");
     
    2525
    2626    @Test
    27     public void testEvaluate_mph() {
     27    void testEvaluateMph() {
    2828        testMaxspeed(72.42048f, "45 mph");
    2929        testMaxspeed(64.373764f, "40mph");
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadPropertyTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core.property;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    6 import org.junit.Ignore;
    76import org.openstreetmap.josm.plugins.graphview.core.TestDataSource;
    87import org.openstreetmap.josm.plugins.graphview.core.data.Tag;
    98
    10 @Ignore("no test")
    11 public abstract class RoadPropertyTest {
     9public interface RoadPropertyTest {
    1210
    13     protected static <P> void testEvaluateW(RoadPropertyType<P> property, P expectedForward, P expectedBackward, Tag... wayTags) {
     11    static <P> void testEvaluateW(RoadPropertyType<P> property, P expectedForward, P expectedBackward, Tag... wayTags) {
    1412
    1513        TestDataSource ds = new TestDataSource();
     
    2523    }
    2624
    27     protected static <P> void testEvaluateN(RoadPropertyType<P> property, P expected, Tag... nodeTags) {
     25    static <P> void testEvaluateN(RoadPropertyType<P> property, P expected, Tag... nodeTags) {
    2826
    2927        TestDataSource ds = new TestDataSource();
     
    4038    }
    4139
    42     protected static <P> void testEvaluateBoth(RoadPropertyType<P> property, P expected, Tag... nodeTags) {
     40    static <P> void testEvaluateBoth(RoadPropertyType<P> property, P expected, Tag... nodeTags) {
    4341        testEvaluateW(property, expected, expected, nodeTags);
    4442        testEvaluateN(property, expected, nodeTags);
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/util/TagConditionLogicTest.java

    r32620 r36064  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.graphview.core.util;
    3 import static org.junit.Assert.assertFalse;
    4 import static org.junit.Assert.assertTrue;
     3
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    56
    67import java.util.Arrays;
     8import java.util.Collections;
    79import java.util.HashMap;
    810import java.util.Map;
    911
    10 import org.junit.Before;
    11 import org.junit.Test;
     12import org.junit.jupiter.api.BeforeEach;
     13import org.junit.jupiter.api.Test;
    1214import org.openstreetmap.josm.plugins.graphview.core.data.MapBasedTagGroup;
    1315import org.openstreetmap.josm.plugins.graphview.core.data.Tag;
    1416import org.openstreetmap.josm.plugins.graphview.core.data.TagGroup;
    1517
    16 public class TagConditionLogicTest {
     18class TagConditionLogicTest {
    1719
    1820    TagGroup groupA;
    1921    TagGroup groupB;
    2022
    21     @Before
    22     public void setUp() {
     23    @BeforeEach
     24    void setUp() {
    2325        Map<String, String> mapA = new HashMap<>();
    2426        mapA.put("key1", "value1");
     
    3436
    3537    @Test
    36     public void testTag() {
     38    void testTag() {
    3739        TagCondition condition = TagConditionLogic.tag(new Tag("key3", "value1"));
    3840        assertTrue(condition.matches(groupA));
     
    4143
    4244    @Test
    43     public void testKey() {
     45    void testKey() {
    4446        TagCondition condition = TagConditionLogic.key("key3");
    4547        assertTrue(condition.matches(groupA));
     
    4850
    4951    @Test
    50     public void testAnd() {
     52    void testAnd() {
    5153        TagCondition condition1 = TagConditionLogic.tag(new Tag("key2", "value2"));
    5254        TagCondition conditionAnd1a = TagConditionLogic.and(condition1);
    53         TagCondition conditionAnd1b = TagConditionLogic.and(Arrays.asList(condition1));
     55        TagCondition conditionAnd1b = TagConditionLogic.and(Collections.singletonList(condition1));
    5456
    5557        assertTrue(conditionAnd1a.matches(groupA));
     
    7880
    7981    @Test
    80     public void testOr() {
     82    void testOr() {
    8183        TagCondition condition1 = TagConditionLogic.tag(new Tag("key42", "value42"));
    8284        TagCondition conditionOr1a = TagConditionLogic.or(condition1);
    83         TagCondition conditionOr1b = TagConditionLogic.or(Arrays.asList(condition1));
     85        TagCondition conditionOr1b = TagConditionLogic.or(Collections.singletonList(condition1));
    8486
    8587        assertFalse(conditionOr1a.matches(groupA));
     
    108110
    109111    @Test
    110     public void testNot() {
     112    void testNot() {
    111113        TagCondition condition = TagConditionLogic.not(TagConditionLogic.key("key3"));
    112114        assertFalse(condition.matches(groupA));
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/util/ValueStringParserTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core.util;
    33
    4 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertNull;
    55import static org.openstreetmap.josm.plugins.graphview.core.util.ValueStringParser.parseMeasure;
    66import static org.openstreetmap.josm.plugins.graphview.core.util.ValueStringParser.parseSpeed;
    77import static org.openstreetmap.josm.plugins.graphview.core.util.ValueStringParser.parseWeight;
    88
    9 import org.junit.Test;
     9import org.junit.jupiter.api.Test;
    1010
    11 public class ValueStringParserTest {
     11
     12class ValueStringParserTest {
    1213
    1314    /* speed */
    1415
    1516    @Test
    16     public void testParseSpeedDefault() {
     17    void testParseSpeedDefault() {
    1718        assertClose(50, parseSpeed("50"));
    1819    }
    1920
    2021    @Test
    21     public void testParseSpeedKmh() {
     22    void testParseSpeedKmh() {
    2223        assertClose(30, parseSpeed("30 km/h"));
    2324        assertClose(100, parseSpeed("100km/h"));
     
    2526
    2627    @Test
    27     public void testParseSpeedMph() {
     28    void testParseSpeedMph() {
    2829        assertClose(40.234f, parseSpeed("25mph"));
    2930        assertClose(40.234f, parseSpeed("25 mph"));
     
    3132
    3233    @Test
    33     public void testParseSpeedInvalid() {
     34    void testParseSpeedInvalid() {
    3435        assertNull(parseSpeed("lightspeed"));
    3536    }
     
    3839
    3940    @Test
    40     public void testParseMeasureDefault() {
     41    void testParseMeasureDefault() {
    4142        assertClose(3.5f, parseMeasure("3.5"));
    4243    }
    4344
    4445    @Test
    45     public void testParseMeasureM() {
     46    void testParseMeasureM() {
    4647        assertClose(2, parseMeasure("2m"));
    4748        assertClose(5.5f, parseMeasure("5.5 m"));
     
    4950
    5051    @Test
    51     public void testParseMeasureKm() {
     52    void testParseMeasureKm() {
    5253        assertClose(1000, parseMeasure("1 km"));
    5354        assertClose(7200, parseMeasure("7.2km"));
     
    5556
    5657    @Test
    57     public void testParseMeasureMi() {
     58    void testParseMeasureMi() {
    5859        assertClose(1609.344f, parseMeasure("1 mi"));
    5960    }
    6061
    6162    @Test
    62     public void testParseMeasureFeetInches() {
     63    void testParseMeasureFeetInches() {
    6364        assertClose(3.6576f, parseMeasure("12'0\""));
    6465        assertClose(1.9812f, parseMeasure("6' 6\""));
     
    6667
    6768    @Test
    68     public void testParseMeasureInvalid() {
     69    void testParseMeasureInvalid() {
    6970        assertNull(parseMeasure("very long"));
    7071        assertNull(parseMeasure("6' 16\""));
     
    7475
    7576    @Test
    76     public void testParseWeightDefault() {
     77    void testParseWeightDefault() {
    7778        assertClose(3.6f, parseWeight("3.6"));
    7879    }
    7980
    8081    @Test
    81     public void testParseWeightT() {
     82    void testParseWeightT() {
    8283        assertClose(30, parseWeight("30t"));
    8384        assertClose(3.5f, parseWeight("3.5 t"));
     
    8586
    8687    @Test
    87     public void testParseWeightInvalid() {
     88    void testParseWeightInvalid() {
    8889        assertNull(parseWeight("heavy"));
    8990    }
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/visualisation/FloatPropertyColorSchemeTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core.visualisation;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.awt.Color;
     
    88import java.util.Map;
    99
    10 import org.junit.Before;
    11 import org.junit.Test;
     10import org.junit.jupiter.api.BeforeEach;
     11import org.junit.jupiter.api.Test;
    1212import org.openstreetmap.josm.plugins.graphview.core.property.RoadMaxweight;
    1313
    14 public class FloatPropertyColorSchemeTest {
     14class FloatPropertyColorSchemeTest {
    1515
    1616    private FloatPropertyColorScheme subject;
    1717
    18     @Before
     18    @BeforeEach
    1919    public void setUp() {
    2020
     
    2828
    2929    @Test
    30     public void testGetColorForValue_below() {
     30    void testGetColorForValueBelow() {
    3131        assertEquals(new Color(42, 42, 42), subject.getColorForValue(1f));
    3232        assertEquals(new Color(42, 42, 42), subject.getColorForValue(5f));
     
    3434
    3535    @Test
    36     public void testGetColorForValue_above() {
     36    void testGetColorForValueAbove() {
    3737        assertEquals(new Color(200, 200, 200), subject.getColorForValue(25f));
    3838    }
    3939
    4040    @Test
    41     public void testGetColorForValue_value() {
     41    void testGetColorForValueValue() {
    4242        assertEquals(new Color(100, 100, 100), subject.getColorForValue(10f));
    4343    }
    4444
    4545    @Test
    46     public void testGetColorForValue_interpolate() {
     46    void testGetColorForValueInterpolate() {
    4747        assertEquals(new Color(150, 150, 150), subject.getColorForValue(15f));
    4848    }
Note: See TracChangeset for help on using the changeset viewer.