### Question:
CDPFlowStructuredEventHandler extends StateMachineListenerAdapter<S, E> implements FlowEventListener<S, E> { @Override public void transition(Transition<S, E> transition) { try { State<S, E> from = transition.getSource(); State<S, E> to = transition.getTarget(); Trigger<S, E> trigger = transition.getTrigger(); Long currentTime = System.currentTimeMillis(); String fromId = from != null ? from.getId().toString() : "unknown"; String toId = to != null ? to.getId().toString() : "unknown"; String eventId = trigger != null ? trigger.getEvent().toString() : "unknown"; Boolean detailed = toId.equals(initState.toString()) || toId.equals(finalState.toString()); long duration = lastStateChange == null ? 0L : currentTime - lastStateChange; FlowDetails flowDetails = new FlowDetails("", flowType, "", flowId, fromId, toId, eventId, duration); CDPStructuredEvent structuredEvent; if (exception == null) { structuredEvent = cdpStructuredFlowEventFactory.createStructuredFlowEvent(resourceId, flowDetails, detailed); } else { structuredEvent = cdpStructuredFlowEventFactory.createStructuredFlowEvent(resourceId, flowDetails, true, exception); exception = null; } cdpDefaultStructuredEventClient.sendStructuredEvent(structuredEvent); lastStateChange = currentTime; } catch (RuntimeException ex) { LOGGER.error("Error happened during structured flow event generation! The event won't be stored!", ex); } } CDPFlowStructuredEventHandler(S initState, S finalState, String flowType, String flowId, Long resourceId); @Override void stateChanged(State<S, E> from, State<S, E> to); @Override void stateEntered(State<S, E> state); @Override void stateExited(State<S, E> state); @Override void eventNotAccepted(Message<E> event); @Override void transition(Transition<S, E> transition); @Override void transitionStarted(Transition<S, E> transition); @Override void transitionEnded(Transition<S, E> transition); @Override void stateMachineStopped(StateMachine<S, E> stateMachine); @Override void stateMachineError(StateMachine<S, E> stateMachine, Exception exception); void setException(Exception exception);  }### Answer:
@Test public void testTransitionWhenExceptionNullAndTransitionValueIsNull() { Transition<String, String> transition = mock(Transition.class); CDPStructuredFlowEvent event = new CDPStructuredFlowEvent(); when(cdpStructuredFlowEventFactory.createStructuredFlowEvent(any(), any(), any())).thenReturn(event); underTest.transition(transition); ArgumentCaptor<FlowDetails> flowDetailsCaptor = ArgumentCaptor.forClass(FlowDetails.class); ArgumentCaptor<Boolean> detailedCaptor = ArgumentCaptor.forClass(Boolean.class); verify(cdpStructuredFlowEventFactory).createStructuredFlowEvent(any(), flowDetailsCaptor.capture(), detailedCaptor.capture()); verify(cdpDefaultStructuredEventClient).sendStructuredEvent(event); FlowDetails flowDetails = flowDetailsCaptor.getValue(); String unknown = "unknown"; Assertions.assertEquals(unknown, flowDetails.getFlowState()); Assertions.assertEquals(unknown, flowDetails.getNextFlowState()); Assertions.assertEquals(unknown, flowDetails.getFlowEvent()); Assertions.assertEquals(0L, flowDetails.getDuration()); Boolean detailed = detailedCaptor.getValue(); Assertions.assertFalse(detailed); }