|
18 | 18 |
|
19 | 19 | import java.util.Collections; |
20 | 20 | import java.util.HashMap; |
21 | | -import java.util.List; |
22 | 21 | import java.util.Map; |
23 | 22 |
|
24 | 23 | import static java.util.Collections.emptyList; |
|
28 | 27 | public class ConfigTests extends ESTestCase { |
29 | 28 |
|
30 | 29 | public void testEmptyField() { |
31 | | - final String field = randomBoolean() ? "" : null; |
32 | | - Exception e = expectThrows(IllegalArgumentException.class, () -> new MetricConfig(field, singletonList("max"))); |
| 30 | + Exception e = expectThrows(IllegalArgumentException.class, () -> new MetricConfig(null, singletonList("max"))); |
| 31 | + assertThat(e.getMessage(), equalTo("Field must be a non-null, non-empty string")); |
| 32 | + |
| 33 | + e = expectThrows(IllegalArgumentException.class, () -> new MetricConfig("", singletonList("max"))); |
33 | 34 | assertThat(e.getMessage(), equalTo("Field must be a non-null, non-empty string")); |
34 | 35 | } |
35 | 36 |
|
36 | 37 | public void testEmptyMetrics() { |
37 | | - final List<String> metrics = randomBoolean() ? emptyList() : null; |
38 | | - Exception e = expectThrows(IllegalArgumentException.class, () -> new MetricConfig("foo", metrics)); |
| 38 | + Exception e = expectThrows(IllegalArgumentException.class, () -> new MetricConfig("foo", emptyList())); |
| 39 | + assertThat(e.getMessage(), equalTo("Metrics must be a non-null, non-empty array of strings")); |
| 40 | + |
| 41 | + e = expectThrows(IllegalArgumentException.class, () -> new MetricConfig("foo", null)); |
39 | 42 | assertThat(e.getMessage(), equalTo("Metrics must be a non-null, non-empty array of strings")); |
40 | 43 | } |
41 | 44 |
|
|
0 commit comments