Skip to content

Commit

Permalink
Update EqlSearchRequest unit test for null searchAfterBuilder cases
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksmaus committed Jan 6, 2020
1 parent 32eeae1 commit 1bd4327
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,19 @@ protected NamedXContentRegistry xContentRegistry() {
protected EqlSearchRequest createTestInstance() {
try {
QueryBuilder query = parseQuery(defaultTestQuery);
return new EqlSearchRequest()
EqlSearchRequest request = new EqlSearchRequest()
.indices(new String[]{defaultTestIndex})
.query(query)
.timestampField(randomAlphaOfLength(10))
.eventTypeField(randomAlphaOfLength(10))
.implicitJoinKeyField(randomAlphaOfLength(10))
.fetchSize(randomIntBetween(1, 50))
.searchAfter(randomJsonSearchFromBuilder().getSortValues())
.rule(randomAlphaOfLength(10));

if (randomBoolean()) {
request.searchAfter(randomJsonSearchFromBuilder());
}
return request;
} catch (IOException ex) {
assertNotNull("unexpected IOException " + ex.getCause().getMessage(), ex);
}
Expand Down Expand Up @@ -101,7 +105,7 @@ private Object randomValue() {
return value.get();
}

private SearchAfterBuilder randomJsonSearchFromBuilder() throws IOException {
private Object[] randomJsonSearchFromBuilder() throws IOException {
int numSearchAfter = randomIntBetween(1, 10);
XContentBuilder jsonBuilder = XContentFactory.jsonBuilder();
jsonBuilder.startObject();
Expand All @@ -115,7 +119,7 @@ private SearchAfterBuilder randomJsonSearchFromBuilder() throws IOException {
parser.nextToken();
parser.nextToken();
parser.nextToken();
return SearchAfterBuilder.fromXContent(parser);
return SearchAfterBuilder.fromXContent(parser).getSortValues();
}
}

Expand Down

0 comments on commit 1bd4327

Please sign in to comment.