### Question:
Flow2Handler implements Consumer<Event<? extends Payload>> { private void cancelRunningFlows(Long stackId) throws TransactionExecutionException { Set<String> flowIds = flowLogService.findAllRunningNonTerminationFlowIdsByStackId(stackId); LOGGER.debug("flow cancellation arrived: ids: {}", flowIds); for (String id : flowIds) { cancelFlow(stackId, id); } }  @Override void accept(Event<? extends Payload> event); void cancelFlow(Long stackId, String flowId); void restartFlow(String flowId); void restartFlow(FlowLog flowLog); static final String FLOW_ID; static final String FLOW_CHAIN_ID; static final String FLOW_FINAL; static final String FLOW_CANCEL; }### Answer:
@Test public void testCancelRunningFlows() throws TransactionExecutionException { given(flowLogService.findAllRunningNonTerminationFlowIdsByStackId(anyLong())).willReturn(Collections.singleton(FLOW_ID)); given(runningFlows.remove(FLOW_ID)).willReturn(flow); given(runningFlows.getFlowChainId(eq(FLOW_ID))).willReturn(FLOW_CHAIN_ID); dummyEvent.setKey(Flow2Handler.FLOW_CANCEL); underTest.accept(dummyEvent); verify(flowLogService, times(1)).cancel(anyLong(), eq(FLOW_ID)); verify(flowChains, times(1)).removeFullFlowChain(eq(FLOW_CHAIN_ID)); }