### Question:
InitCodeGrantFlowHandler implements CloudPlatformEventHandler<InitCodeGrantFlowRequest> { @Override public void accept(Event<InitCodeGrantFlowRequest> initCodeGrantFlowRequestEvent) { LOGGER.info("Received event: {}", initCodeGrantFlowRequestEvent); InitCodeGrantFlowRequest request = initCodeGrantFlowRequestEvent.getData(); CloudContext cloudContext = request.getCloudContext(); try { CloudConnector<?> connector = cloudPlatformConnectors.getDefault(cloudContext.getPlatform()); Map<String, String> parameters = connector.credentials().initCodeGrantFlow(cloudContext, request.getCloudCredential()); InitCodeGrantFlowResponse initCodeGrantFlowResponse = new InitCodeGrantFlowResponse(request.getResourceId(), parameters); request.getResult().onNext(initCodeGrantFlowResponse); LOGGER.info("Authorization code grant flow has initialized successfully."); } catch (RuntimeException e) { request.getResult().onNext(new InitCodeGrantFlowResponse(e.getMessage(), e, request.getResourceId())); } }  @Override Class<InitCodeGrantFlowRequest> type(); @Override void accept(Event<InitCodeGrantFlowRequest> initCodeGrantFlowRequestEvent);  }### Answer:
@Test public void testAcceptWhenSomeRuntimeExceptionHappensThenOnNextCallStillHappens() { doThrow(new RuntimeException()).when(cloudPlatformConnectors).getDefault(platform); underTest.accept(initCodeGrantFlowRequestEvent); verify(cloudPlatformConnectors, times(1)).getDefault(platform); verify(data, times(1)).getResult(); verify(result, times(1)).onNext(any(InitCodeGrantFlowResponse.class)); verify(credentialConnector, times(0)).initCodeGrantFlow(cloudContext, cloudCredential); }
@Test public void testAcceptWhenNoExceptionComesDuringExecutionThenOnNextCallHappens() { when(cloudPlatformConnectors.getDefault(platform)).thenReturn(cloudConnector); underTest.accept(initCodeGrantFlowRequestEvent); verify(cloudPlatformConnectors, times(1)).getDefault(platform); verify(data, times(1)).getResult(); verify(result, times(1)).onNext(any(InitCodeGrantFlowResponse.class)); verify(credentialConnector, times(1)).initCodeGrantFlow(cloudContext, cloudCredential); }