@Test public void testRunningFlowChainWithoutFinishedState() { setUpFlowChain(flowChainLog(), false, List.of( flowLog(INTERMEDIATE_STATE, NEXT_EVENT, 2), flowLog(FlowConstants.INIT_STATE, NEXT_EVENT, 1))); FlowCheckResponse flowCheckResponse = underTest.getFlowChainState(FLOW_CHAIN_ID); assertTrue(flowCheckResponse.getHasActiveFlow()); assertEquals(FLOW_CHAIN_ID, flowCheckResponse.getFlowChainId()); }
public FlowCheckResponse getFlowChainState(String chainId) { FlowCheckResponse flowCheckResponse = new FlowCheckResponse(); flowCheckResponse.setFlowChainId(chainId); List<FlowChainLog> flowChains = flowChainLogService.findByFlowChainIdOrderByCreatedDesc(chainId); if (!flowChains.isEmpty()) { LOGGER.info("Checking if there is an active flow based on flow chain id {}", chainId); List<FlowChainLog> relatedChains = getRelatedFlowChainLogs(flowChains); Set<String> relatedChainIds = relatedChains.stream().map(FlowChainLog::getFlowChainId).collect(toSet()); Set<String> relatedFlowIds = flowLogDBService.getFlowIdsByChainIds(relatedChainIds); List<FlowLog> relatedFlowLogs = flowLogDBService.getFlowLogsByFlowIdsCreatedDesc(relatedFlowIds); flowCheckResponse.setHasActiveFlow(!completed("Flow chain", chainId, relatedChains, relatedFlowLogs)); return flowCheckResponse; } else { flowCheckResponse.setHasActiveFlow(Boolean.FALSE); return flowCheckResponse; } }
FlowService { public FlowCheckResponse getFlowChainState(String chainId) { FlowCheckResponse flowCheckResponse = new FlowCheckResponse(); flowCheckResponse.setFlowChainId(chainId); List<FlowChainLog> flowChains = flowChainLogService.findByFlowChainIdOrderByCreatedDesc(chainId); if (!flowChains.isEmpty()) { LOGGER.info("Checking if there is an active flow based on flow chain id {}", chainId); List<FlowChainLog> relatedChains = getRelatedFlowChainLogs(flowChains); Set<String> relatedChainIds = relatedChains.stream().map(FlowChainLog::getFlowChainId).collect(toSet()); Set<String> relatedFlowIds = flowLogDBService.getFlowIdsByChainIds(relatedChainIds); List<FlowLog> relatedFlowLogs = flowLogDBService.getFlowLogsByFlowIdsCreatedDesc(relatedFlowIds); flowCheckResponse.setHasActiveFlow(!completed("Flow chain", chainId, relatedChains, relatedFlowLogs)); return flowCheckResponse; } else { flowCheckResponse.setHasActiveFlow(Boolean.FALSE); return flowCheckResponse; } } }
FlowService { public FlowCheckResponse getFlowChainState(String chainId) { FlowCheckResponse flowCheckResponse = new FlowCheckResponse(); flowCheckResponse.setFlowChainId(chainId); List<FlowChainLog> flowChains = flowChainLogService.findByFlowChainIdOrderByCreatedDesc(chainId); if (!flowChains.isEmpty()) { LOGGER.info("Checking if there is an active flow based on flow chain id {}", chainId); List<FlowChainLog> relatedChains = getRelatedFlowChainLogs(flowChains); Set<String> relatedChainIds = relatedChains.stream().map(FlowChainLog::getFlowChainId).collect(toSet()); Set<String> relatedFlowIds = flowLogDBService.getFlowIdsByChainIds(relatedChainIds); List<FlowLog> relatedFlowLogs = flowLogDBService.getFlowLogsByFlowIdsCreatedDesc(relatedFlowIds); flowCheckResponse.setHasActiveFlow(!completed("Flow chain", chainId, relatedChains, relatedFlowLogs)); return flowCheckResponse; } else { flowCheckResponse.setHasActiveFlow(Boolean.FALSE); return flowCheckResponse; } }  }
FlowService { public FlowCheckResponse getFlowChainState(String chainId) { FlowCheckResponse flowCheckResponse = new FlowCheckResponse(); flowCheckResponse.setFlowChainId(chainId); List<FlowChainLog> flowChains = flowChainLogService.findByFlowChainIdOrderByCreatedDesc(chainId); if (!flowChains.isEmpty()) { LOGGER.info("Checking if there is an active flow based on flow chain id {}", chainId); List<FlowChainLog> relatedChains = getRelatedFlowChainLogs(flowChains); Set<String> relatedChainIds = relatedChains.stream().map(FlowChainLog::getFlowChainId).collect(toSet()); Set<String> relatedFlowIds = flowLogDBService.getFlowIdsByChainIds(relatedChainIds); List<FlowLog> relatedFlowLogs = flowLogDBService.getFlowLogsByFlowIdsCreatedDesc(relatedFlowIds); flowCheckResponse.setHasActiveFlow(!completed("Flow chain", chainId, relatedChains, relatedFlowLogs)); return flowCheckResponse; } else { flowCheckResponse.setHasActiveFlow(Boolean.FALSE); return flowCheckResponse; } }  FlowLogResponse getLastFlowById(String flowId); List<FlowLogResponse> getFlowLogsByFlowId(String flowId); FlowLogResponse getLastFlowByResourceName(String resourceName); FlowLogResponse getLastFlowByResourceCrn(String resourceCrn); List<FlowLogResponse> getFlowLogsByResourceCrn(String resourceCrn); List<FlowLogResponse> getFlowLogsByResourceName(String resourceName); FlowCheckResponse getFlowChainStateByResourceCrn(String chainId, String resourceCrn); FlowCheckResponse getFlowChainState(String chainId); FlowCheckResponse getFlowChainStateSafe(Long resourceId, String chainId); FlowCheckResponse getFlowState(String flowId); }
FlowService { public FlowCheckResponse getFlowChainState(String chainId) { FlowCheckResponse flowCheckResponse = new FlowCheckResponse(); flowCheckResponse.setFlowChainId(chainId); List<FlowChainLog> flowChains = flowChainLogService.findByFlowChainIdOrderByCreatedDesc(chainId); if (!flowChains.isEmpty()) { LOGGER.info("Checking if there is an active flow based on flow chain id {}", chainId); List<FlowChainLog> relatedChains = getRelatedFlowChainLogs(flowChains); Set<String> relatedChainIds = relatedChains.stream().map(FlowChainLog::getFlowChainId).collect(toSet()); Set<String> relatedFlowIds = flowLogDBService.getFlowIdsByChainIds(relatedChainIds); List<FlowLog> relatedFlowLogs = flowLogDBService.getFlowLogsByFlowIdsCreatedDesc(relatedFlowIds); flowCheckResponse.setHasActiveFlow(!completed("Flow chain", chainId, relatedChains, relatedFlowLogs)); return flowCheckResponse; } else { flowCheckResponse.setHasActiveFlow(Boolean.FALSE); return flowCheckResponse; } }  FlowLogResponse getLastFlowById(String flowId); List<FlowLogResponse> getFlowLogsByFlowId(String flowId); FlowLogResponse getLastFlowByResourceName(String resourceName); FlowLogResponse getLastFlowByResourceCrn(String resourceCrn); List<FlowLogResponse> getFlowLogsByResourceCrn(String resourceCrn); List<FlowLogResponse> getFlowLogsByResourceName(String resourceName); FlowCheckResponse getFlowChainStateByResourceCrn(String chainId, String resourceCrn); FlowCheckResponse getFlowChainState(String chainId); FlowCheckResponse getFlowChainStateSafe(Long resourceId, String chainId); FlowCheckResponse getFlowState(String flowId);  }