Address review comments in ES core
Original commit: elastic/x-pack-elasticsearch@925c78d4fe
This commit is contained in:
parent
b7d2ef0160
commit
050a36bb28
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.notification.email.attachment;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
|
@ -116,6 +115,10 @@ public class EmailAttachmentParsersTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatTwoAttachmentsWithTheSameIdThrowError() throws Exception {
|
||||
if (JsonXContent.isStrictDuplicateDetectionEnabled()) {
|
||||
logger.info("Skipping test as it uses a custom duplicate check that is obsolete when strict duplicate checks are enabled.");
|
||||
return;
|
||||
}
|
||||
Map<String, EmailAttachmentParser> parsers = new HashMap<>();
|
||||
parsers.put("test", new TestEmailAttachmentParser());
|
||||
EmailAttachmentsParser parser = new EmailAttachmentsParser(parsers);
|
||||
|
@ -144,8 +147,8 @@ public class EmailAttachmentParsersTests extends ESTestCase {
|
|||
|
||||
parser.parse(xContentParser);
|
||||
fail("Expected parser to fail but did not happen");
|
||||
} catch (JsonParseException e) {
|
||||
assertThat(e.getMessage(), is("Duplicate field 'my-name.json'"));
|
||||
} catch (ElasticsearchParseException e) {
|
||||
assertThat(e.getMessage(), is("Attachment with id [my-name.json] has already been created, must be renamed"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.condition;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -195,6 +194,10 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testParseContainsDuplicateOperator() throws IOException {
|
||||
if (JsonXContent.isStrictDuplicateDetectionEnabled()) {
|
||||
logger.info("Skipping test as it uses a custom duplicate check that is obsolete when strict duplicate checks are enabled.");
|
||||
return;
|
||||
}
|
||||
ArrayCompareCondition.Op op = randomFrom(ArrayCompareCondition.Op.values());
|
||||
ArrayCompareCondition.Quantifier quantifier = randomFrom(ArrayCompareCondition.Quantifier.values());
|
||||
Object value = randomFrom("value", 1, null);
|
||||
|
@ -216,8 +219,8 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
parser.nextToken();
|
||||
|
||||
expectedException.expect(JsonParseException.class);
|
||||
expectedException.expectMessage("Duplicate field '" + op.id() + "'");
|
||||
expectedException.expect(ElasticsearchParseException.class);
|
||||
expectedException.expectMessage("duplicate comparison operator");
|
||||
|
||||
ArrayCompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
||||
}
|
||||
|
@ -246,6 +249,10 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testParseContainsDuplicateValue() throws IOException {
|
||||
if (JsonXContent.isStrictDuplicateDetectionEnabled()) {
|
||||
logger.info("Skipping test as it uses a custom duplicate check that is obsolete when strict duplicate checks are enabled.");
|
||||
return;
|
||||
}
|
||||
ArrayCompareCondition.Op op = randomFrom(ArrayCompareCondition.Op.values());
|
||||
ArrayCompareCondition.Quantifier quantifier = randomFrom(ArrayCompareCondition.Quantifier.values());
|
||||
Object value = randomFrom("value", 1, null);
|
||||
|
@ -264,13 +271,17 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
parser.nextToken();
|
||||
|
||||
expectedException.expect(JsonParseException.class);
|
||||
expectedException.expectMessage("Duplicate field 'value'");
|
||||
expectedException.expect(ElasticsearchParseException.class);
|
||||
expectedException.expectMessage("duplicate field \"value\"");
|
||||
|
||||
ArrayCompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
||||
}
|
||||
|
||||
public void testParseContainsDuplicateQuantifier() throws IOException {
|
||||
if (JsonXContent.isStrictDuplicateDetectionEnabled()) {
|
||||
logger.info("Skipping test as it uses a custom duplicate check that is obsolete when strict duplicate checks are enabled.");
|
||||
return;
|
||||
}
|
||||
ArrayCompareCondition.Op op = randomFrom(ArrayCompareCondition.Op.values());
|
||||
ArrayCompareCondition.Quantifier quantifier = randomFrom(ArrayCompareCondition.Quantifier.values());
|
||||
Object value = randomFrom("value", 1, null);
|
||||
|
@ -289,8 +300,8 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
parser.nextToken();
|
||||
|
||||
expectedException.expect(JsonParseException.class);
|
||||
expectedException.expectMessage("Duplicate field 'quantifier'");
|
||||
expectedException.expect(ElasticsearchParseException.class);
|
||||
expectedException.expectMessage("duplicate field \"quantifier\"");
|
||||
|
||||
ArrayCompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue