2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.so.adapters.appc.orchestrator.service;
 
  23 import static org.mockito.ArgumentMatchers.any;
 
  24 import static org.mockito.Mockito.doNothing;
 
  25 import static org.mockito.Mockito.doReturn;
 
  26 import org.camunda.bpm.client.task.ExternalTask;
 
  27 import org.camunda.bpm.client.task.ExternalTaskService;
 
  28 import org.junit.Before;
 
  29 import org.junit.Test;
 
  30 import org.mockito.InjectMocks;
 
  31 import org.mockito.Mock;
 
  32 import org.mockito.Mockito;
 
  33 import org.mockito.MockitoAnnotations;
 
  34 import org.onap.so.externaltasks.logging.AuditMDCSetup;
 
  35 import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback;
 
  36 import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest;
 
  37 import org.onap.appc.client.lcm.model.Status;
 
  39 public class ApplicationControllerTaskTest extends ApplicationControllerTask {
 
  42     ApplicationControllerTask appcTaskService = new ApplicationControllerTask();
 
  45     ApplicationControllerTaskImpl applicationControllerTaskImpl;
 
  48     ExternalTask mockExternalTask;
 
  51     ExternalTaskService mockExternalTaskService;
 
  54     private AuditMDCSetup mdcSetup;
 
  56     private ApplicationControllerTaskRequest request = new ApplicationControllerTaskRequest();
 
  57     private String msoRequestId = "testRequestId";
 
  61         MockitoAnnotations.initMocks(this);
 
  62         doNothing().when(mdcSetup).setupMDC(mockExternalTask);
 
  63         doReturn(request).when(mockExternalTask).getVariable("appcOrchestratorRequest");
 
  64         doReturn(msoRequestId).when(mockExternalTask).getVariable("mso-request-id");
 
  68     public void executeExternalTask_appc_success_Test() throws Exception {
 
  69         Status status = new Status();
 
  70         doReturn(status).when(applicationControllerTaskImpl).execute(any(String.class),
 
  71                 any(ApplicationControllerTaskRequest.class), any(ApplicationControllerCallback.class));
 
  72         appcTaskService.executeExternalTask(mockExternalTask, mockExternalTaskService);
 
  73         Mockito.verify(applicationControllerTaskImpl).execute(any(String.class),
 
  74                 any(ApplicationControllerTaskRequest.class), any(ApplicationControllerCallback.class));