### Question:
ApplicationControllerCallback implements ResponseHandler<T> { @Override public void onResponse(T response) { logger.info("ON RESPONSE IN CALLBACK"); Status status = appCSupport.getStatusFromGenericResponse(response); logger.info("Status code is: " + status.getCode()); logger.info("Status message is: " + status.getMessage()); if (appCSupport.getFinalityOf(status)) { logger.debug("Obtained final status, complete the task"); completeExternalTask(externalTask, externalTaskService, status); } else { logger.debug("Intermediate status, continue the task"); } } ApplicationControllerCallback(ExternalTask externalTask, ExternalTaskService externalTaskService,
            ApplicationControllerSupport appCSupport); @Override void onResponse(T response); @Override void onException(AppcClientException exception);  }### Answer:
@Test public void onResponse_appcCallback_success_Test() throws Exception { Status status = new Status(); status.setCode(400); ResumeTrafficOutput response = new ResumeTrafficOutput(); response.setStatus(status); doReturn(status).when(applicationControllerSupport).getStatusFromGenericResponse(response); doReturn(true).when(applicationControllerSupport).getFinalityOf(status); doReturn(StatusCategory.NORMAL).when(applicationControllerSupport).getCategoryOf(status); appcTaskCallback.onResponse(response); Mockito.verify(mockExternalTaskService).complete(mockExternalTask); }
@Test public void onResponse_appcCallback_intermediateResponse_Test() throws Exception { Status status = new Status(); status.setCode(100); ResumeTrafficOutput response = new ResumeTrafficOutput(); response.setStatus(status); doReturn(status).when(applicationControllerSupport).getStatusFromGenericResponse(response); appcTaskCallback.onResponse(response); Mockito.verifyZeroInteractions(mockExternalTaskService); }
@Test public void onResponse_appcCallback_failure_Test() throws Exception { String testFailure = "test failure"; Status status = new Status(); status.setCode(200); status.setMessage(testFailure); ResumeTrafficOutput response = new ResumeTrafficOutput(); response.setStatus(status); doReturn(status).when(applicationControllerSupport).getStatusFromGenericResponse(response); doReturn(true).when(applicationControllerSupport).getFinalityOf(status); doReturn(StatusCategory.ERROR).when(applicationControllerSupport).getCategoryOf(status); appcTaskCallback.onResponse(response); Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask, "MSOWorkflowException", testFailure); }