@Test
public void testGetWorkflowsByCorrelationId() {

    when(executionDAO.canSearchAcrossWorkflows()).thenReturn(true);
    when(executionDAO.getWorkflowsByCorrelationId(any(), any(), anyBoolean())).thenReturn(Collections.singletonList(new Workflow()));
    List<Workflow> workflows = executionDAOFacade.getWorkflowsByCorrelationId("workflowName", "correlationId", true);
    assertNotNull(workflows);
    assertEquals(1, workflows.size());
    verify(indexDAO, never()).searchWorkflows(anyString(), anyString(), anyInt(), anyInt(), any());
    when(executionDAO.canSearchAcrossWorkflows()).thenReturn(false);
    List<String> workflowIds = new ArrayList<>();
    workflowIds.add("workflowId");
    SearchResult<String> searchResult = new SearchResult<>();
    searchResult.setResults(workflowIds);
    when(indexDAO.searchWorkflows(anyString(), anyString(), anyInt(), anyInt(), any())).thenReturn(searchResult);
    when(executionDAO.getWorkflow("workflowId", true)).thenReturn(new Workflow());
    workflows = executionDAOFacade.getWorkflowsByCorrelationId("workflowName", "correlationId", true);
    assertNotNull(workflows);
    assertEquals(1, workflows.size());
}