2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.bpmn.infrastructure.activity;
24 import static org.junit.Assert.assertEquals;
26 import java.nio.file.Files;
27 import java.nio.file.Paths;
29 import org.camunda.bpm.engine.delegate.DelegateExecution;
30 import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
31 import org.junit.Before;
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;
39 public class ExecuteActivityTest extends BaseTaskTest {
41 protected ExecuteActivity executeActivity;
43 private DelegateExecution execution;
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);
58 public void buildBuildingBlock_Test(){
59 BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
60 assertEquals(bb.getBpmnFlowName(), "testActivityName");
61 assertEquals(bb.getKey(), "");
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);