Skip to content

Commit 6e7aee0

Browse files
committed
use expectThrows instead of manually testing exception
1 parent d97750b commit 6e7aee0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,11 @@ public void testInvalidHostType() throws InterruptedException {
197197
Settings nodeSettings = Settings.builder()
198198
.put(DISCOVERY_EC2.HOST_TYPE_SETTING.getKey(), "does_not_exist")
199199
.build();
200-
try {
200+
201+
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> {
201202
buildDynamicNodes(nodeSettings, 1);
202-
fail("Expected IllegalArgumentException");
203-
} catch (IllegalArgumentException e) {
204-
assertThat(e.getMessage(), containsString("does_not_exist is unknown for discovery.ec2.host_type"));
205-
}
203+
});
204+
assertThat(exception.getMessage(), containsString("does_not_exist is unknown for discovery.ec2.host_type"));
206205
}
207206

208207
public void testFilterByTags() throws InterruptedException {

0 commit comments

Comments
 (0)