### Question:
RollbackService extends ExternalTaskUtils { public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { mdcSetup.setupMDC(externalTask); logger.trace("Executing External Task Rollback Service"); Map<String, Object> variables = new HashMap<>(); boolean success = false; boolean pollRollbackStatus = false; try { String xmlRequest = externalTask.getVariable("openstackAdapterTaskRequest"); if (xmlRequest != null) { Optional<String> requestType = findRequestType(xmlRequest); if ("createVolumeGroupRequest".equals(requestType.get())) { logger.debug("Executing External Task Rollback Service for Create Volume Group"); CreateVolumeGroupRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateVolumeGroupRequest.class); vnfAdapterImpl.deleteVnf(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), req.getVolumeGroupName(), req.getMsoRequest(), false); pollRollbackStatus = true; success = true; } else if ("createVfModuleRequest".equals(requestType.get())) { logger.debug("Executing External Task Rollback Service for Create Vf Module"); CreateVfModuleRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateVfModuleRequest.class); vnfAdapterImpl.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), req.getVfModuleName(), req.getVnfId(), req.getVfModuleId(), req.getModelCustomizationUuid(), req.getMsoRequest(), new Holder<>()); pollRollbackStatus = true; success = true; } else if ("createNetworkRequest".equals(requestType.get())) { logger.debug("Executing External Task Rollback Service for Create Network"); Holder<Boolean> networkDeleted = new Holder<>(); CreateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateNetworkRequest.class); networkAdapterImpl.deleteNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), req.getModelCustomizationUuid(), req.getNetworkName(), req.getMsoRequest(), networkDeleted, false); pollRollbackStatus = true; success = true; } } } catch (Exception e) { logger.error("Error during External Task Rollback Service", e); } variables.put("OpenstackRollbackSuccess", success); variables.put("rollbackPerformed", true); variables.put("PollRollbackStatus", pollRollbackStatus); if (success) { externalTaskService.complete(externalTask, variables); logger.debug("The External Task Id: {} Successful", externalTask.getId()); } else { logger.debug("The External Task Id: {} Failed. Not Retrying", externalTask.getId()); externalTaskService.complete(externalTask, variables); } }  void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService);  }### Answer:
@Test public void testExecuteExternalTask() throws VnfException, MsoException, IOException { String payload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/vnfAdapterTaskRequestCreate.xml"))); Stack stack = new Stack(); stack.setId("heatId"); Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(payload); Mockito.doNothing().when(vnfAdapterImpl).deleteVfModule(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); Mockito.doNothing().when(mockExternalTaskService).complete(Mockito.any(), Mockito.any()); rollbackService.executeExternalTask(mockExternalTask, mockExternalTaskService); Mockito.verify(vnfAdapterImpl, Mockito.times(1)).deleteVfModule(Mockito.eq("regionOne"), Mockito.eq("CloudOwner"), Mockito.eq("0422ffb57ba042c0800a29dc85ca70f8"), Mockito.eq("dummy_id"), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(), Mockito.any(), Mockito.any()); Mockito.verify(mockExternalTaskService).complete(Mockito.eq(mockExternalTask), Mockito.any()); }