Test: Extended malformed test to also check if the strict alert mapping in the template is active.

Original commit: elastic/x-pack-elasticsearch@dfcad46f94
This commit is contained in:
Martijn van Groningen 2014-11-12 21:27:48 +01:00
parent 4d581876bd
commit e0741997d0
1 changed files with 17 additions and 4 deletions

View File

@ -86,7 +86,7 @@ public class BasicAlertingTest extends AbstractAlertingTests {
assertFalse(deleteAlertResponse.deleteResponse().isFound()); assertFalse(deleteAlertResponse.deleteResponse().isFound());
} }
@Test(expected = ElasticsearchIllegalArgumentException.class) @Test
public void testMalformedAlert() throws Exception { public void testMalformedAlert() throws Exception {
AlertsClientInterface alertsClient = alertClient(); AlertsClientInterface alertsClient = alertClient();
createIndex("my-index"); createIndex("my-index");
@ -98,8 +98,21 @@ public class BasicAlertingTest extends AbstractAlertingTests {
.field("enable", true) .field("enable", true)
.field("malformed_field", "x") .field("malformed_field", "x")
.endObject().bytes(); .endObject().bytes();
alertsClient.prepareIndexAlert("my-first-alert") try {
.setAlertSource(alertSource) alertsClient.prepareIndexAlert("my-first-alert")
.get(); .setAlertSource(alertSource)
.get();
fail();
} catch (ElasticsearchIllegalArgumentException e) {
// In AlertStore we fail parsing if an alert contains undefined fields.
}
try {
client().prepareIndex(AlertsStore.ALERT_INDEX, AlertsStore.ALERT_TYPE, "my-first-alert")
.setSource(alertSource)
.get();
fail();
} catch (Exception e) {
// The alert index template the mapping is defined as strict
}
} }
} }