Skip to content

Commit

Permalink
add unit test for complex data structures
Browse files Browse the repository at this point in the history
Signed-off-by: Chenyang Ji <[email protected]>
  • Loading branch information
ansjcy committed May 2, 2024
1 parent 139389c commit 5abf955
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.opensearch.search.Scroll;
import org.opensearch.search.builder.PointInTimeBuilder;
import org.opensearch.search.builder.SearchSourceBuilder;
import org.opensearch.search.fetch.subphase.FetchSourceContext;
import org.opensearch.search.rescore.QueryRescorerBuilder;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.test.VersionUtils;
Expand Down Expand Up @@ -76,11 +77,20 @@ protected SearchRequest createSearchRequest() throws IOException {
);
}

public void testClone() {
public void testClone() throws IOException {
SearchRequest searchRequest = new SearchRequest();
SearchRequest clonedRequest = searchRequest.clone();
assertEquals(searchRequest.hashCode(), clonedRequest.hashCode());
assertNotSame(searchRequest, clonedRequest);

SearchSourceBuilder source = new SearchSourceBuilder()
.fetchSource(new FetchSourceContext(true, new String[] { "field1.*" }, new String[] { "field2.*" }));
SearchRequest complexSearchRequest = createSearchRequest().source(source);
complexSearchRequest.requestCache(false);
complexSearchRequest.scroll(new TimeValue(1000));
SearchRequest clonedComplexRequest = complexSearchRequest.clone();
assertEquals(complexSearchRequest.hashCode(), clonedComplexRequest.hashCode());
assertNotSame(complexSearchRequest, clonedComplexRequest);
}

public void testWithLocalReduction() {
Expand Down

0 comments on commit 5abf955

Please sign in to comment.