d4956f9349fb732fe035c6b82820ffe6143ab9f2
[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.onap.so.bpmn.BaseTaskTest;
35 import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
36 import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
37 import org.springframework.beans.factory.annotation.Autowired;
38
39 public class ExecuteActivityTest extends BaseTaskTest {
40         @Autowired
41         protected ExecuteActivity executeActivity;
42         
43         private DelegateExecution execution;
44         
45         @Before
46         public void before() throws Exception {
47                 execution = new DelegateExecutionFake();                
48                 execution.setVariable("vnfType", "testVnfType");
49                 execution.setVariable("requestAction", "testRequestAction");
50                 execution.setVariable("mso-request-id", "testMsoRequestId");
51                 execution.setVariable("vnfId", "testVnfId");
52                 execution.setVariable("serviceInstanceId", "testServiceInstanceId");
53                 String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
54                 execution.setVariable("bpmnRequest", bpmnRequest);
55         }
56         
57         @Test
58         public void buildBuildingBlock_Test(){
59                 BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
60                 assertEquals(bb.getBpmnFlowName(), "testActivityName");
61                 assertEquals(bb.getKey(), "");          
62         }
63         
64         @Test
65         public void executeBuildingBlock_Test() throws Exception {
66                 BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
67                 ExecuteBuildingBlock ebb = executeActivity.buildExecuteBuildingBlock(execution, "testMsoRequestId", bb);
68                 assertEquals(ebb.getVnfType(), "testVnfType");
69                 assertEquals(ebb.getRequestAction(), "testRequestAction");
70                 assertEquals(ebb.getRequestId(), "testMsoRequestId");
71                 assertEquals(ebb.getWorkflowResourceIds().getVnfId(), "testVnfId");
72                 assertEquals(ebb.getWorkflowResourceIds().getServiceInstanceId(), "testServiceInstanceId");
73                 assertEquals(ebb.getBuildingBlock(), bb);       
74         }
75         
76 }