### Question:
MonitorVnfmCreateJobTask extends MonitorVnfmJobTask { public void checkIfOperationWasSuccessful(final BuildingBlockExecution execution) { LOGGER.debug("Executing checkIfOperationWasSuccessful ..."); final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME); final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME); if (operationStatusOption == null || !operationStatusOption.isPresent()) { final String message = "Unable to instantiate jobId: " + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null") + "Unable to retrieve OperationStatus"; LOGGER.error(message); exceptionUtil.buildAndThrowWorkflowException(execution, 1206, message); } else if (operationStatusOption != null && operationStatusOption.isPresent()) { final OperationStateEnum operationStatus = operationStatusOption.get(); if (operationStatus != OperationStateEnum.COMPLETED) { final String message = "Unable to instantiate jobId: " + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null") + " OperationStatus: " + operationStatus; LOGGER.error(message); exceptionUtil.buildAndThrowWorkflowException(execution, 1207, message); } LOGGER.debug("Successfully completed instatiation of job {}", vnfInstantiateResponse); } } @Autowired  MonitorVnfmCreateJobTask(final VnfmAdapterServiceProvider vnfmAdapterServiceProvider,
            final ExceptionBuilder exceptionUtil); void getCurrentOperationStatus(final BuildingBlockExecution execution); void timeOutLogFailue(final BuildingBlockExecution execution); void checkIfOperationWasSuccessful(final BuildingBlockExecution execution);  }### Answer:
@Test public void testCheckIfOperationWasSuccessful() throws Exception { stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED)); MonitorVnfmCreateJobTask objUnderTest = Mockito.spy(getEtsiVnfMonitorJobTask()); objUnderTest.checkIfOperationWasSuccessful(stubbedxecution); verify(objUnderTest, times(1)).checkIfOperationWasSuccessful(stubbedxecution); }
@Test public void testCheckIfOperationWasSuccessfulWithPending() throws Exception { final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask(); stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.PROCESSING)); objUnderTest.checkIfOperationWasSuccessful(stubbedxecution); verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1207), anyString()); }
@Test public void testCheckIfOperationWasSuccessfulEmpty() throws Exception { MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask(); stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse()); stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent()); objUnderTest.checkIfOperationWasSuccessful(stubbedxecution); verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1206), anyString()); }