Use expectThrows in JsonSettingsLoaderTests
This commit refactors the unit tests in JsonSettingsLoaderTests to use exceptThrows for simplification.
This commit is contained in:
parent
7841b439ec
commit
f9500b1d6a
|
@ -49,22 +49,16 @@ public class JsonSettingsLoaderTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testDuplicateKeysThrowsException() {
|
||||
String json = "{\"foo\":\"bar\",\"foo\":\"baz\"}";
|
||||
try {
|
||||
settingsBuilder()
|
||||
.loadFromSource(json)
|
||||
.build();
|
||||
fail("expected exception");
|
||||
} catch (SettingsException e) {
|
||||
assertEquals(e.getCause().getClass(), ElasticsearchParseException.class);
|
||||
assertThat(
|
||||
e.toString(),
|
||||
containsString("duplicate settings key [foo] " +
|
||||
"found at line number [1], " +
|
||||
"column number [20], " +
|
||||
"previous value [bar], " +
|
||||
"current value [baz]"));
|
||||
}
|
||||
final String json = "{\"foo\":\"bar\",\"foo\":\"baz\"}";
|
||||
final SettingsException e = expectThrows(SettingsException.class, () -> settingsBuilder().loadFromSource(json).build());
|
||||
assertEquals(e.getCause().getClass(), ElasticsearchParseException.class);
|
||||
assertThat(
|
||||
e.toString(),
|
||||
containsString("duplicate settings key [foo] " +
|
||||
"found at line number [1], " +
|
||||
"column number [20], " +
|
||||
"previous value [bar], " +
|
||||
"current value [baz]"));
|
||||
}
|
||||
|
||||
public void testNullValuedSettingThrowsException() {
|
||||
|
|
Loading…
Reference in New Issue