Ignore:
Timestamp:
2025-07-13T20:19:41+02:00 (4 months ago)
Author:
taylor.smock
Message:

Fix some test issues (from order) and clean up some try blocks

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java

    r19292 r19428  
    66import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
    77import static org.junit.jupiter.api.Assertions.assertEquals;
     8import static org.junit.jupiter.api.Assertions.assertThrows;
    89import static org.junit.jupiter.api.Assertions.assertTrue;
    910
     
    100101    void testActionPerformedDisabled() {
    101102        assertTrue(MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty());
    102         try {
    103             new AddImageryLayerAction(new ImageryInfo("foo")).actionPerformed(null);
    104         } catch (IllegalArgumentException expected) {
    105             assertEquals("Parameter 'info.url' must not be null", expected.getMessage());
    106         }
     103        final AddImageryLayerAction action = new AddImageryLayerAction(new ImageryInfo("foo"));
     104        IllegalArgumentException expected = assertThrows(IllegalArgumentException.class, () -> action.actionPerformed(null));
     105        assertEquals("Parameter 'info.url' must not be null", expected.getMessage());
    107106        assertTrue(MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty());
    108107    }
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java

    r19066 r19428  
    3333import org.openstreetmap.josm.testutils.annotations.MapPaintStyles;
    3434import org.openstreetmap.josm.testutils.annotations.Projection;
     35import org.openstreetmap.josm.testutils.annotations.Territories;
    3536import org.openstreetmap.josm.tools.Pair;
    3637import org.openstreetmap.josm.tools.SubclassFilteredCollection;
     
    4344@MapPaintStyles
    4445@Projection
     46@Territories(Territories.Initialize.ALL)
    4547class CreateMultipolygonActionTest {
    4648    private static Map<String, String> getRefToRoleMap(Relation relation) {
  • trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java

    r19078 r19428  
    3838import org.openstreetmap.josm.testutils.annotations.Main;
    3939import org.openstreetmap.josm.testutils.annotations.Projection;
     40import org.openstreetmap.josm.testutils.annotations.Territories;
    4041import org.openstreetmap.josm.tools.MultiMap;
    4142import org.openstreetmap.josm.tools.Utils;
     
    4748@Main
    4849@Projection
     50@Territories
    4951class JoinAreasActionTest {
    5052    /**
  • trunk/test/unit/org/openstreetmap/josm/actions/JoinNodeWayActionTest.java

    r18870 r19428  
    2929import org.openstreetmap.josm.testutils.annotations.Main;
    3030import org.openstreetmap.josm.testutils.annotations.Projection;
     31import org.openstreetmap.josm.testutils.annotations.Territories;
    3132import org.openstreetmap.josm.tools.Geometry;
    3233
     
    3738@Main
    3839@Projection
     40@Territories(Territories.Initialize.ALL)
    3941final class JoinNodeWayActionTest {
    4042    private void setupMapView(DataSet ds) {
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeItemTest.java

    r18037 r19428  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertNull;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    67import static org.junit.jupiter.api.Assertions.fail;
    78
     
    8182    void testDecide1() {
    8283        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
    83         try {
    84             item.decide(null);
    85             fail("expected IllegalArgumentException not thrown");
    86         } catch (IllegalArgumentException e) {
    87             // OK
    88             Logging.trace(e);
    89         }
     84        assertThrows(IllegalArgumentException.class, () -> item.decide(null));
    9085    }
    9186
     
    128123        Node n1 = new Node(1);
    129124        n1.put("key", "oldvalue");
    130         try {
    131             item.applyToMyPrimitive(n1);
    132             fail("expected IllegalStateException");
    133         } catch (IllegalStateException e) {
    134             // OK
    135             Logging.trace(e);
    136         }
     125        assertThrows(IllegalStateException.class, () -> item.applyToMyPrimitive(n1));
    137126    }
    138127
     
    141130        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
    142131
    143         try {
    144             item.applyToMyPrimitive(null);
    145             fail("expected IllegalArgumentException");
    146         } catch (IllegalArgumentException e) {
    147             // OK
    148             Logging.trace(e);
    149         }
     132        assertThrows(IllegalArgumentException.class, () -> item.applyToMyPrimitive(null));
    150133    }
    151134}
Note: See TracChangeset for help on using the changeset viewer.