use of com.netflix.conductor.common.run.SearchResult in project conductor by Netflix.
the class TaskResourceTest method search.
@Test
public void search() {
Task task = new Task();
task.setTaskType("SIMPLE");
task.setWorkerId("123");
task.setDomain("test");
task.setStatus(Task.Status.IN_PROGRESS);
TaskSummary taskSummary = new TaskSummary(task);
ArrayList<TaskSummary> listOfTaskSummary = new ArrayList<TaskSummary>() {
{
add(taskSummary);
}
};
SearchResult<TaskSummary> searchResult = new SearchResult<TaskSummary>(100, listOfTaskSummary);
listOfTaskSummary.add(taskSummary);
when(mockTaskService.search(anyInt(), anyInt(), anyString(), anyString(), anyString())).thenReturn(searchResult);
assertEquals(searchResult, taskResource.search(0, 100, "asc", "*", "*"));
}
use of com.netflix.conductor.common.run.SearchResult in project conductor by Netflix.
the class WorkflowClientTest method testSearchV2.
@Test
public void testSearchV2() {
ClientResponse clientResponse = mock(ClientResponse.class);
SearchResult<Workflow> workflowSearchResult = new SearchResult<>();
workflowSearchResult.setTotalHits(1);
Workflow workflow = new Workflow();
workflowSearchResult.setResults(Collections.singletonList(workflow));
when(clientResponse.getEntity(argThat((GenericType<SearchResult<Workflow>> type) -> ((ParameterizedTypeImpl) type.getType()).getRawType().equals(SearchResult.class) && ((ParameterizedTypeImpl) type.getType()).getActualTypeArguments()[0].equals(Workflow.class)))).thenReturn(workflowSearchResult);
when(clientHandler.handle(argThat(argument -> argument.getURI().equals(URI.create("http://myuri:8080/workflow/search-v2?query=my_complex_query"))))).thenReturn(clientResponse);
SearchResult<Workflow> searchResult = workflowClient.searchV2("my_complex_query");
assertEquals(1, searchResult.getTotalHits());
assertEquals(Collections.singletonList(workflow), searchResult.getResults());
}
use of com.netflix.conductor.common.run.SearchResult in project conductor by Netflix.
the class WorkflowClientTest method testSearchWithParams.
@Test
public void testSearchWithParams() {
ClientResponse clientResponse = mock(ClientResponse.class);
SearchResult<WorkflowSummary> workflowSearchResult = new SearchResult<>();
workflowSearchResult.setTotalHits(1);
WorkflowSummary workflowSummary = new WorkflowSummary(new Workflow());
workflowSearchResult.setResults(Collections.singletonList(workflowSummary));
when(clientResponse.getEntity(argThat((GenericType<SearchResult<WorkflowSummary>> type) -> ((ParameterizedTypeImpl) type.getType()).getRawType().equals(SearchResult.class) && ((ParameterizedTypeImpl) type.getType()).getActualTypeArguments()[0].equals(WorkflowSummary.class)))).thenReturn(workflowSearchResult);
when(clientHandler.handle(argThat(argument -> argument.getURI().equals(URI.create("http://myuri:8080/workflow/search?start=0&size=10&sort=sort&freeText=text&query=my_complex_query"))))).thenReturn(clientResponse);
SearchResult<WorkflowSummary> searchResult = workflowClient.search(0, 10, "sort", "text", "my_complex_query");
assertEquals(1, searchResult.getTotalHits());
assertEquals(Collections.singletonList(workflowSummary), searchResult.getResults());
}
use of com.netflix.conductor.common.run.SearchResult in project conductor by Netflix.
the class WorkflowClientTest method testSearchV2WithParams.
@Test
public void testSearchV2WithParams() {
ClientResponse clientResponse = mock(ClientResponse.class);
SearchResult<Workflow> workflowSearchResult = new SearchResult<>();
workflowSearchResult.setTotalHits(1);
Workflow workflow = new Workflow();
workflowSearchResult.setResults(Collections.singletonList(workflow));
when(clientResponse.getEntity(argThat((GenericType<SearchResult<Workflow>> type) -> ((ParameterizedTypeImpl) type.getType()).getRawType().equals(SearchResult.class) && ((ParameterizedTypeImpl) type.getType()).getActualTypeArguments()[0].equals(Workflow.class)))).thenReturn(workflowSearchResult);
when(clientHandler.handle(argThat(argument -> argument.getURI().equals(URI.create("http://myuri:8080/workflow/search-v2?start=0&size=10&sort=sort&freeText=text&query=my_complex_query"))))).thenReturn(clientResponse);
SearchResult<Workflow> searchResult = workflowClient.searchV2(0, 10, "sort", "text", "my_complex_query");
assertEquals(1, searchResult.getTotalHits());
assertEquals(Collections.singletonList(workflow), searchResult.getResults());
}
Aggregations