Skip to content

Commit

Permalink
remove null from mock get result of field
Browse files Browse the repository at this point in the history
Signed-off-by: bowenlan-amzn <[email protected]>
  • Loading branch information
bowenlan-amzn committed Aug 2, 2024
1 parent a82a896 commit b18b44e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,13 @@ public GetResponse executeGet(GetRequest getRequest) {
throw new OpenSearchException("boom", ex);
}
Map<String, DocumentField> documentField = new HashMap<>();
documentField.put(termsPath, new DocumentField(termsPath, randomTerms));
List<Object> nonNullTerms = new ArrayList<>();
for (Object obj : randomTerms) {
if (obj != null) {
nonNullTerms.add(obj);
}
}
documentField.put(termsPath, new DocumentField(termsPath, nonNullTerms));
return new GetResponse(
new GetResult(getRequest.index(), getRequest.id(), 0, 1, 0, true, new BytesArray(json), documentField, null)
);
Expand Down

0 comments on commit b18b44e

Please sign in to comment.