Skip to content

Commit 918945c

Browse files
author
taylor.smock
committed
Fix some test issues (from order) and clean up some try blocks
git-svn-id: https://josm.openstreetmap.de/svn/trunk@19428 0c6e7542-c601-0410-84e7-c038aed88b3b
1 parent b73a1f8 commit 918945c

File tree

5 files changed

+14
-26
lines changed

5 files changed

+14
-26
lines changed

test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static com.github.tomakehurst.wiremock.client.WireMock.get;
66
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
77
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
import static org.junit.jupiter.api.Assertions.assertThrows;
89
import static org.junit.jupiter.api.Assertions.assertTrue;
910

1011
import java.util.Arrays;
@@ -99,11 +100,9 @@ void testActionPerformedEnabledWms(WireMockRuntimeInfo wireMockRuntimeInfo) {
99100
@Test
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
}
109108

test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.openstreetmap.josm.testutils.annotations.Main;
3333
import org.openstreetmap.josm.testutils.annotations.MapPaintStyles;
3434
import org.openstreetmap.josm.testutils.annotations.Projection;
35+
import org.openstreetmap.josm.testutils.annotations.Territories;
3536
import org.openstreetmap.josm.tools.Pair;
3637
import org.openstreetmap.josm.tools.SubclassFilteredCollection;
3738

@@ -42,6 +43,7 @@
4243
@Main
4344
@MapPaintStyles
4445
@Projection
46+
@Territories(Territories.Initialize.ALL)
4547
class CreateMultipolygonActionTest {
4648
private static Map<String, String> getRefToRoleMap(Relation relation) {
4749
Map<String, String> refToRole = new TreeMap<>();

test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
3838
import org.openstreetmap.josm.testutils.annotations.Main;
3939
import org.openstreetmap.josm.testutils.annotations.Projection;
40+
import org.openstreetmap.josm.testutils.annotations.Territories;
4041
import org.openstreetmap.josm.tools.MultiMap;
4142
import org.openstreetmap.josm.tools.Utils;
4243

@@ -46,6 +47,7 @@
4647
@BasicPreferences
4748
@Main
4849
@Projection
50+
@Territories
4951
class JoinAreasActionTest {
5052
/**
5153
* Non-regression test for bug #9599.

test/unit/org/openstreetmap/josm/actions/JoinNodeWayActionTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
2929
import org.openstreetmap.josm.testutils.annotations.Main;
3030
import org.openstreetmap.josm.testutils.annotations.Projection;
31+
import org.openstreetmap.josm.testutils.annotations.Territories;
3132
import org.openstreetmap.josm.tools.Geometry;
3233

3334
/**
@@ -36,6 +37,7 @@
3637
@BasicPreferences
3738
@Main
3839
@Projection
40+
@Territories(Territories.Initialize.ALL)
3941
final class JoinNodeWayActionTest {
4042
private void setupMapView(DataSet ds) {
4143
// setup a reasonable size for the edit window

test/unit/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeItemTest.java

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import static org.junit.jupiter.api.Assertions.assertEquals;
55
import static org.junit.jupiter.api.Assertions.assertNull;
6+
import static org.junit.jupiter.api.Assertions.assertThrows;
67
import static org.junit.jupiter.api.Assertions.fail;
78

89
import org.openstreetmap.josm.data.osm.Node;
@@ -80,13 +81,7 @@ void testDecide() {
8081
@Test
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

9287
@Test
@@ -127,25 +122,13 @@ void testApplyToMyPrimitive3() {
127122

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

139128
@Test
140129
void testApplyToMyPrimitive4() {
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
}

0 commit comments

Comments
 (0)