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/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/AllUnitTests.java

    r32519 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions;
    33
    4 import org.junit.runner.RunWith;
    5 import org.junit.runners.Suite;
     4import org.junit.platform.suite.api.SelectClasses;
     5import org.junit.platform.suite.api.Suite;
    66import org.openstreetmap.josm.plugins.turnrestrictions.editor.AllEditorTests;
    77
    8 @RunWith(Suite.class)
    9 @Suite.SuiteClasses({
     8@Suite
     9@SelectClasses({
    1010    AllEditorTests.class,
    1111    TurnRestrictionBuilderTest.class
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/TurnRestrictionBuilderTest.java

    r32925 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions;
    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.assertNull;
    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.assertNull;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    99import static org.openstreetmap.josm.plugins.turnrestrictions.TurnRestrictionBuilder.intersectionAngle;
    1010import static org.openstreetmap.josm.plugins.turnrestrictions.TurnRestrictionBuilder.selectToWayAfterSplit;
     
    1212import java.util.ArrayList;
    1313import java.util.Arrays;
     14import java.util.Collections;
    1415import java.util.List;
    1516import java.util.Optional;
    1617
    17 import org.junit.Rule;
    18 import org.junit.Test;
     18import org.junit.jupiter.api.Test;
    1919import org.openstreetmap.josm.data.coor.LatLon;
    2020import org.openstreetmap.josm.data.osm.Node;
     
    2525import org.openstreetmap.josm.plugins.turnrestrictions.TurnRestrictionBuilder.RelativeWayJoinOrientation;
    2626import org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionType;
    27 import org.openstreetmap.josm.testutils.JOSMTestRules;
    28 
    29 public class TurnRestrictionBuilderTest {
    30 
    31     @Rule
    32     public JOSMTestRules rules = new JOSMTestRules().preferences();
    33 
     27import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     28
     29@BasicPreferences
     30class TurnRestrictionBuilderTest {
    3431    TurnRestrictionBuilder builder = new TurnRestrictionBuilder();
    3532
    3633    boolean hasExactlyOneMemberWithRole(Relation r, final String role) {
    37         return r.getMembers().stream().filter(rm -> role.equals(rm.getRole())).findFirst().isPresent();
     34        return r.getMembers().stream().anyMatch(rm -> role.equals(rm.getRole()));
    3835    }
    3936
    4037    OsmPrimitive memberWithRole(Relation r, final String role) {
    4138        Optional<RelationMember> opt = r.getMembers().stream().filter(rm -> role.equals(rm.getRole())).findFirst();
    42         if (!opt.isPresent())
    43             return null;
    44         return opt.get().getMember();
     39        return opt.map(RelationMember::getMember).orElse(null);
    4540    }
    4641
     
    5752     */
    5853    @Test
    59     public void noUTurn_1() {
     54    void testNoUTurn1() {
    6055        Way w = new Way(1);
    6156        Node n1 = new Node(1);
     
    8479    */
    8580   @Test
    86    public void noUTurn_2() {
     81   void testNoUTurn2() {
    8782       Way w = new Way(1);
    8883       Node n1 = new Node(1);
     
    106101
    107102   @Test
    108    public void nullSelection() {
     103   void testNullSelection() {
    109104       assertEmptyTurnRestriction(builder.build(null));
    110105   }
    111106
    112107   @Test
    113    public void emptySelection() {
     108   void testEmptySelection() {
    114109       assertEmptyTurnRestriction(builder.build(new ArrayList<>()));
    115110   }
     
    120115    */
    121116   @Test
    122    public void oneSelectedWay() {
     117   void testOneSelectedWay() {
    123118       Way w = new Way(1);
    124        Relation tr = builder.build(Arrays.asList(w));
     119       Relation tr = builder.build(Collections.singletonList(w));
    125120       assertNotNull(tr);
    126121       assertEquals("restriction", tr.get("type"));
     
    134129    */
    135130   @Test
    136    public void twoUnconnectedWays() {
     131   void testTwoUnconnectedWays() {
    137132       Way w1 = new Way(1);
    138133       w1.setNodes(Arrays.asList(new Node(11), new Node(12)));
     
    159154    */
    160155   @Test
    161    public void twoConnectedWays_1() {
     156   void testTwoConnectedWays1() {
    162157       Node n1 = new Node(1);
    163158       n1.setCoor(new LatLon(1, 1));
     
    217212    */
    218213   @Test
    219    public void twoConnectedWays_2() {
     214   void testTwoConnectedWays2() {
    220215       Node n1 = new Node(1);
    221216       n1.setCoor(new LatLon(5, 5));
     
    260255
    261256   /**
    262    * Two connected ways. end node of the first way connects to end node of
    263    * the second way. left turn.
    264    *
    265    *
    266    *           (7,5) -
    267    *             ^     -    w2
    268    *             | w1     ------> (6,7)
    269    *             |
    270    *           (5,5)
    271    */
    272   @Test
    273   public void twoConnectedWays_3() {
    274       Node n1 = new Node(1);
    275       n1.setCoor(new LatLon(5, 5));
    276       Node n2 = new Node(2);
    277       n2.setCoor(new LatLon(7, 5));
    278       Node n3 = new Node(3);
    279       n3.setCoor(new LatLon(6, 7));
    280 
    281       Way w1 = new Way(1);
    282       w1.setNodes(Arrays.asList(n1, n2));
    283       Way w2 = new Way(2);
    284       w2.setNodes(Arrays.asList(n2, n3));
    285 
    286       Relation tr = builder.build(Arrays.asList(w1, w2, n2));
    287 
    288       assertNotNull(tr);
    289       assertEquals("restriction", tr.get("type"));
    290       assertEquals(3, tr.getMembersCount());
    291       assertEquals(w1, memberWithRole(tr, "from"));
    292       assertEquals(w2, memberWithRole(tr, "to"));
    293       assertEquals(n2, memberWithRole(tr, "via"));
    294 
    295       assertEquals("no_right_turn", tr.get("restriction"));
    296   }
    297 
    298   /**
    299   * Two connected ways. end node of the first way connects to end node of
    300   * the second way. left turn.
    301   *
    302   *
    303   *           (10,10)
    304   *                 \
    305   *                  \
    306   *                   \
    307   *                    v
    308   *                     (8,15)
    309   *                    /
    310   *                   /
    311   *                  /
    312   *                 v
    313   *            (5,11)
    314   */
    315  @Test
    316  public void twoConnectedWays_4() {
    317      Node n1 = new Node(1);
    318      n1.setCoor(new LatLon(10, 10));
    319      Node n2 = new Node(2);
    320      n2.setCoor(new LatLon(8, 15));
    321      Node n3 = new Node(3);
    322      n3.setCoor(new LatLon(5, 11));
    323 
    324      Way w1 = new Way(1);
    325      w1.setNodes(Arrays.asList(n1, n2));
    326      Way w2 = new Way(2);
    327      w2.setNodes(Arrays.asList(n2, n3));
    328 
    329      Relation tr = builder.build(Arrays.asList(w1, w2, n2));
    330 
    331      assertNotNull(tr);
    332      assertEquals("restriction", tr.get("type"));
    333      assertEquals(3, tr.getMembersCount());
    334      assertEquals(w1, memberWithRole(tr, "from"));
    335      assertEquals(w2, memberWithRole(tr, "to"));
    336      assertEquals(n2, memberWithRole(tr, "via"));
    337 
    338      assertEquals("no_right_turn", tr.get("restriction"));
    339 
    340      /*
    341       * opposite order, from w2 to w1. In  this case we have left turn.
    342       */
    343      tr = builder.build(Arrays.asList(w2, w1, n2));
    344 
    345      assertNotNull(tr);
    346      assertEquals("restriction", tr.get("type"));
    347      assertEquals(3, tr.getMembersCount());
    348      assertEquals(w2, memberWithRole(tr, "from"));
    349      assertEquals(w1, memberWithRole(tr, "to"));
    350      assertEquals(n2, memberWithRole(tr, "via"));
    351 
    352      assertEquals("no_left_turn", tr.get("restriction"));
     257    * Two connected ways. end node of the first way connects to end node of
     258    * the second way. left turn.
     259    *
     260    *           (7,5) -
     261    *             ^     -    w2
     262    *             | w1     ------> (6,7)
     263    *             |
     264    *           (5,5)
     265    */
     266    @Test
     267    void testTwoConnectedWays3() {
     268        Node n1 = new Node(1);
     269        n1.setCoor(new LatLon(5, 5));
     270        Node n2 = new Node(2);
     271        n2.setCoor(new LatLon(7, 5));
     272        Node n3 = new Node(3);
     273        n3.setCoor(new LatLon(6, 7));
     274
     275        Way w1 = new Way(1);
     276        w1.setNodes(Arrays.asList(n1, n2));
     277        Way w2 = new Way(2);
     278        w2.setNodes(Arrays.asList(n2, n3));
     279
     280        Relation tr = builder.build(Arrays.asList(w1, w2, n2));
     281
     282        assertNotNull(tr);
     283        assertEquals("restriction", tr.get("type"));
     284        assertEquals(3, tr.getMembersCount());
     285        assertEquals(w1, memberWithRole(tr, "from"));
     286        assertEquals(w2, memberWithRole(tr, "to"));
     287        assertEquals(n2, memberWithRole(tr, "via"));
     288
     289        assertEquals("no_right_turn", tr.get("restriction"));
     290    }
     291
     292    /**
     293     * Two connected ways. end node of the first way connects to end node of
     294     * the second way. left turn.
     295     *
     296     *           (10,10)
     297     *                 \
     298     *                  \
     299     *                   \
     300     *                    v
     301     *                     (8,15)
     302     *                    /
     303     *                   /
     304     *                  /
     305     *                 v
     306     *            (5,11)
     307     */
     308    @Test
     309    void testTwoConnectedWays4() {
     310        Node n1 = new Node(1);
     311        n1.setCoor(new LatLon(10, 10));
     312        Node n2 = new Node(2);
     313        n2.setCoor(new LatLon(8, 15));
     314        Node n3 = new Node(3);
     315        n3.setCoor(new LatLon(5, 11));
     316
     317        Way w1 = new Way(1);
     318        w1.setNodes(Arrays.asList(n1, n2));
     319        Way w2 = new Way(2);
     320        w2.setNodes(Arrays.asList(n2, n3));
     321
     322        Relation tr = builder.build(Arrays.asList(w1, w2, n2));
     323
     324        assertNotNull(tr);
     325        assertEquals("restriction", tr.get("type"));
     326        assertEquals(3, tr.getMembersCount());
     327        assertEquals(w1, memberWithRole(tr, "from"));
     328        assertEquals(w2, memberWithRole(tr, "to"));
     329        assertEquals(n2, memberWithRole(tr, "via"));
     330
     331        assertEquals("no_right_turn", tr.get("restriction"));
     332
     333        /*
     334         * opposite order, from w2 to w1. In  this case we have left turn.
     335         */
     336        tr = builder.build(Arrays.asList(w2, w1, n2));
     337
     338        assertNotNull(tr);
     339        assertEquals("restriction", tr.get("type"));
     340        assertEquals(3, tr.getMembersCount());
     341        assertEquals(w2, memberWithRole(tr, "from"));
     342        assertEquals(w1, memberWithRole(tr, "to"));
     343        assertEquals(n2, memberWithRole(tr, "via"));
     344
     345        assertEquals("no_left_turn", tr.get("restriction"));
    353346    }
    354347
     
    374367      */
    375368     @Test
    376      public void intersectionAngle_1() {
     369     void testIntersectionAngle1() {
    377370         Node n1 = nn(1, 5, 5);
    378371         Node n2 = nn(2, 5, 10);
     
    429422     */
    430423    @Test
    431     public void intersectionAngle_2() {
     424    void testIntersectionAngle2() {
    432425        Node n1 = nn(1, 5, 5);
    433426        Node n2 = nn(2, 5, 10);
     
    473466     *          /
    474467     *      (-5, -10) n2
    475     *           ^
    476     *           |
    477     *           | from
    478     *           |
    479     *       (-10,-10) n1
    480     */
    481    @Test
    482    public void intersectionAngle_3() {
    483        Node n1 = nn(1, -10, -10);
    484        Node n2 = nn(2, -5, -10);
    485        Node n3 = nn(3, -1, -6);
    486        Way from = nw(1, n1, n2);
    487        Way to = nw(2, n2, n3);
    488 
    489        double a = TurnRestrictionBuilder.intersectionAngle(from, to);
    490        assertEquals(45, Math.toDegrees(a), 1e-7);
    491 
    492        /*
    493         * if reversed from, the intersection angle is still 45
    494         */
    495        from = nw(1, n2, n1);
    496        to = nw(2, n2, n3);
    497        a = TurnRestrictionBuilder.intersectionAngle(from, to);
    498        assertEquals(45, Math.toDegrees(a), 1e-7);
    499 
    500        /*
    501        * if reversed to, the intersection angle is still 45
    502        */
    503        from = nw(1, n1, n2);
    504        to = nw(2, n3, n2);
    505        a = TurnRestrictionBuilder.intersectionAngle(from, to);
    506        assertEquals(45, Math.toDegrees(a), 1e-7);
    507 
    508        /*
    509        * if reversed both, the intersection angle is still 45
    510        */
    511        from = nw(1, n2, n1);
    512        to = nw(2, n3, n2);
    513        a = TurnRestrictionBuilder.intersectionAngle(from, to);
    514        assertEquals(45, Math.toDegrees(a), 1e-7);
    515    }
    516 
    517    /**
    518    *
    519    *
    520    *         (-1,-14) (n3)
    521    *            ^
    522    *            \
    523    *             \ to
    524    *              \
    525    *          (-5, -10) n2
    526   *               ^
    527   *               |
    528   *               | from
    529   *               |
    530   *           (-10,-10) n1
    531   */
    532  @Test
    533  public void intersectionAngle_4() {
    534      Node n1 = nn(1, -10, -10);
    535      Node n2 = nn(2, -5, -10);
    536      Node n3 = nn(3, -1, -14);
    537      Way from = nw(1, n1, n2);
    538      Way to = nw(2, n2, n3);
    539 
    540      double a = TurnRestrictionBuilder.intersectionAngle(from, to);
    541      assertEquals(-45, Math.toDegrees(a), 1e-7);
    542 
    543      /*
    544       * if reversed from, the intersection angle is still -45
    545       */
    546      from = nw(1, n2, n1);
    547      to = nw(2, n2, n3);
    548      a = TurnRestrictionBuilder.intersectionAngle(from, to);
    549      assertEquals(-45, Math.toDegrees(a), 1e-7);
    550 
    551      /*
    552      * if reversed to, the intersection angle is still -45
     468     *           ^
     469     *           |
     470     *           | from
     471     *           |
     472     *       (-10,-10) n1
    553473     */
    554      from = nw(1, n1, n2);
    555      to = nw(2, n3, n2);
    556      a = TurnRestrictionBuilder.intersectionAngle(from, to);
    557      assertEquals(-45, Math.toDegrees(a), 1e-7);
    558 
    559      /*
    560      * if reversed both, the intersection angle is still 45
     474    @Test
     475    void testIntersectionAngle3() {
     476        Node n1 = nn(1, -10, -10);
     477        Node n2 = nn(2, -5, -10);
     478        Node n3 = nn(3, -1, -6);
     479        Way from = nw(1, n1, n2);
     480        Way to = nw(2, n2, n3);
     481
     482        double a = TurnRestrictionBuilder.intersectionAngle(from, to);
     483        assertEquals(45, Math.toDegrees(a), 1e-7);
     484
     485        /*
     486         * if reversed from, the intersection angle is still 45
     487         */
     488        from = nw(1, n2, n1);
     489        to = nw(2, n2, n3);
     490        a = TurnRestrictionBuilder.intersectionAngle(from, to);
     491        assertEquals(45, Math.toDegrees(a), 1e-7);
     492
     493        /*
     494        * if reversed to, the intersection angle is still 45
     495        */
     496        from = nw(1, n1, n2);
     497        to = nw(2, n3, n2);
     498        a = TurnRestrictionBuilder.intersectionAngle(from, to);
     499        assertEquals(45, Math.toDegrees(a), 1e-7);
     500
     501        /*
     502        * if reversed both, the intersection angle is still 45
     503        */
     504        from = nw(1, n2, n1);
     505        to = nw(2, n3, n2);
     506        a = TurnRestrictionBuilder.intersectionAngle(from, to);
     507        assertEquals(45, Math.toDegrees(a), 1e-7);
     508    }
     509
     510    /**
     511     *
     512     *
     513     *         (-1,-14) (n3)
     514     *            ^
     515     *            \
     516     *             \ to
     517     *              \
     518     *          (-5, -10) n2
     519     *               ^
     520     *               |
     521     *               | from
     522     *               |
     523     *           (-10,-10) n1
    561524     */
    562      from = nw(1, n2, n1);
    563      to = nw(2, n3, n2);
    564      a = TurnRestrictionBuilder.intersectionAngle(from, to);
    565      assertEquals(-45, Math.toDegrees(a), 1e-7);
    566  }
    567 
    568 
    569      /*
     525    @Test
     526    void testIntersectionAngle4() {
     527        Node n1 = nn(1, -10, -10);
     528        Node n2 = nn(2, -5, -10);
     529        Node n3 = nn(3, -1, -14);
     530        Way from = nw(1, n1, n2);
     531        Way to = nw(2, n2, n3);
     532
     533        double a = TurnRestrictionBuilder.intersectionAngle(from, to);
     534        assertEquals(-45, Math.toDegrees(a), 1e-7);
     535
     536        /*
     537         * if reversed from, the intersection angle is still -45
     538         */
     539        from = nw(1, n2, n1);
     540        to = nw(2, n2, n3);
     541        a = TurnRestrictionBuilder.intersectionAngle(from, to);
     542        assertEquals(-45, Math.toDegrees(a), 1e-7);
     543
     544        /*
     545        * if reversed to, the intersection angle is still -45
     546        */
     547        from = nw(1, n1, n2);
     548        to = nw(2, n3, n2);
     549        a = TurnRestrictionBuilder.intersectionAngle(from, to);
     550        assertEquals(-45, Math.toDegrees(a), 1e-7);
     551
     552        /*
     553        * if reversed both, the intersection angle is still 45
     554        */
     555        from = nw(1, n2, n1);
     556        to = nw(2, n3, n2);
     557        a = TurnRestrictionBuilder.intersectionAngle(from, to);
     558        assertEquals(-45, Math.toDegrees(a), 1e-7);
     559    }
     560
     561    /**
    570562     *
    571563     *      n21        w21        n22       w22            n23
     
    579571     */
    580572    @Test
    581     public void splitToWay() {
     573    void testSplitToWay() {
    582574        Node n11 = new Node(11);
    583575        n11.setCoor(new LatLon(5, 15));
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/AllEditorTests.java

    r32519 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    33
    4 import org.junit.runner.RunWith;
    5 import org.junit.runners.Suite;
     4import org.junit.platform.suite.api.SelectClasses;
    65
    76import junit.framework.TestCase;
     7import org.junit.platform.suite.api.Suite;
    88
    9 @RunWith(Suite.class)
    10 @Suite.SuiteClasses({
     9@Suite
     10@SelectClasses({
    1111    JosmSelectionListModelTest.class,
    1212    TurnRestrictionEditorModelUnitTest.class,
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/BasicEditorPanelTest.java

    r32519 r36064  
    77import javax.swing.JFrame;
    88
    9 import org.junit.Ignore;
     9import org.junit.jupiter.api.Disabled;
    1010import org.openstreetmap.josm.data.osm.DataSet;
    1111import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    1515 *
    1616 */
    17 @Ignore("no test")
     17@Disabled("no test")
    1818public class BasicEditorPanelTest extends JFrame {
    1919
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/ExceptValueModelTest.java

    r32925 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertAll;
     5import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
     6import static org.junit.jupiter.api.Assertions.assertEquals;
     7import static org.junit.jupiter.api.Assertions.assertFalse;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    79
    8 import org.junit.Test;
     10import org.junit.jupiter.api.Test;
     11import org.junit.jupiter.params.ParameterizedTest;
     12import org.junit.jupiter.params.provider.ValueSource;
    913
    10 public class ExceptValueModelTest {
     14class ExceptValueModelTest {
    1115
    12     @Test
    13     public void testConstructors() {
    14         new ExceptValueModel();
    15         new ExceptValueModel(null);
    16         new ExceptValueModel("");
    17         new ExceptValueModel("  ");
    18         new ExceptValueModel("hgv");
    19         new ExceptValueModel("hgv;psv");
    20         new ExceptValueModel("non_standard");
     16    @ParameterizedTest
     17    @ValueSource(strings = {"", "  ", "hgv", "hgv;psv", "non_standard"})
     18    void testStringConstructors(String value) {
     19        assertDoesNotThrow(() -> new ExceptValueModel(value));
    2120    }
    2221
    2322    @Test
    24     public void testSetValue() {
     23    void testAdditionalConstructors() {
     24        assertAll(() -> assertDoesNotThrow(() -> new ExceptValueModel()),
     25                () -> assertDoesNotThrow(() -> new ExceptValueModel(null)));
     26    }
     27
     28    @Test
     29    void testSetValue() {
    2530        ExceptValueModel evm;
    2631
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionListModelTest.java

    r33847 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertNotNull;
     7import static org.junit.jupiter.api.Assertions.assertThrows;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    79
    810import java.util.ArrayList;
     
    1416import javax.swing.ListSelectionModel;
    1517
    16 import org.junit.Rule;
    17 import org.junit.Test;
     18import org.junit.jupiter.api.Test;
    1819import org.openstreetmap.josm.data.coor.LatLon;
    1920import org.openstreetmap.josm.data.osm.DataSet;
     
    2425import org.openstreetmap.josm.gui.MainApplication;
    2526import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    26 import org.openstreetmap.josm.testutils.JOSMTestRules;
     27import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2728
    2829/**
    2930 * Unit test for {@see JosmSelctionListModel}
    3031 */
    31 public class JosmSelectionListModelTest {
    32 
    33     @Rule
    34     public JOSMTestRules rules = new JOSMTestRules().preferences();
     32@BasicPreferences
     33class JosmSelectionListModelTest {
    3534
    3635    @Test
    37     public void testConstructor() {
    38         assertNotNull(new JosmSelectionListModel(new OsmDataLayer(new DataSet(), "test", null)));
    39     }
    40 
    41     @Test(expected = IllegalArgumentException.class)
    42     public void testConstructorNull() {
    43         new JosmSelectionListModel(null);
     36    void testConstructor() {
     37        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "test", null);
     38        assertDoesNotThrow(() -> new JosmSelectionListModel(layer));
    4439    }
    4540
    4641    @Test
    47     public void test_setJOSMSelection() {
     42    void testConstructorNull() {
     43        assertThrows(IllegalArgumentException.class, () -> new JosmSelectionListModel(null));
     44    }
     45
     46    @Test
     47    void testSetJOSMSelection() {
    4848        DataSet ds = new DataSet();
    4949        OsmDataLayer layer = new OsmDataLayer(ds, "test", null);
     
    6666
    6767    @Test
    68     public void test_setJOSMSelection_withSelected() {
     68    void testSetJOSMSelectionWithSelected() {
    6969        DataSet ds = new DataSet();
    7070        OsmDataLayer layer = new OsmDataLayer(ds, "test", null);
     
    8484
    8585    @Test
    86     public void test_getSelected() {
     86    void testGetSelected() {
    8787        DataSet ds = new DataSet();
    8888        OsmDataLayer layer = new OsmDataLayer(ds, "test", null);
     
    105105
    106106    @Test
    107     public void test_setSelected() {
     107    void testSetSelected() {
    108108        // set selected with null is OK - nothing selected thereafter
    109109        JosmSelectionListModel model = new JosmSelectionListModel(new OsmDataLayer(new DataSet(), "test", null));
     
    118118        List<OsmPrimitive> objects = (Arrays.asList(new Node(new LatLon(1, 1)), new Way(), new Relation()));
    119119        model.setJOSMSelection(objects);
    120         model.setSelected(Arrays.asList(objects.get(0)));
     120        model.setSelected(Collections.singletonList(objects.get(0)));
    121121        assertEquals(Collections.singleton(objects.get(0)), model.getSelected());
    122122
    123123        // select an object not-existing in the list of displayed objects
    124124        model.setJOSMSelection(objects);
    125         model.setSelected(Arrays.asList(new Way()));
     125        model.setSelected(Collections.singletonList(new Way()));
    126126        assertTrue(model.getSelected().isEmpty());
    127127    }
    128128
    129129    @Test
    130     public void test_editLayerChanged() {
     130    void testEditLayerChanged() {
    131131        DataSet ds = new DataSet();
    132132
    133133        List<OsmPrimitive> objects = (Arrays.asList(new Node(new LatLon(1, 1)), new Way(), new Relation()));
    134         objects.stream().forEach(ds::addPrimitive);
     134        objects.forEach(ds::addPrimitive);
    135135
    136136        OsmDataLayer layer1 = new OsmDataLayer(ds, "layer1", null);
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionComboBoxTest.java

    r32519 r36064  
    88import javax.swing.JFrame;
    99
    10 import org.junit.Ignore;
     10import org.junit.jupiter.api.Disabled;
    1111import org.openstreetmap.josm.data.osm.DataSet;
    1212import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    1717 *
    1818 */
    19 @Ignore("no test")
     19@Disabled("no test")
    2020public class TurnRestrictionComboBoxTest extends JFrame {
    2121
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorModelUnitTest.java

    r32925 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertTrue;
    7 import static org.junit.Assert.fail;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
     8import static org.junit.jupiter.api.Assertions.fail;
    89import static org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionLegRole.FROM;
    910import static org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionLegRole.TO;
     
    1314import java.util.Collections;
    1415
    15 import org.junit.Before;
    16 import org.junit.Rule;
    17 import org.junit.Test;
     16import org.junit.jupiter.api.BeforeEach;
     17import org.junit.jupiter.api.Test;
    1818import org.openstreetmap.josm.data.coor.LatLon;
    1919import org.openstreetmap.josm.data.osm.DataSet;
     
    2121import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2222import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     23import org.openstreetmap.josm.data.osm.PrimitiveId;
    2324import org.openstreetmap.josm.data.osm.Relation;
    2425import org.openstreetmap.josm.data.osm.RelationMember;
     
    2627import org.openstreetmap.josm.data.osm.Way;
    2728import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    28 import org.openstreetmap.josm.testutils.JOSMTestRules;
     29import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2930
    3031/**
    3132 * This is a unit test for {@link TurnRestrictionEditorModel}
    3233 */
    33 public class TurnRestrictionEditorModelUnitTest {
    34 
    35     @Rule
    36     public JOSMTestRules rules = new JOSMTestRules().preferences();
     34@BasicPreferences
     35class TurnRestrictionEditorModelUnitTest {
    3736
    3837    private final NavigationControler navigationControlerMock = new NavigationControler() {
     
    114113    }
    115114
    116     @Before
     115    @BeforeEach
    117116    public void setUp() {
    118117        ds = new DataSet();
     
    124123     * Test the constructor
    125124     */
    126     @Test(expected = IllegalArgumentException.class)
    127     public void testConstructor1() {
    128         new TurnRestrictionEditorModel(null, navigationControlerMock);
     125    @Test
     126    void testConstructor1() {
     127        assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionEditorModel(null, navigationControlerMock));
    129128    }
    130129
     
    132131     * Test the constructor
    133132     */
    134     @Test(expected = IllegalArgumentException.class)
    135     public void testConstructor2() {
    136         new TurnRestrictionEditorModel(layer, null);
    137     }
    138 
    139     @Test
    140     public void testPopulateEmptyTurnRestriction() {
     133    @Test
     134    void testConstructor2() {
     135        assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionEditorModel(layer, null));
     136    }
     137
     138    @Test
     139    void testPopulateEmptyTurnRestriction() {
    141140        // an "empty" turn restriction with a public id
    142141        Relation r = new Relation(1);
     
    156155     */
    157156    @Test
    158     public void test_populate_SimpleStandardTurnRestriction() {
     157    void testPopulateSimpleStandardTurnRestriction() {
    159158        buildDataSet1();
    160159        model.populate(rel(1));
     
    162161        assertEquals(Collections.singleton(way(2)), model.getTurnRestrictionLeg(FROM));
    163162        assertEquals(Collections.singleton(way(3)), model.getTurnRestrictionLeg(TO));
    164         assertEquals(Arrays.asList(node(22)), model.getVias());
     163        assertEquals(Collections.singletonList(node(22)), model.getVias());
    165164        assertEquals("no_left_turn", model.getRestrictionTagValue());
    166165        assertEquals("", model.getExcept().getValue());
     
    168167
    169168    @Test
    170     public void setFrom() {
     169    void testSetFrom() {
    171170        buildDataSet1();
    172171        model.populate(rel(1));
     
    178177        // set another way as from
    179178        model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, way(4).getPrimitiveId());
    180         assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(TurnRestrictionLegRole.FROM));
     179        assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(FROM));
    181180
    182181        // delete the/all members with role 'from'
    183182        model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, null);
    184         assertTrue(model.getTurnRestrictionLeg(TurnRestrictionLegRole.FROM).isEmpty());
    185 
    186         try {
    187             // can't add a node as 'from'
    188             model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, node(21).getPrimitiveId());
    189             fail();
    190         } catch (IllegalArgumentException e) {
    191             // OK
    192             System.out.println(e.getMessage());
    193         }
    194 
    195         try {
    196             // can't set a way as 'from' if it isn't part of the dataset
    197             model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, new Way().getPrimitiveId());
    198             fail();
    199         } catch (IllegalStateException e) {
    200             // OK
    201             System.out.println(e.getMessage());
    202         }
    203     }
    204 
    205     @Test
    206     public void setTo() {
     183        assertTrue(model.getTurnRestrictionLeg(FROM).isEmpty());
     184
     185        // can't add a node as 'from'
     186        PrimitiveId node = node(21).getPrimitiveId();
     187        assertThrows(IllegalArgumentException.class,
     188                () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, node));
     189
     190        // can't set a way as 'from' if it isn't part of the dataset
     191        PrimitiveId way = new Way().getPrimitiveId();
     192        assertThrows(IllegalStateException.class, () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, way));
     193    }
     194
     195    @Test
     196    void setTo() {
    207197        buildDataSet1();
    208198        model.populate(rel(1));
     
    214204        // set another way as from
    215205        model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, way(4).getPrimitiveId());
    216         assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(TurnRestrictionLegRole.TO));
     206        assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(TO));
    217207
    218208        // delete the/all members with role 'from'
    219209        model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, null);
    220         assertTrue(model.getTurnRestrictionLeg(TurnRestrictionLegRole.TO).isEmpty());
    221 
    222         try {
    223             // can't add a node as 'from'
    224             model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, node(21).getPrimitiveId());
    225             fail();
    226         } catch (IllegalArgumentException e) {
    227             // OK
    228             System.out.println(e.getMessage());
    229         }
    230 
    231         try {
    232             // can't set a way as 'from' if it isn't part of the dataset
    233             model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, new Way().getPrimitiveId());
    234             fail();
    235         } catch (IllegalStateException e) {
    236             // OK
    237             System.out.println(e.getMessage());
    238         }
     210        assertTrue(model.getTurnRestrictionLeg(TO).isEmpty());
     211
     212        PrimitiveId node = node(21).getPrimitiveId();
     213        assertThrows(IllegalArgumentException.class, () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, node));
     214
     215        PrimitiveId way = new Way().getPrimitiveId();
     216        assertThrows(IllegalStateException.class, () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, way));
    239217    }
    240218
     
    269247
    270248        // one node as via - OK
    271         model.setVias(Arrays.asList(node(22)));
    272         assertEquals(Arrays.asList(node(22)), model.getVias());
     249        model.setVias(Collections.singletonList(node(22)));
     250        assertEquals(Collections.singletonList(node(22)), model.getVias());
    273251
    274252        // pass in null as vias -> remove all vias
     
    291269        // null values in the list of vias are skipped
    292270        model.setVias(Arrays.asList(null, node(22)));
    293         assertEquals(Arrays.asList(node(22)), model.getVias());
     271        assertEquals(Collections.singletonList(node(22)), model.getVias());
    294272
    295273        try {
    296274            // an object which doesn't belong to the same dataset can't be a via
    297             model.setVias(Arrays.asList(new Node(LatLon.ZERO)));
     275            model.setVias(Collections.singletonList(new Node(LatLon.ZERO)));
    298276            fail();
    299277        } catch (IllegalArgumentException e) {
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorTest.java

    r32519 r36064  
    44import javax.swing.JFrame;
    55
    6 import org.junit.Ignore;
     6import org.junit.jupiter.api.Disabled;
    77import org.openstreetmap.josm.data.osm.DataSet;
    88import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    1111 *
    1212 */
    13 @Ignore("no test")
     13@Disabled("no test")
    1414public class TurnRestrictionEditorTest extends JFrame {
    1515
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditorTest.java

    r34148 r36064  
    1717import javax.swing.JScrollPane;
    1818
    19 import org.junit.Ignore;
     19import org.junit.jupiter.api.Disabled;
    2020import org.openstreetmap.josm.data.coor.LatLon;
    2121import org.openstreetmap.josm.data.osm.DataSet;
     
    3434 * {@see TurnRestrictionLegEditor}
    3535 */
    36 @Ignore("no test")
     36@Disabled("no test")
    3737public class TurnRestrictionLegEditorTest extends JFrame {
    3838
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditorUnitTest.java

    r32925 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    33
    4 import static org.junit.Assert.assertEquals;
    54
    6 import org.junit.Before;
    7 import org.junit.Rule;
    8 import org.junit.Test;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
     7
     8import org.junit.jupiter.api.BeforeEach;
     9import org.junit.jupiter.api.Test;
    910import org.openstreetmap.josm.data.osm.DataSet;
    1011import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    11 import org.openstreetmap.josm.testutils.JOSMTestRules;
     12import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1213
    1314/**
    1415 * Unit test for the {@link TurnRestrictionLegEditor}
    1516 */
    16 public class TurnRestrictionLegEditorUnitTest {
    17 
    18     @Rule
    19     public JOSMTestRules rules = new JOSMTestRules().preferences();
    20 
     17@BasicPreferences
     18class TurnRestrictionLegEditorUnitTest {
    2119    private DataSet ds;
    2220    private OsmDataLayer layer;
    2321    private TurnRestrictionEditorModel model;
    2422
    25     @Before
     23    @BeforeEach
    2624    public void setUp() {
    2725        ds = new DataSet();
     
    4341
    4442    @Test
    45     public void testConstructor1() {
     43    void testConstructor1() {
    4644        TurnRestrictionLegEditor editor = new TurnRestrictionLegEditor(model, TurnRestrictionLegRole.FROM);
    4745        assertEquals(model, editor.getModel());
     
    4947    }
    5048
    51     @Test(expected = IllegalArgumentException.class)
    52     public void testConstructor2() {
    53         new TurnRestrictionLegEditor(null, TurnRestrictionLegRole.FROM);
     49    @Test
     50    void testConstructor2() {
     51        assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionLegEditor(null, TurnRestrictionLegRole.FROM));
    5452    }
    5553
    56     @Test(expected = IllegalArgumentException.class)
    57     public void testConstructor3() {
    58         new TurnRestrictionLegEditor(model, null);
     54    @Test
     55    void testConstructor3() {
     56        assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionLegEditor(model, null));
    5957    }
    6058}
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionTypeRendererTest.java

    r32925 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertNull;
    77
    88import javax.swing.JLabel;
    99
    10 import org.junit.Rule;
    11 import org.junit.Test;
    12 import org.openstreetmap.josm.testutils.JOSMTestRules;
     10import org.junit.jupiter.api.Test;
     11import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1312
    14 public class TurnRestrictionTypeRendererTest {
    15 
    16     @Rule
    17     public JOSMTestRules rules = new JOSMTestRules().preferences();
    18 
     13@BasicPreferences
     14class TurnRestrictionTypeRendererTest {
    1915    @Test
    20     public void test_Constructor() {
     16    void testConstructor() {
    2117        TurnRestrictionTypeRenderer renderer = new TurnRestrictionTypeRenderer();
    2218
     
    2622
    2723    @Test
    28     public void test_getListCellRendererComponent_1() {
     24    void testGetListCellRendererComponent1() {
    2925        TurnRestrictionTypeRenderer renderer = new TurnRestrictionTypeRenderer();
    3026
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionTypeTest.java

    r32925 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNull;
    66
    7 import org.junit.Test;
     7import org.junit.jupiter.api.Test;
    88
    9 public class TurnRestrictionTypeTest {
     9
     10class TurnRestrictionTypeTest {
    1011
    1112    @Test
    12     public void test_fromTagValue() {
     13    void testFromTagValue() {
    1314
    1415        TurnRestrictionType type = TurnRestrictionType.fromTagValue("no_left_turn");
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/VehicleExceptionEditorTest.java

    r32519 r36064  
    77import javax.swing.JFrame;
    88
    9 import org.junit.Ignore;
     9import org.junit.jupiter.api.Disabled;
    1010import org.openstreetmap.josm.data.osm.DataSet;
    1111import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    1616 *
    1717 */
    18 @Ignore("no test")
     18@Disabled("no test")
    1919public class VehicleExceptionEditorTest extends JFrame {
    2020    TurnRestrictionEditorModel model;
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/ViaListTest.java

    r32519 r36064  
    1111import javax.swing.JList;
    1212
    13 import org.junit.Ignore;
     13import org.junit.jupiter.api.Disabled;
    1414import org.openstreetmap.josm.data.coor.LatLon;
    1515import org.openstreetmap.josm.data.osm.DataSet;
     
    2323 *
    2424 */
    25 @Ignore("no test")
     25@Disabled("no test")
    2626public class ViaListTest extends JFrame {
    2727
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/qa/IssuesViewTest.java

    r32519 r36064  
    1111import javax.swing.JScrollPane;
    1212
    13 import org.junit.Ignore;
     13import org.junit.jupiter.api.Disabled;
    1414import org.openstreetmap.josm.data.osm.DataSet;
    1515import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    2020 * Simple test application for layout and functionality of the issues view.
    2121 */
    22 @Ignore("no test")
     22@Disabled("no test")
    2323public class IssuesViewTest extends JFrame {
    2424    private IssuesModel model;
Note: See TracChangeset for help on using the changeset viewer.