use expectThrows instead of manually testing exception
This commit is contained in:
parent
d97750b52c
commit
6e7aee0c5a
|
@ -197,12 +197,11 @@ public class Ec2DiscoveryTests extends ESTestCase {
|
||||||
Settings nodeSettings = Settings.builder()
|
Settings nodeSettings = Settings.builder()
|
||||||
.put(DISCOVERY_EC2.HOST_TYPE_SETTING.getKey(), "does_not_exist")
|
.put(DISCOVERY_EC2.HOST_TYPE_SETTING.getKey(), "does_not_exist")
|
||||||
.build();
|
.build();
|
||||||
try {
|
|
||||||
|
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> {
|
||||||
buildDynamicNodes(nodeSettings, 1);
|
buildDynamicNodes(nodeSettings, 1);
|
||||||
fail("Expected IllegalArgumentException");
|
});
|
||||||
} catch (IllegalArgumentException e) {
|
assertThat(exception.getMessage(), containsString("does_not_exist is unknown for discovery.ec2.host_type"));
|
||||||
assertThat(e.getMessage(), containsString("does_not_exist is unknown for discovery.ec2.host_type"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFilterByTags() throws InterruptedException {
|
public void testFilterByTags() throws InterruptedException {
|
||||||
|
|
Loading…
Reference in New Issue