228ee90107d5cebe676fa7a43530b6f0c8d4598b
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.so.adapters.appc.orchestrator.service;
22
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;
38
39 public class ApplicationControllerTaskTest extends ApplicationControllerTask {
40
41     @InjectMocks
42     ApplicationControllerTask appcTaskService = new ApplicationControllerTask();
43
44     @Mock
45     ApplicationControllerTaskImpl applicationControllerTaskImpl;
46
47     @Mock
48     ExternalTask mockExternalTask;
49
50     @Mock
51     ExternalTaskService mockExternalTaskService;
52
53     @Mock
54     private AuditMDCSetup mdcSetup;
55
56     private ApplicationControllerTaskRequest request = new ApplicationControllerTaskRequest();
57     private String msoRequestId = "testRequestId";
58
59     @Before
60     public void setup() {
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");
65     }
66
67     @Test
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));
75     }
76 }