Springboot 2.0 upgrade
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / activity / ExecuteActivityTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 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.bpmn.infrastructure.activity;
22
23
24 import static org.junit.Assert.assertEquals;
25
26 import java.nio.file.Files;
27 import java.nio.file.Paths;
28
29 import org.camunda.bpm.engine.delegate.DelegateExecution;
30 import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
31 import org.junit.Before;
32
33 import org.junit.Test;
34 import org.mockito.InjectMocks;
35 import org.onap.so.bpmn.BaseTaskTest;
36 import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
37 import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
38 import org.springframework.beans.factory.annotation.Autowired;
39
40 public class ExecuteActivityTest extends BaseTaskTest {
41         @InjectMocks
42         protected ExecuteActivity executeActivity = new ExecuteActivity();
43         
44         private DelegateExecution execution;
45         
46         @Before
47         public void before() throws Exception {
48                 execution = new DelegateExecutionFake();                
49                 execution.setVariable("vnfType", "testVnfType");
50                 execution.setVariable("requestAction", "testRequestAction");
51                 execution.setVariable("mso-request-id", "testMsoRequestId");
52                 execution.setVariable("vnfId", "testVnfId");
53                 execution.setVariable("serviceInstanceId", "testServiceInstanceId");
54                 String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
55                 execution.setVariable("bpmnRequest", bpmnRequest);
56         }
57         
58         @Test
59         public void buildBuildingBlock_Test(){
60                 BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
61                 assertEquals(bb.getBpmnFlowName(), "testActivityName");
62                 assertEquals(bb.getKey(), "");          
63         }
64         
65         @Test
66         public void executeBuildingBlock_Test() throws Exception {
67                 BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
68                 ExecuteBuildingBlock ebb = executeActivity.buildExecuteBuildingBlock(execution, "testMsoRequestId", bb);
69                 assertEquals(ebb.getVnfType(), "testVnfType");
70                 assertEquals(ebb.getRequestAction(), "testRequestAction");
71                 assertEquals(ebb.getRequestId(), "testMsoRequestId");
72                 assertEquals(ebb.getWorkflowResourceIds().getVnfId(), "testVnfId");
73                 assertEquals(ebb.getWorkflowResourceIds().getServiceInstanceId(), "testServiceInstanceId");
74                 assertEquals(ebb.getBuildingBlock(), bb);       
75         }
76         
77 }