6f76c83c6feb1360687a4e38ea74751970fc47f0
[so.git] /
1
2 /*
3  * ============LICENSE_START======================================================= ONAP : SO
4  * ================================================================================ Copyright 2019 TechMahindra
5  * ================================================================================= Licensed under the Apache License,
6  * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy
7  * of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
12  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
13  * specific language governing permissions and limitations under the License.
14  * ============LICENSE_END=========================================================
15  */
16
17 package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
18
19 import static org.junit.Assert.assertTrue;
20 import static org.mockito.ArgumentMatchers.any;
21 import static org.mockito.ArgumentMatchers.eq;
22 import static org.mockito.Mockito.doThrow;
23 import static org.mockito.Mockito.when;
24 import java.util.UUID;
25 import org.camunda.bpm.engine.delegate.BpmnError;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.mockito.ArgumentMatchers;
29 import org.mockito.InjectMocks;
30 import org.mockito.Mock;
31 import org.onap.so.bpmn.BaseTaskTest;
32 import org.onap.so.bpmn.common.BuildingBlockExecution;
33 import org.onap.so.bpmn.infrastructure.aai.tasks.AAIUpdateTasks;
34 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
35 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
36 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
37 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
38 import org.onap.so.client.exception.BBObjectNotFoundException;
39
40 public class ConfigDeployVnfTest extends BaseTaskTest {
41
42     @InjectMocks
43     private ConfigDeployVnf configDeployVnf = new ConfigDeployVnf();
44     @Mock
45     AAIUpdateTasks aAIUpdateTasks = new AAIUpdateTasks();
46
47
48     private GenericVnf genericVnf;
49     private ServiceInstance serviceInstance;
50     private RequestContext requestContext;
51     private String msoRequestId;
52
53     @Before
54     public void before() throws BBObjectNotFoundException {
55         genericVnf = setGenericVnf();
56         serviceInstance = setServiceInstance();
57         msoRequestId = UUID.randomUUID().toString();
58         requestContext = setRequestContext();
59         requestContext.setMsoRequestId(msoRequestId);
60         gBBInput.setRequestContext(requestContext);
61
62         doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
63                 .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
64         when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
65                 .thenReturn(genericVnf);
66         when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
67                 .thenReturn(serviceInstance);
68     }
69
70
71
72     @Test
73     public void preProcessAbstractCDSProcessingTest() throws Exception {
74
75         configDeployVnf.preProcessAbstractCDSProcessing(execution);
76
77         assertTrue(true);
78     }
79
80     @Test
81     public void updateAAIConfigureTaskTest() throws Exception {
82
83         configDeployVnf.updateAAIConfigure(execution);
84         assertTrue(true);
85     }
86
87     @Test
88     public void updateAAIConfiguredTaskTest() throws Exception {
89         configDeployVnf.updateAAIConfigured(execution);
90         assertTrue(true);
91     }
92
93 }