From 5648fffeaf625dde2b9207ceae87979082a68409 Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Wed, 19 Sep 2018 14:03:47 -0400 Subject: Workflow Activities Execution Environment Add a license header to ExecuteActivity.java Fix a JUnit by modifying the values for the expected variables. BBInput changes to support CM flows Implement JavaDelegate for activities execution Change-Id: I9cfc51241d414b85441d1a8443a950b97d14b65f Issue-ID: SO-827 Signed-off-by: Elena Kuleshov --- .../activity/ExecuteActivityTest.java | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java (limited to 'bpmn/so-bpmn-tasks/src/test') diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java new file mode 100644 index 0000000000..d4956f9349 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.activity; + + +import static org.junit.Assert.assertEquals; + +import java.nio.file.Files; +import java.nio.file.Paths; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; + +import org.junit.Test; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.springframework.beans.factory.annotation.Autowired; + +public class ExecuteActivityTest extends BaseTaskTest { + @Autowired + protected ExecuteActivity executeActivity; + + private DelegateExecution execution; + + @Before + public void before() throws Exception { + execution = new DelegateExecutionFake(); + execution.setVariable("vnfType", "testVnfType"); + execution.setVariable("requestAction", "testRequestAction"); + execution.setVariable("mso-request-id", "testMsoRequestId"); + execution.setVariable("vnfId", "testVnfId"); + execution.setVariable("serviceInstanceId", "testServiceInstanceId"); + String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + } + + @Test + public void buildBuildingBlock_Test(){ + BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName"); + assertEquals(bb.getBpmnFlowName(), "testActivityName"); + assertEquals(bb.getKey(), ""); + } + + @Test + public void executeBuildingBlock_Test() throws Exception { + BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName"); + ExecuteBuildingBlock ebb = executeActivity.buildExecuteBuildingBlock(execution, "testMsoRequestId", bb); + assertEquals(ebb.getVnfType(), "testVnfType"); + assertEquals(ebb.getRequestAction(), "testRequestAction"); + assertEquals(ebb.getRequestId(), "testMsoRequestId"); + assertEquals(ebb.getWorkflowResourceIds().getVnfId(), "testVnfId"); + assertEquals(ebb.getWorkflowResourceIds().getServiceInstanceId(), "testServiceInstanceId"); + assertEquals(ebb.getBuildingBlock(), bb); + } + +} -- cgit 1.2.3-korg