Skip to content

Commit ab2aead

Browse files
committed
Allow test for random fields when search has no failures
1 parent 72fd736 commit ab2aead

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/MultiSearchTemplateResponseTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ protected boolean supportsUnknownFields() {
9797
return true;
9898
}
9999

100-
@Override
101-
protected Predicate<String> getRandomFieldsExcludeFilter() {
100+
protected Predicate<String> getRandomFieldsExcludeFilterWhenResultHasErrors() {
102101
return field -> field.startsWith("responses");
103102
}
104103

@@ -132,7 +131,7 @@ public void testFromXContentWithFailures() throws IOException {
132131
//exceptions are not of the same type whenever parsed back
133132
boolean assertToXContentEquivalence = false;
134133
AbstractXContentTestCase.testFromXContent(NUMBER_OF_TEST_RUNS, instanceSupplier, supportsUnknownFields, Strings.EMPTY_ARRAY,
135-
getRandomFieldsExcludeFilter(), this::createParser, this::doParseInstance,
134+
getRandomFieldsExcludeFilterWhenResultHasErrors(), this::createParser, this::doParseInstance,
136135
this::assertEqualInstances, assertToXContentEquivalence, ToXContent.EMPTY_PARAMS);
137136
}
138137

server/src/test/java/org/elasticsearch/action/search/MultiSearchResponseTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,9 @@ protected boolean supportsUnknownFields() {
105105
return true;
106106
}
107107

108-
@Override
109-
protected Predicate<String> getRandomFieldsExcludeFilter() {
108+
protected Predicate<String> getRandomFieldsExcludeFilterWhenResultHasErrors() {
110109
return field -> field.startsWith("responses");
111-
}
110+
}
112111

113112
/**
114113
* Test parsing {@link MultiSearchResponse} with inner failures as they don't support asserting on xcontent equivalence, given that
@@ -123,7 +122,7 @@ public void testFromXContentWithFailures() throws IOException {
123122
//exceptions are not of the same type whenever parsed back
124123
boolean assertToXContentEquivalence = false;
125124
AbstractXContentTestCase.testFromXContent(NUMBER_OF_TEST_RUNS, instanceSupplier, supportsUnknownFields, Strings.EMPTY_ARRAY,
126-
getRandomFieldsExcludeFilter(), this::createParser, this::doParseInstance,
125+
getRandomFieldsExcludeFilterWhenResultHasErrors(), this::createParser, this::doParseInstance,
127126
this::assertEqualInstances, assertToXContentEquivalence, ToXContent.EMPTY_PARAMS);
128127
}
129128

0 commit comments

Comments
 (0)