* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.appc.executor.impl;
 
+import com.att.eelf.configuration.Configuration;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import java.net.InetAddress;
+import java.util.UUID;
 import org.onap.appc.domainmodel.lcm.Status;
 import org.onap.appc.domainmodel.lcm.VNFOperation;
 import org.onap.appc.executor.impl.objects.CommandRequest;
 import org.onap.appc.domainmodel.lcm.RuntimeContext;
 import org.onap.appc.workflow.WorkFlowManager;
 import org.onap.appc.workflow.objects.WorkflowRequest;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
 import org.osgi.framework.ServiceReference;
 import org.slf4j.MDC;
 
-import java.net.InetAddress;
-import java.util.UUID;
 
-import static com.att.eelf.configuration.Configuration.*;
 
 /**
  * This abstract class is base class for all Command tasks. All command task must inherit this class.
         } else {
             logger.info("AAIService error from bundlecontext");
             logger.warn("Cannot find service reference for org.onap.ccsdk.sli.adaptors.aai.AAIService");
-
         }
     }
 
 
     @Override
     public void run() {
-        logger.debug("Starting execution of command :"+ commandRequest);
+        logger.debug("Starting execution of command :" + commandRequest);
         setInitialLogProperties(commandRequest);
         final RuntimeContext runtimeContext = commandRequest.getCommandExecutorInput().getRuntimeContext();
 
-
         WorkflowRequest workflowRequest = new WorkflowRequest();
         workflowRequest.setRequestContext(runtimeContext.getRequestContext());
         workflowRequest.setResponseContext(runtimeContext.getResponseContext());
         workflowRequest.setVnfContext(runtimeContext.getVnfContext());
-        logger.debug("Executing workflow :"+ workflowRequest);
+        logger.debug("Executing workflow :" + workflowRequest);
         workflowManager.executeWorkflow(workflowRequest);
         logger.debug("Completed execution workflow with response:"+ commandRequest.getCommandExecutorInput().getRuntimeContext().getResponseContext());
         try {
     private void updateAAIForTerminate(CommandRequest commandRequest) throws AAIServiceException {
         final int statusCode = commandRequest.getCommandExecutorInput().getRuntimeContext().getResponseContext().getStatus().getCode();
 
-        if (logger.isDebugEnabled()) {
-            logger.debug("Workflow Execution Status = "+ statusCode);
-        }
+        logger.debug("Workflow Execution Status = "+ statusCode);
         if (statusCode == 100 || statusCode == 400) {
             SvcLogicContext ctx = new SvcLogicContext();
             ctx = getVnfdata(commandRequest.getCommandExecutorInput().getRuntimeContext().getVnfContext().getId(), "vnf", ctx);
-            deleteGenericVnfData(commandRequest.getCommandExecutorInput().getRuntimeContext().getVnfContext().getId(), ctx.getAttribute("vnf.resource-version"));
-
+            deleteGenericVnfData(commandRequest.getCommandExecutorInput().getRuntimeContext().getVnfContext().getId(),
+                    ctx.getAttribute("vnf.resource-version"));
         }
     }
 
     private SvcLogicContext getVnfdata(String vnf_id, String prefix,SvcLogicContext ctx) {
-        String key="generic-vnf.vnf-id = '"+ vnf_id+"'"+" AND http-header.Real-Time = 'true'";
-        logger.debug("inside getVnfdata=== "+key);
+        String key="generic-vnf.vnf-id = '" + vnf_id + "'" + " AND http-header.Real-Time = 'true'";
+        logger.debug("inside getVnfdata=== " + key);
         try {
             SvcLogicResource.QueryStatus response = aaiService.query("generic-vnf", false, null, key,prefix, null, ctx);
             if(SvcLogicResource.QueryStatus.NOT_FOUND.equals(response)){
                 logger.warn("VNF " + vnf_id + " not found while updating A&AI");
-                throw new RuntimeException("VNF not found for vnf_id = "+ vnf_id);
+                throw new RuntimeException("VNF not found for vnf_id = " + vnf_id);
             }
             else if(SvcLogicResource.QueryStatus.FAILURE.equals(response)){
-                throw new RuntimeException("Error Querying AAI with vnfID = " +vnf_id);
+                throw new RuntimeException("Error Querying AAI with vnfID = " + vnf_id);
             }
             logger.info("AAIResponse: " + response.toString());
         } catch (SvcLogicException e) {
-            logger.error("Error in getVnfdata "+ e);
+            logger.error("Error in getVnfdata " + e);
             throw new RuntimeException(e);
         }
         return ctx;
         String reqId = request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getCommonHeader().getRequestId();
 
         try {
-            MDC.put(MDC_KEY_REQUEST_ID, UUID.fromString(reqId).toString());
+            MDC.put(Configuration.MDC_KEY_REQUEST_ID, UUID.fromString(reqId).toString());
             //reaching here without exception means existing RequestId is
             //valid UUID as per ECOMP logging standards
         } catch (Exception e) {
             String reqIdUUID = UUID.randomUUID().toString();
-            MDC.put(MDC_KEY_REQUEST_ID, reqIdUUID);
+            MDC.put(Configuration.MDC_KEY_REQUEST_ID, reqIdUUID);
             logger.info("Replaced invalid requestID of " + reqId + ".  New value is " + reqIdUUID + ".");
         }
-        if (request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getActionIdentifiers().getServiceInstanceId() != null)
-            MDC.put(MDC_SERVICE_INSTANCE_ID, request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getActionIdentifiers().getServiceInstanceId());
-        MDC.put(LoggingConstants.MDCKeys.PARTNER_NAME, request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getCommonHeader().getOriginatorId());
-        MDC.put(MDC_SERVICE_NAME, request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getAction().name());
+        if (request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getActionIdentifiers().getServiceInstanceId() != null) {
+            MDC.put(Configuration.MDC_SERVICE_INSTANCE_ID, 
+                    request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getActionIdentifiers().getServiceInstanceId());
+            MDC.put(LoggingConstants.MDCKeys.PARTNER_NAME, 
+                    request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getCommonHeader().getOriginatorId());
+            MDC.put(Configuration.MDC_SERVICE_NAME, 
+                    request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getAction().name());
+        }
         try {
-            MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName());
-            MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
+            MDC.put(Configuration.MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName());
+            MDC.put(Configuration.MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
         } catch (Exception e) {
-            logger.error(e.getMessage(),e);
+            logger.error(e.getMessage(), e);
         }
-        MDC.put(MDC_INSTANCE_UUID, ""); // make instanse_UUID generation once during APPC-instanse deploying
+        MDC.put(Configuration.MDC_INSTANCE_UUID, ""); // make instanse_UUID generation once during APPC-instance deploying
     }
 
     private void clearRequestLogProperties()
     {
         try {
-            MDC.remove(MDC_KEY_REQUEST_ID);
-            MDC.remove(MDC_SERVICE_INSTANCE_ID);
-            MDC.remove(MDC_SERVICE_NAME);
+            MDC.remove(Configuration.MDC_KEY_REQUEST_ID);
+            MDC.remove(Configuration.MDC_SERVICE_INSTANCE_ID);
+            MDC.remove(Configuration.MDC_SERVICE_NAME);
             MDC.remove(LoggingConstants.MDCKeys.PARTNER_NAME);
         } catch (Exception e) {
-            logger.error(e.getMessage(),e);
+            logger.error(e.getMessage(), e);
         }
     }
-    
+
     public boolean deleteGenericVnfData(String vnf_id, String resourceVersion) throws AAIServiceException {
         boolean response = false;
 
 
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.appc.executor;
+package org.onap.appc.executor.impl;
 /**
  * 
  */
 
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.onap.appc.domainmodel.lcm.*;
 import org.onap.appc.exceptions.APPCException;
 import org.onap.appc.executionqueue.ExecutionQueueService;
-import org.onap.appc.executor.impl.*;
 import org.onap.appc.executor.impl.objects.CommandRequest;
 import org.onap.appc.executor.objects.CommandExecutorInput;
-import org.onap.appc.lifecyclemanager.LifecycleManager;
 import org.onap.appc.requesthandler.RequestHandler;
 import org.onap.appc.workflow.WorkFlowManager;
 import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
 
 import java.util.Date;
 import java.util.concurrent.TimeUnit;
 
-import static junit.framework.Assert.assertTrue;
-import static org.powermock.api.support.membermodification.MemberMatcher.method;
 
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({CommandTask.class,CommandExecutorImpl.class})
 public class TestCommandExecutor {
 
-        private static final String TTL_FLAG= "TTL";
         private static final String API_VERSION= "2.0.0";
         private static final String ORIGINATOR_ID= "1";
 
             timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "2", VNFOperation.Configure,"15","") ;
     private CommandExecutorInput commandExecutorInputSync = pouplateCommandExecutorInput("FIREWALL", 30, "1.0",
             timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "2", VNFOperation.Sync,"15","") ;
+    private CommandTask commandTask;
 
     @Before
     public void init()throws Exception {
 
         executionQueueService = Mockito.mock(ExecutionQueueService.class);
 
-        commandExecutor = new CommandExecutorImpl();
+        commandExecutor = Mockito.spy(new CommandExecutorImpl());
         commandExecutor.setExecutionQueueService(executionQueueService);
         commandExecutor.setRequestHandler(requestHandler);
         commandExecutor.setWorkflowManager(workflowManager);
         commandExecutor.initialize();
-        CommandTask commandTask = Mockito.mock(CommandTask.class);
+        commandTask = Mockito.mock(CommandTask.class);
         Mockito.when(commandTask.getCommandRequest()).thenReturn(new CommandRequest(commandExecutorInputConfigure));
         PowerMockito.whenNew(CommandTask.class).withParameterTypes(RequestHandler.class,WorkFlowManager.class).withArguments(requestHandler,workflowManager).thenReturn(commandTask);
     }
-        
 
     @Test
     public void testPositiveFlow_LCM() throws Exception {
-        //Map <String,Object> flags = setTTLInFlags("30");
         try {
+            Mockito.doReturn(commandTask).when(commandExecutor).getCommandTask(Mockito.any(), Mockito.any());
             commandExecutor.executeCommand(commandExecutorInputConfigure);
         } catch (APPCException e) {
             Assert.fail(e.toString());
         }
-
     }
 
     @Test(expected = APPCException.class)
             commandExecutor.executeCommand(commandExecutorInputSync);
     }
 
-    
     private CommandExecutorInput pouplateCommandExecutorInput(String vnfType, int ttl, String vnfVersion, Date timeStamp, String apiVersion, String requestId, String originatorID, String subRequestID, VNFOperation action, String vnfId , String payload){
         CommandExecutorInput commandExecutorInput = createCommandExecutorInputWithSubObjects();
         RuntimeContext runtimeContext = commandExecutorInput.getRuntimeContext();
         runtimeContext.setVnfContext(vnfContext);
         return commandExecutorInput;
     }
-
 }
 
 
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.appc.executor;
+package org.onap.appc.executor.impl;
 
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.isA;
+import static org.hamcrest.beans.HasPropertyWithValue.hasProperty;
+import static org.mockito.Matchers.anyObject;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
 import org.onap.appc.domainmodel.lcm.*;
-import org.onap.appc.executor.impl.CommandExecutorImpl;
 import org.onap.appc.executor.impl.CommandTask;
 import org.onap.appc.executor.impl.objects.CommandRequest;
 import org.onap.appc.executor.objects.CommandExecutorInput;
 import org.onap.appc.requesthandler.RequestHandler;
 import org.onap.appc.workflow.WorkFlowManager;
-import org.onap.appc.workflow.objects.WorkflowRequest;
 import org.onap.appc.workflow.objects.WorkflowResponse;
+import org.onap.ccsdk.sli.adaptors.aai.AAIRequest;
 import org.onap.ccsdk.sli.adaptors.aai.AAIService;
-import org.osgi.framework.*;
+import org.onap.ccsdk.sli.adaptors.aai.AAIServiceException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
 import org.powermock.api.mockito.PowerMockito;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
-
+import org.powermock.reflect.Whitebox;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
 
 /**
  * @author sushilma
  * @since September 04, 2017
  */
 @RunWith(PowerMockRunner.class)
-@PrepareForTest({FrameworkUtil.class,AAIService.class,BundleContext.class,ServiceReference.class,
-        BundleReference.class,Bundle.class,Filter.class,BundleListener.class,InvalidSyntaxException.class,
-        BundleException.class,FrameworkListener.class,ServiceRegistration.class,ServiceListener.class,
-        Version.class})
+@PrepareForTest({FrameworkUtil.class, InetAddress.class})
 public class TestCommandTask {
     CommandTask task ;
     private RequestHandler requestHandler;
     private WorkFlowManager workflowManager;
-    private CommandRequest commandRequest;
     private AAIService aaiService;
 
     private BundleContext bundleContext = Mockito.mock(BundleContext.class);
     private static final String TTL_FLAG= "TTL";
     private static final String API_VERSION= "2.0.0";
     private static final String ORIGINATOR_ID= "1";
+
+    @Rule
+    public ExpectedException expectedEx = ExpectedException.none();
+
     @Before
-    public void init(){
+    public void init() throws UnknownHostException{
         aaiService =  Mockito.mock(AAIService.class);
-/*        PowerMockito.mockStatic(FrameworkUtil.class);
-        Mockito.when(bundleContext.getServiceReference(AAIService.class.getName())).thenReturn(sref);
-        Mockito.when(bundleContext.getService(any())).thenReturn(aaiService);
-        Mockito.when(FrameworkUtil.getBundle(AAIService.class).getBundleContext()).thenReturn(bundleContext);*/
-
         PowerMockito.mockStatic(FrameworkUtil.class);
         PowerMockito.when(FrameworkUtil.getBundle(AAIService.class)).thenReturn(bundleService);
         PowerMockito.when(bundleService.getBundleContext()).thenReturn(bundleContext);
         PowerMockito.when(bundleContext.getServiceReference(AAIService.class.getName())).thenReturn(sref);
         PowerMockito.when(bundleContext.getService(sref)).thenReturn(aaiService);
-
-
         requestHandler =  Mockito.mock(RequestHandler.class);
         workflowManager = Mockito.mock(WorkFlowManager.class);
-        task = new CommandTask(requestHandler ,workflowManager );
+        task = Mockito.spy(new CommandTask(requestHandler, workflowManager));
     }
 
     @Test
         Mockito.when(workflowManager.executeWorkflow(anyObject())).thenReturn(getWorkflowResponse());
         task.setWorkflowManager(workflowManager);
         task.setRequestHandler(requestHandler);
-        task.setCommandRequest(getCommandRequest("FIREWALL",30,new Date(), "11" ,setTTLInFlags("30"),VNFOperation.Sync, "1", "1.0"));
+        task.setCommandRequest(getCommandRequest("FIREWALL", 30, new Date(), "11", setTTLInFlags("30"), VNFOperation.Sync, "1", "1.0"));
         task.run();
         Assert.assertNotNull(task.getCommandRequest().getCommandExecutorInput().getRuntimeContext().getResponseContext());
     }
         Mockito.when(workflowManager.executeWorkflow(anyObject())).thenReturn(getWorkflowResponse());
         task.setWorkflowManager(workflowManager);
         task.setRequestHandler(requestHandler);
-        task.setCommandRequest(getCommandRequest("FIREWALL",30,new Date(), "12" ,setTTLInFlags("30"),VNFOperation.Terminate, "2", "1.0"));
-        setResponseContext(300,task.getCommandRequest().getCommandExecutorInput().getRuntimeContext());
+        task.setCommandRequest(getCommandRequest("FIREWALL", 30, new Date(), "12" , setTTLInFlags("30"), VNFOperation.Terminate, "2", "1.0"));
+        setResponseContext(300, task.getCommandRequest().getCommandExecutorInput().getRuntimeContext());
         task.run();
         Assert.assertNotNull(task.getCommandRequest().getCommandExecutorInput().getRuntimeContext().getResponseContext());
     }
 
+    @Test
+    public void testRunPositiveTerminateSucceeded() throws SvcLogicException, AAIServiceException{
+        AAIService mockAai = Mockito.mock(AAIService.class);
 
-    @Ignore
-    public void testRunPositiveTerminateSuccess(){
+        Mockito.when(mockAai.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
+                Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any(SvcLogicContext.class))).thenReturn(SvcLogicResource.QueryStatus.SUCCESS);
+        Mockito.when(mockAai.getRequestFromResource("generic-vnf")).thenReturn(Mockito.mock(AAIRequest.class));
+        Mockito.when(mockAai.delete(Mockito.any(AAIRequest.class), Mockito.anyString())).thenReturn(true);
+        Whitebox.setInternalState(task, "aaiService", mockAai);
         Mockito.when(workflowManager.executeWorkflow(anyObject())).thenReturn(getWorkflowResponse());
         task.setWorkflowManager(workflowManager);
         task.setRequestHandler(requestHandler);
-        task.setCommandRequest(getCommandRequest("FIREWALL",30,new Date(), "12" ,setTTLInFlags("30"),VNFOperation.Terminate, "2", "1.0"));
-        setResponseContext(100,task.getCommandRequest().getCommandExecutorInput().getRuntimeContext());
+        task.setCommandRequest(getCommandRequest("FIREWALL", 30, new Date(), "12" , setTTLInFlags("30"), VNFOperation.Terminate, "2", "1.0"));
+        setResponseContext(100, task.getCommandRequest().getCommandExecutorInput().getRuntimeContext());
+        task.run();
+    }
+
+    @Test
+    public void testRunPositiveTerminateNotFound() throws SvcLogicException, AAIServiceException{
+        AAIService mockAai = Mockito.mock(AAIService.class);
+
+        Mockito.when(mockAai.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
+                Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any(SvcLogicContext.class)))
+                .thenReturn(SvcLogicResource.QueryStatus.NOT_FOUND);
+        Mockito.when(mockAai.getRequestFromResource("generic-vnf")).thenReturn(Mockito.mock(AAIRequest.class));
+        Mockito.when(mockAai.delete(Mockito.any(AAIRequest.class), Mockito.anyString())).thenReturn(true);
+        Whitebox.setInternalState(task, "aaiService", mockAai);
+        Mockito.when(workflowManager.executeWorkflow(anyObject())).thenReturn(getWorkflowResponse());
+        task.setWorkflowManager(workflowManager);
+        task.setRequestHandler(requestHandler);
+        task.setCommandRequest(getCommandRequest("FIREWALL", 30, new Date(), "12" , setTTLInFlags("30"), VNFOperation.Terminate, "2", "1.0"));
+        setResponseContext(100, task.getCommandRequest().getCommandExecutorInput().getRuntimeContext());
+        expectedEx.expect(RuntimeException.class);
+        expectedEx.expectMessage("VNF not found for vnf_id = ");
+        task.run();
+    }
+
+    @Test
+    public void testRunPositiveTerminateFailure() throws SvcLogicException, AAIServiceException{
+        AAIService mockAai = Mockito.mock(AAIService.class);
+
+        Mockito.when(mockAai.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
+                Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any(SvcLogicContext.class)))
+                .thenReturn(SvcLogicResource.QueryStatus.FAILURE);
+        Mockito.when(mockAai.getRequestFromResource("generic-vnf")).thenReturn(Mockito.mock(AAIRequest.class));
+        Mockito.when(mockAai.delete(Mockito.any(AAIRequest.class), Mockito.anyString())).thenReturn(true);
+        Whitebox.setInternalState(task, "aaiService", mockAai);
+        Mockito.when(workflowManager.executeWorkflow(anyObject())).thenReturn(getWorkflowResponse());
+        task.setWorkflowManager(workflowManager);
+        task.setRequestHandler(requestHandler);
+        task.setCommandRequest(getCommandRequest("FIREWALL", 30, new Date(), "12" , setTTLInFlags("30"), VNFOperation.Terminate, "2", "1.0"));
+        setResponseContext(100, task.getCommandRequest().getCommandExecutorInput().getRuntimeContext());
+        expectedEx.expect(RuntimeException.class);
+        expectedEx.expectMessage("Error Querying AAI with vnfID = ");
+        task.run();
+    }
+
+    @Test
+    public void testRunPositiveAaiServiceException() throws SvcLogicException, AAIServiceException{
+        AAIService mockAai = Mockito.mock(AAIService.class);
+
+        Mockito.when(mockAai.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
+                Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any(SvcLogicContext.class)))
+                .thenReturn(SvcLogicResource.QueryStatus.SUCCESS);
+        Mockito.when(mockAai.getRequestFromResource("generic-vnf")).thenReturn(Mockito.mock(AAIRequest.class));
+        Mockito.when(mockAai.delete(Mockito.any(AAIRequest.class), Mockito.anyString())).thenThrow(new AAIServiceException("ERROR IN DELETE"));
+        Whitebox.setInternalState(task, "aaiService", mockAai);
+        Mockito.when(workflowManager.executeWorkflow(anyObject())).thenReturn(getWorkflowResponse());
+        task.setWorkflowManager(workflowManager);
+        task.setRequestHandler(requestHandler);
+        task.setCommandRequest(getCommandRequest("FIREWALL", 30, new Date(), "12" , setTTLInFlags("30"), VNFOperation.Terminate, "2", "1.0"));
+        setResponseContext(100, task.getCommandRequest().getCommandExecutorInput().getRuntimeContext());
+        expectedEx.expect(RuntimeException.class);
+        expectedEx.expectCause(allOf(isA(AAIServiceException.class),
+                hasProperty("message", is("ERROR IN DELETE"))));
+        task.run();
+    }
+
+    @Test
+    public void testRunSvcLogicException() throws SvcLogicException, AAIServiceException {
+        AAIService mockAai = Mockito.mock(AAIService.class);
+
+        Mockito.when(mockAai.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
+                Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any(SvcLogicContext.class)))
+                .thenThrow(new SvcLogicException());
+        Mockito.when(mockAai.getRequestFromResource("generic-vnf")).thenReturn(Mockito.mock(AAIRequest.class));
+        Mockito.when(mockAai.delete(Mockito.any(AAIRequest.class), Mockito.anyString())).thenReturn(true);
+        Whitebox.setInternalState(task, "aaiService", mockAai);
+        Mockito.when(workflowManager.executeWorkflow(anyObject())).thenReturn(getWorkflowResponse());
+        task.setWorkflowManager(workflowManager);
+        task.setRequestHandler(requestHandler);
+        task.setCommandRequest(getCommandRequest("FIREWALL", 30, new Date(), "12" , setTTLInFlags("30"), VNFOperation.Terminate, "2", "1.0"));
+        setResponseContext(100, task.getCommandRequest().getCommandExecutorInput().getRuntimeContext());
+        expectedEx.expect(RuntimeException.class);
+        expectedEx.expectCause(isA(SvcLogicException.class));
         task.run();
-        Assert.assertNotNull(task.getCommandRequest().getCommandExecutorInput().getRuntimeContext().getResponseContext());
     }
 
     private WorkflowResponse getWorkflowResponse (){
         runtimeContext.setResponseContext(responseContext);
     }
 
-    private CommandRequest getCommandRequest(String vnfType , Integer ttl , Date timeStamp, String requestId,
-                                             Map<String,Object> flags, VNFOperation command , String vnfId, String vnfVersion ){
+    private CommandRequest getCommandRequest(String vnfType, Integer ttl, Date timeStamp, String requestId,
+                                             Map<String, Object> flags, VNFOperation command, String vnfId, String vnfVersion ){
 
-        CommandExecutorInput commandExecutorInput = pouplateCommandExecutorInput(vnfType, ttl, vnfVersion, timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "", command, vnfId, "");
+        CommandExecutorInput commandExecutorInput =
+                pouplateCommandExecutorInput(vnfType, ttl, vnfVersion, timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "", command, vnfId, "");
         CommandRequest request = new CommandRequest(commandExecutorInput);
         request.setCommandExecutorInput(commandExecutorInput);
         request.setCommandInTimeStamp(new Date());
         return request;
     }
 
-    private CommandExecutorInput pouplateCommandExecutorInput(String vnfType, int ttl, String vnfVersion, Date timeStamp, String apiVersion, String requestId, String originatorID, String subRequestID, VNFOperation action, String vnfId , String payload){
+    private CommandExecutorInput pouplateCommandExecutorInput(String vnfType, int ttl, String vnfVersion, Date timeStamp, String apiVersion,
+            String requestId, String originatorID, String subRequestID, VNFOperation action, String vnfId , String payload){
         CommandExecutorInput commandExecutorInput = createCommandExecutorInputWithSubObjects();
         RuntimeContext runtimeContext = commandExecutorInput.getRuntimeContext();
         RequestContext requestContext = runtimeContext.getRequestContext();