use of org.apache.lucene.search.TotalHits.Relation.EQUAL_TO in project hazelcast by hazelcast.
the class ElasticSourcePTest method when_runProcessorWithOptionsFn_then_shouldUseOptionsFnForScrollRequest.
@Test
public void when_runProcessorWithOptionsFn_then_shouldUseOptionsFnForScrollRequest() throws Exception {
SearchHit hit = new SearchHit(0, "id-0", new Text("ignored"), emptyMap(), emptyMap());
hit.sourceRef(new BytesArray(HIT_SOURCE));
when(response.getHits()).thenReturn(new SearchHits(new SearchHit[] { hit }, new TotalHits(1, EQUAL_TO), Float.NaN));
SearchResponse response2 = mock(SearchResponse.class);
when(response2.getHits()).thenReturn(new SearchHits(new SearchHit[] {}, new TotalHits(1, EQUAL_TO), Float.NaN));
when(mockClient.scroll(any(), any())).thenReturn(response2);
// get different instance than default
TestSupport testSupport = runProcessor(request -> {
Builder builder = RequestOptions.DEFAULT.toBuilder();
builder.addHeader("TestHeader", "value");
return builder.build();
});
testSupport.expectOutput(newArrayList(HIT_SOURCE));
ArgumentCaptor<RequestOptions> captor = forClass(RequestOptions.class);
verify(mockClient).scroll(any(), captor.capture());
RequestOptions capturedOptions = captor.getValue();
assertThat(capturedOptions.getHeaders()).extracting(h -> tuple(h.getName(), h.getValue())).containsExactly(tuple("TestHeader", "value"));
}
use of org.apache.lucene.search.TotalHits.Relation.EQUAL_TO in project hazelcast by hazelcast.
the class ElasticSourcePTest method when_runProcessorWithOptionsFn_then_shouldUseOptionsFnForSearchRequest.
@Test
public void when_runProcessorWithOptionsFn_then_shouldUseOptionsFnForSearchRequest() throws Exception {
when(response.getHits()).thenReturn(new SearchHits(new SearchHit[] {}, new TotalHits(0, EQUAL_TO), Float.NaN));
// get different instance than default
TestSupport testSupport = runProcessor(request -> {
Builder builder = RequestOptions.DEFAULT.toBuilder();
builder.addHeader("TestHeader", "value");
return builder.build();
});
testSupport.expectOutput(emptyList());
ArgumentCaptor<RequestOptions> captor = forClass(RequestOptions.class);
verify(mockClient).search(any(), captor.capture());
RequestOptions capturedOptions = captor.getValue();
assertThat(capturedOptions.getHeaders()).extracting(h -> tuple(h.getName(), h.getValue())).containsExactly(tuple("TestHeader", "value"));
}
Aggregations