982b75ae8ed0a41a6dc441fcbd9ff1e0a0775de6
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2019 TechMahindra
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.bpmn.infrastructure.flowspecific.tasks;
22
23 import static org.junit.Assert.assertTrue;
24 import static org.mockito.ArgumentMatchers.any;
25 import static org.mockito.ArgumentMatchers.eq;
26 import static org.mockito.Mockito.doThrow;
27 import static org.mockito.Mockito.when;
28 import java.util.UUID;
29 import org.camunda.bpm.engine.delegate.BpmnError;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.mockito.ArgumentMatchers;
33 import org.mockito.InjectMocks;
34 import org.mockito.Mock;
35 import org.onap.so.bpmn.BaseTaskTest;
36 import org.onap.so.bpmn.common.BuildingBlockExecution;
37 import org.onap.so.bpmn.infrastructure.aai.tasks.AAIUpdateTasks;
38 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
39 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
40 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
41 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
42 import org.onap.so.client.exception.BBObjectNotFoundException;
43
44 public class ConfigDeployVnfTest extends BaseTaskTest {
45
46     @InjectMocks
47     private ConfigDeployVnf configDeployVnf = new ConfigDeployVnf();
48     @Mock
49     AAIUpdateTasks aAIUpdateTasks = new AAIUpdateTasks();
50
51
52     private GenericVnf genericVnf;
53     private ServiceInstance serviceInstance;
54     private RequestContext requestContext;
55     private String msoRequestId;
56
57     @Before
58     public void before() throws BBObjectNotFoundException {
59         genericVnf = setGenericVnf();
60         serviceInstance = setServiceInstance();
61         msoRequestId = UUID.randomUUID().toString();
62         requestContext = setRequestContext();
63         requestContext.setMsoRequestId(msoRequestId);
64         gBBInput.setRequestContext(requestContext);
65
66         doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
67                 .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
68         when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
69                 .thenReturn(genericVnf);
70         when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
71                 .thenReturn(serviceInstance);
72     }
73
74
75
76     @Test
77     public void preProcessAbstractCDSProcessingTest() throws Exception {
78
79         configDeployVnf.preProcessAbstractCDSProcessing(execution);
80
81         assertTrue(true);
82     }
83
84     @Test
85     public void updateAAIConfigureTaskTest() throws Exception {
86
87         configDeployVnf.updateAAIConfigure(execution);
88         assertTrue(true);
89     }
90
91     @Test
92     public void updateAAIConfiguredTaskTest() throws Exception {
93         configDeployVnf.updateAAIConfigured(execution);
94         assertTrue(true);
95     }
96
97 }