Skip to content

Commit

Permalink
Only set request to default if null
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Dec 15, 2023
1 parent 340162d commit d1e25f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public boolean isSimulate() {
}

public void setSimulate(boolean simulate) {
if (simulate) {
if (simulate && request == null) {
this.request = SIMULATED_REQUEST;
}
this.simulate = simulate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,17 @@ public static SearchTemplateRequest createRandomRequest() {

public void testSimulatedSearchTemplateRequest() {
SearchTemplateRequest request = createRandomRequest();
request.setRequest(null);
request.setSimulate(true);

assertEquals(0, request.indices().length);
assertEquals(SearchRequest.DEFAULT_INDICES_OPTIONS, request.indicesOptions());
assertEquals(2, request.indices("index1", "index2").indices().length);

SearchTemplateRequest randomRequest = createRandomRequest();
int expectedIndicesLength = randomRequest.indices().length;
request.setSimulate(true);

assertEquals(expectedIndicesLength, randomRequest.indices().length);
}
}

0 comments on commit d1e25f3

Please sign in to comment.