@Test public void shouldCompleteDeleteOnErrorDuringCompletingFlowPathRemoval() { Flow target = makeFlow(); FlowPath forwardPath = target.getForwardPath(); Assert.assertNotNull(forwardPath); FlowPathRepository repository = setupFlowPathRepositorySpy(); doThrow(new RuntimeException(injectedErrorMessage)) .when(repository) .remove(eq(forwardPath.getPathId())); FlowDeleteService service = makeService(); service.handleRequest(dummyRequestKey, commandContext, target.getFlowId()); verifyFlowStatus(target.getFlowId(), FlowStatus.IN_PROGRESS); verifyNorthboundSuccessResponse(carrier); produceSpeakerResponses(service); verify(carrier, times(4)).sendSpeakerRequest(any()); verifyFlowIsMissing(target); }
public void handleRequest(String key, CommandContext commandContext, String flowId) { log.debug("Handling flow delete request with key {} and flow ID: {}", key, flowId); if (fsms.containsKey(key)) { log.error("Attempt to create a FSM with key {}, while there's another active FSM with the same key.", key); return; } String eventKey = commandContext.getCorrelationId(); if (flowEventRepository.existsByTaskId(eventKey)) { log.error("Attempt to reuse key %s, but there's a history record(s) for it.", eventKey); return; } FlowDeleteFsm fsm = fsmFactory.newInstance(commandContext, flowId); fsms.put(key, fsm); fsmExecutor.fire(fsm, Event.NEXT, FlowDeleteContext.builder().build()); removeIfFinished(fsm, key); }
FlowDeleteService { public void handleRequest(String key, CommandContext commandContext, String flowId) { log.debug("Handling flow delete request with key {} and flow ID: {}", key, flowId); if (fsms.containsKey(key)) { log.error("Attempt to create a FSM with key {}, while there's another active FSM with the same key.", key); return; } String eventKey = commandContext.getCorrelationId(); if (flowEventRepository.existsByTaskId(eventKey)) { log.error("Attempt to reuse key %s, but there's a history record(s) for it.", eventKey); return; } FlowDeleteFsm fsm = fsmFactory.newInstance(commandContext, flowId); fsms.put(key, fsm); fsmExecutor.fire(fsm, Event.NEXT, FlowDeleteContext.builder().build()); removeIfFinished(fsm, key); } }
FlowDeleteService { public void handleRequest(String key, CommandContext commandContext, String flowId) { log.debug("Handling flow delete request with key {} and flow ID: {}", key, flowId); if (fsms.containsKey(key)) { log.error("Attempt to create a FSM with key {}, while there's another active FSM with the same key.", key); return; } String eventKey = commandContext.getCorrelationId(); if (flowEventRepository.existsByTaskId(eventKey)) { log.error("Attempt to reuse key %s, but there's a history record(s) for it.", eventKey); return; } FlowDeleteFsm fsm = fsmFactory.newInstance(commandContext, flowId); fsms.put(key, fsm); fsmExecutor.fire(fsm, Event.NEXT, FlowDeleteContext.builder().build()); removeIfFinished(fsm, key); } FlowDeleteService(FlowDeleteHubCarrier carrier, PersistenceManager persistenceManager,
                             FlowResourcesManager flowResourcesManager,
                             int speakerCommandRetriesLimit); }
FlowDeleteService { public void handleRequest(String key, CommandContext commandContext, String flowId) { log.debug("Handling flow delete request with key {} and flow ID: {}", key, flowId); if (fsms.containsKey(key)) { log.error("Attempt to create a FSM with key {}, while there's another active FSM with the same key.", key); return; } String eventKey = commandContext.getCorrelationId(); if (flowEventRepository.existsByTaskId(eventKey)) { log.error("Attempt to reuse key %s, but there's a history record(s) for it.", eventKey); return; } FlowDeleteFsm fsm = fsmFactory.newInstance(commandContext, flowId); fsms.put(key, fsm); fsmExecutor.fire(fsm, Event.NEXT, FlowDeleteContext.builder().build()); removeIfFinished(fsm, key); } FlowDeleteService(FlowDeleteHubCarrier carrier, PersistenceManager persistenceManager,
                             FlowResourcesManager flowResourcesManager,
                             int speakerCommandRetriesLimit); void handleRequest(String key, CommandContext commandContext, String flowId); void handleAsyncResponse(String key, SpeakerFlowSegmentResponse flowResponse); void handleTimeout(String key); }
FlowDeleteService { public void handleRequest(String key, CommandContext commandContext, String flowId) { log.debug("Handling flow delete request with key {} and flow ID: {}", key, flowId); if (fsms.containsKey(key)) { log.error("Attempt to create a FSM with key {}, while there's another active FSM with the same key.", key); return; } String eventKey = commandContext.getCorrelationId(); if (flowEventRepository.existsByTaskId(eventKey)) { log.error("Attempt to reuse key %s, but there's a history record(s) for it.", eventKey); return; } FlowDeleteFsm fsm = fsmFactory.newInstance(commandContext, flowId); fsms.put(key, fsm); fsmExecutor.fire(fsm, Event.NEXT, FlowDeleteContext.builder().build()); removeIfFinished(fsm, key); } FlowDeleteService(FlowDeleteHubCarrier carrier, PersistenceManager persistenceManager,
                             FlowResourcesManager flowResourcesManager,
                             int speakerCommandRetriesLimit); void handleRequest(String key, CommandContext commandContext, String flowId); void handleAsyncResponse(String key, SpeakerFlowSegmentResponse flowResponse); void handleTimeout(String key);  }