### Question:
AAIDeleteServiceInstance extends AAIResource implements JavaDelegate { public void execute(DelegateExecution execution) throws Exception { try { String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)); getAaiClient().delete(serviceInstanceURI); execution.setVariable("GENDS_SuccessIndicator", true); } catch (Exception ex) { logger.error(ERROR_MESSAGE, ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ERROR_MESSAGE + ex.getMessage()); } }  void execute(DelegateExecution execution);  }### Answer:
@Test public void executeTest() throws Exception { doReturn("serviceInstanceId").when(execution).getVariable("serviceInstanceId"); doNothing().when(aaiResourcesClient).delete(isA(AAIResourceUri.class)); doNothing().when(execution).setVariable(isA(String.class), isA(Boolean.class)); aaiDeleteServiceInstance.execute(execution); verify(execution, times(1)).getVariable("serviceInstanceId"); verify(aaiResourcesClient, times(1)).delete(isA(AAIResourceUri.class)); verify(execution, times(1)).setVariable("GENDS_SuccessIndicator", true); }
@Test public void executeExceptionTest() throws Exception { expectedException.expect(BpmnError.class); doReturn("testProcessKey").when(execution).getVariable("testProcessKey"); doReturn("serviceInstanceId").when(execution).getVariable("serviceInstanceId"); doThrow(RuntimeException.class).when(aaiResourcesClient).delete(isA(AAIResourceUri.class)); aaiDeleteServiceInstance.execute(execution); }