@Test public void getFilteredProcessTest() throws Exception { ServerConfiguration serverConfiguration = new ServerConfiguration(); serverConfiguration.setUrlMetadata("fakeurl:1111"); serverConfiguration.setUrlWorkspace("fakeurl:1112"); when(processDataAccess.findAllProcessWorkflow(eq(0))).thenReturn(getPausedWorkflowList(5)); processManagementImpl = new ProcessManagementImpl(serverConfiguration, processDistributor, processDataAccess, processDataManagement, operationContextMonitor); Assert.assertNotNull(processManagementImpl); ProcessQuery pq = new ProcessQuery(); List<ProcessDetail> results = processManagementImpl.getFilteredProcess(pq, 0); assertThat(results).hasSize(5); LocalDate date = LocalDate.now(ZoneOffset.UTC); LocalDate dateMax = LocalDate.now(ZoneOffset.UTC); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); pq.setStartDateMin(date.format(formatter)); pq.setStartDateMax(dateMax.format(formatter)); results = processManagementImpl.getFilteredProcess(pq, 0); Assert.assertEquals(1, results.size()); dateMax = dateMax.plusDays(1); pq.setStartDateMax(dateMax.format(formatter)); results = processManagementImpl.getFilteredProcess(pq, 0); Assert.assertEquals(2, results.size()); dateMax = dateMax.plusDays(2); pq.setStartDateMax(dateMax.format(formatter)); results = processManagementImpl.getFilteredProcess(pq, 0); Assert.assertEquals(4, results.size()); dateMax = dateMax.plusDays(1); pq.setStartDateMax(dateMax.format(formatter)); results = processManagementImpl.getFilteredProcess(pq, 0); Assert.assertEquals(5, results.size()); date = date.plusDays(1); pq.setStartDateMin(date.format(formatter)); results = processManagementImpl.getFilteredProcess(pq, 0); Assert.assertEquals(4, results.size()); pq.setStartDateMin(null); pq.setStartDateMax(null); List<String> list = new ArrayList<>(); list.add(StatusCode.OK.name()); pq.setStatuses(list); results = processManagementImpl.getFilteredProcess(pq, 0); Assert.assertEquals(5, results.size()); list.clear(); list.add(StatusCode.KO.name()); pq.setStatuses(list); results = processManagementImpl.getFilteredProcess(pq, 0); Assert.assertEquals(0, results.size()); list.add(StatusCode.OK.name()); pq.setStatuses(list); results = processManagementImpl.getFilteredProcess(pq, 0); Assert.assertEquals(5, results.size()); pq.setStatuses(null); pq.setId("operationId0"); results = processManagementImpl.getFilteredProcess(pq, 0); Assert.assertEquals(1, results.size()); pq.setId(null); list.clear(); list.add(ProcessState.PAUSE.name()); pq.setStates(list); results = processManagementImpl.getFilteredProcess(pq, 0); Assert.assertEquals(5, results.size()); list.clear(); list.add(ProcessState.RUNNING.name()); pq.setStates(list); results = processManagementImpl.getFilteredProcess(pq, 0); Assert.assertEquals(0, results.size()); list.add(ProcessState.PAUSE.name()); pq.setStates(list); results = processManagementImpl.getFilteredProcess(pq, 0); Assert.assertEquals(5, results.size()); }
public List<ProcessDetail> getFilteredProcess(ProcessQuery query, Integer tenantId) { List<ProcessWorkflow> listWorkflow = this.findAllProcessWorkflow(tenantId); listWorkflow.sort((a, b) -> b.getProcessDate().compareTo(a.getProcessDate())); List<ProcessDetail> results = new ArrayList<>(); for (ProcessWorkflow processWorkflow : listWorkflow) { ProcessDetail workflow = new ProcessDetail(); workflow = getNextAndPreviousSteps(processWorkflow, workflow); if (query.getId() != null && !query.getId().equals(processWorkflow.getOperationId())) { continue; } if (query.getStates() != null && !query.getStates().isEmpty() && !query.getStates().contains(processWorkflow.getState().name())) { continue; } if (query.getStatuses() != null && !query.getStatuses().isEmpty() && !query.getStatuses().contains(processWorkflow.getStatus().name())) { continue; } if (query.getWorkflows() != null && !query.getWorkflows().isEmpty() && !query.getWorkflows().contains(processWorkflow.getWorkflowId())) { continue; } if (query.getListSteps() != null && !query.getListSteps().isEmpty()) { if (!isContainsStep(query.getListSteps(), workflow)) { continue; } } if (query.getListProcessTypes() != null && !query.getListProcessTypes().isEmpty() && !query.getListProcessTypes().contains(processWorkflow.getLogbookTypeProcess().toString())) { continue; } if (query.getStartDateMin() != null && query.getStartDateMax() != null) { if (!isStartDateIn(query.getStartDateMin(), query.getStartDateMax(), processWorkflow)) { continue; } } workflow.setOperationId(processWorkflow.getOperationId()); workflow.setProcessType(processWorkflow.getLogbookTypeProcess().toString()); workflow.setStepByStep(processWorkflow.isStepByStep()); workflow.setGlobalState(processWorkflow.getState().name()); workflow.setStepStatus(processWorkflow.getStatus().name()); workflow.setProcessDate(LocalDateUtil.getFormattedDate(processWorkflow.getProcessDate())); results.add(workflow); } return results; }
ProcessManagementImpl implements ProcessManagement { public List<ProcessDetail> getFilteredProcess(ProcessQuery query, Integer tenantId) { List<ProcessWorkflow> listWorkflow = this.findAllProcessWorkflow(tenantId); listWorkflow.sort((a, b) -> b.getProcessDate().compareTo(a.getProcessDate())); List<ProcessDetail> results = new ArrayList<>(); for (ProcessWorkflow processWorkflow : listWorkflow) { ProcessDetail workflow = new ProcessDetail(); workflow = getNextAndPreviousSteps(processWorkflow, workflow); if (query.getId() != null && !query.getId().equals(processWorkflow.getOperationId())) { continue; } if (query.getStates() != null && !query.getStates().isEmpty() && !query.getStates().contains(processWorkflow.getState().name())) { continue; } if (query.getStatuses() != null && !query.getStatuses().isEmpty() && !query.getStatuses().contains(processWorkflow.getStatus().name())) { continue; } if (query.getWorkflows() != null && !query.getWorkflows().isEmpty() && !query.getWorkflows().contains(processWorkflow.getWorkflowId())) { continue; } if (query.getListSteps() != null && !query.getListSteps().isEmpty()) { if (!isContainsStep(query.getListSteps(), workflow)) { continue; } } if (query.getListProcessTypes() != null && !query.getListProcessTypes().isEmpty() && !query.getListProcessTypes().contains(processWorkflow.getLogbookTypeProcess().toString())) { continue; } if (query.getStartDateMin() != null && query.getStartDateMax() != null) { if (!isStartDateIn(query.getStartDateMin(), query.getStartDateMax(), processWorkflow)) { continue; } } workflow.setOperationId(processWorkflow.getOperationId()); workflow.setProcessType(processWorkflow.getLogbookTypeProcess().toString()); workflow.setStepByStep(processWorkflow.isStepByStep()); workflow.setGlobalState(processWorkflow.getState().name()); workflow.setStepStatus(processWorkflow.getStatus().name()); workflow.setProcessDate(LocalDateUtil.getFormattedDate(processWorkflow.getProcessDate())); results.add(workflow); } return results; } }
ProcessManagementImpl implements ProcessManagement { public List<ProcessDetail> getFilteredProcess(ProcessQuery query, Integer tenantId) { List<ProcessWorkflow> listWorkflow = this.findAllProcessWorkflow(tenantId); listWorkflow.sort((a, b) -> b.getProcessDate().compareTo(a.getProcessDate())); List<ProcessDetail> results = new ArrayList<>(); for (ProcessWorkflow processWorkflow : listWorkflow) { ProcessDetail workflow = new ProcessDetail(); workflow = getNextAndPreviousSteps(processWorkflow, workflow); if (query.getId() != null && !query.getId().equals(processWorkflow.getOperationId())) { continue; } if (query.getStates() != null && !query.getStates().isEmpty() && !query.getStates().contains(processWorkflow.getState().name())) { continue; } if (query.getStatuses() != null && !query.getStatuses().isEmpty() && !query.getStatuses().contains(processWorkflow.getStatus().name())) { continue; } if (query.getWorkflows() != null && !query.getWorkflows().isEmpty() && !query.getWorkflows().contains(processWorkflow.getWorkflowId())) { continue; } if (query.getListSteps() != null && !query.getListSteps().isEmpty()) { if (!isContainsStep(query.getListSteps(), workflow)) { continue; } } if (query.getListProcessTypes() != null && !query.getListProcessTypes().isEmpty() && !query.getListProcessTypes().contains(processWorkflow.getLogbookTypeProcess().toString())) { continue; } if (query.getStartDateMin() != null && query.getStartDateMax() != null) { if (!isStartDateIn(query.getStartDateMin(), query.getStartDateMax(), processWorkflow)) { continue; } } workflow.setOperationId(processWorkflow.getOperationId()); workflow.setProcessType(processWorkflow.getLogbookTypeProcess().toString()); workflow.setStepByStep(processWorkflow.isStepByStep()); workflow.setGlobalState(processWorkflow.getState().name()); workflow.setStepStatus(processWorkflow.getStatus().name()); workflow.setProcessDate(LocalDateUtil.getFormattedDate(processWorkflow.getProcessDate())); results.add(workflow); } return results; } ProcessManagementImpl(ServerConfiguration config, ProcessDistributor processDistributor); @VisibleForTesting  ProcessManagementImpl(ServerConfiguration config,
        ProcessDistributor processDistributor, ProcessDataAccess processDataAccess,
        ProcessDataManagement processDataManagement, OperationContextMonitor operationContextMonitor); }
ProcessManagementImpl implements ProcessManagement { public List<ProcessDetail> getFilteredProcess(ProcessQuery query, Integer tenantId) { List<ProcessWorkflow> listWorkflow = this.findAllProcessWorkflow(tenantId); listWorkflow.sort((a, b) -> b.getProcessDate().compareTo(a.getProcessDate())); List<ProcessDetail> results = new ArrayList<>(); for (ProcessWorkflow processWorkflow : listWorkflow) { ProcessDetail workflow = new ProcessDetail(); workflow = getNextAndPreviousSteps(processWorkflow, workflow); if (query.getId() != null && !query.getId().equals(processWorkflow.getOperationId())) { continue; } if (query.getStates() != null && !query.getStates().isEmpty() && !query.getStates().contains(processWorkflow.getState().name())) { continue; } if (query.getStatuses() != null && !query.getStatuses().isEmpty() && !query.getStatuses().contains(processWorkflow.getStatus().name())) { continue; } if (query.getWorkflows() != null && !query.getWorkflows().isEmpty() && !query.getWorkflows().contains(processWorkflow.getWorkflowId())) { continue; } if (query.getListSteps() != null && !query.getListSteps().isEmpty()) { if (!isContainsStep(query.getListSteps(), workflow)) { continue; } } if (query.getListProcessTypes() != null && !query.getListProcessTypes().isEmpty() && !query.getListProcessTypes().contains(processWorkflow.getLogbookTypeProcess().toString())) { continue; } if (query.getStartDateMin() != null && query.getStartDateMax() != null) { if (!isStartDateIn(query.getStartDateMin(), query.getStartDateMax(), processWorkflow)) { continue; } } workflow.setOperationId(processWorkflow.getOperationId()); workflow.setProcessType(processWorkflow.getLogbookTypeProcess().toString()); workflow.setStepByStep(processWorkflow.isStepByStep()); workflow.setGlobalState(processWorkflow.getState().name()); workflow.setStepStatus(processWorkflow.getStatus().name()); workflow.setProcessDate(LocalDateUtil.getFormattedDate(processWorkflow.getProcessDate())); results.add(workflow); } return results; } ProcessManagementImpl(ServerConfiguration config, ProcessDistributor processDistributor); @VisibleForTesting  ProcessManagementImpl(ServerConfiguration config,
        ProcessDistributor processDistributor, ProcessDataAccess processDataAccess,
        ProcessDataManagement processDataManagement, OperationContextMonitor operationContextMonitor); @Override void startProcess(); @Override void stopProcess(); @Override ProcessWorkflow init(WorkerParameters workerParameters, String workflowId); @Override ItemStatus next(WorkerParameters workerParameters, Integer tenantId); @Override ItemStatus resume(WorkerParameters workerParameters, Integer tenantId, boolean useForcedPause); @Override ItemStatus replay(WorkerParameters workerParameters, Integer tenantId); @Override ItemStatus pause(String operationId, Integer tenantId); @Override ItemStatus cancel(String operationId, Integer tenantId); ItemStatus execute(String operationId, Integer tenantId, WorkerParameters workerParameters,
        Boolean useForcedPause,
        ProcessAction action); @Override void forcePause(ProcessPause pause); @Override void removeForcePause(ProcessPause pause); @Override void close(); @Override List<ProcessWorkflow> findAllProcessWorkflow(Integer tenantId); @Override ProcessWorkflow findOneProcessWorkflow(String operationId, Integer tenantId); @Override Map<String, WorkFlow> getWorkflowDefinitions(); @Override void reloadWorkflowDefinitions(); Map<Integer, Map<String, ProcessWorkflow>> getWorkFlowList(); @Override Map<String, IEventsState> getProcessMonitorList(); List<ProcessDetail> getFilteredProcess(ProcessQuery query, Integer tenantId); @Override ServerConfiguration getConfiguration(); }
ProcessManagementImpl implements ProcessManagement { public List<ProcessDetail> getFilteredProcess(ProcessQuery query, Integer tenantId) { List<ProcessWorkflow> listWorkflow = this.findAllProcessWorkflow(tenantId); listWorkflow.sort((a, b) -> b.getProcessDate().compareTo(a.getProcessDate())); List<ProcessDetail> results = new ArrayList<>(); for (ProcessWorkflow processWorkflow : listWorkflow) { ProcessDetail workflow = new ProcessDetail(); workflow = getNextAndPreviousSteps(processWorkflow, workflow); if (query.getId() != null && !query.getId().equals(processWorkflow.getOperationId())) { continue; } if (query.getStates() != null && !query.getStates().isEmpty() && !query.getStates().contains(processWorkflow.getState().name())) { continue; } if (query.getStatuses() != null && !query.getStatuses().isEmpty() && !query.getStatuses().contains(processWorkflow.getStatus().name())) { continue; } if (query.getWorkflows() != null && !query.getWorkflows().isEmpty() && !query.getWorkflows().contains(processWorkflow.getWorkflowId())) { continue; } if (query.getListSteps() != null && !query.getListSteps().isEmpty()) { if (!isContainsStep(query.getListSteps(), workflow)) { continue; } } if (query.getListProcessTypes() != null && !query.getListProcessTypes().isEmpty() && !query.getListProcessTypes().contains(processWorkflow.getLogbookTypeProcess().toString())) { continue; } if (query.getStartDateMin() != null && query.getStartDateMax() != null) { if (!isStartDateIn(query.getStartDateMin(), query.getStartDateMax(), processWorkflow)) { continue; } } workflow.setOperationId(processWorkflow.getOperationId()); workflow.setProcessType(processWorkflow.getLogbookTypeProcess().toString()); workflow.setStepByStep(processWorkflow.isStepByStep()); workflow.setGlobalState(processWorkflow.getState().name()); workflow.setStepStatus(processWorkflow.getStatus().name()); workflow.setProcessDate(LocalDateUtil.getFormattedDate(processWorkflow.getProcessDate())); results.add(workflow); } return results; } ProcessManagementImpl(ServerConfiguration config, ProcessDistributor processDistributor); @VisibleForTesting  ProcessManagementImpl(ServerConfiguration config,
        ProcessDistributor processDistributor, ProcessDataAccess processDataAccess,
        ProcessDataManagement processDataManagement, OperationContextMonitor operationContextMonitor); @Override void startProcess(); @Override void stopProcess(); @Override ProcessWorkflow init(WorkerParameters workerParameters, String workflowId); @Override ItemStatus next(WorkerParameters workerParameters, Integer tenantId); @Override ItemStatus resume(WorkerParameters workerParameters, Integer tenantId, boolean useForcedPause); @Override ItemStatus replay(WorkerParameters workerParameters, Integer tenantId); @Override ItemStatus pause(String operationId, Integer tenantId); @Override ItemStatus cancel(String operationId, Integer tenantId); ItemStatus execute(String operationId, Integer tenantId, WorkerParameters workerParameters,
        Boolean useForcedPause,
        ProcessAction action); @Override void forcePause(ProcessPause pause); @Override void removeForcePause(ProcessPause pause); @Override void close(); @Override List<ProcessWorkflow> findAllProcessWorkflow(Integer tenantId); @Override ProcessWorkflow findOneProcessWorkflow(String operationId, Integer tenantId); @Override Map<String, WorkFlow> getWorkflowDefinitions(); @Override void reloadWorkflowDefinitions(); Map<Integer, Map<String, ProcessWorkflow>> getWorkFlowList(); @Override Map<String, IEventsState> getProcessMonitorList(); List<ProcessDetail> getFilteredProcess(ProcessQuery query, Integer tenantId); @Override ServerConfiguration getConfiguration();  }