summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2019-10-16 13:59:46 +0100
committerwaqas.ikram <waqas.ikram@est.tech>2019-10-23 11:51:27 +0100
commit3b83a490bace15afe62b171242f2315f8805269f (patch)
tree12de5b716f90271b66a8ea7af885c27efbec7fb7 /bpmn/so-bpmn-tasks/src/test
parent86f62530f1813152efbcc3d61f85e1fa6c943e36 (diff)
Adding preload capability using userParams
Change-Id: Id107f2c9c2da643ecb57daaef26dfa2bfd89f8aa Issue-ID: SO-1635 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java128
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java28
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameterRetrieverTaskTest.java248
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameterTest.java79
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/NullInputParameterTest.java62
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProviderImplTest.java (renamed from bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java)14
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/UserParamInputParametersProviderTest.java98
7 files changed, 520 insertions, 137 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java
deleted file mode 100644
index caae90bfff..0000000000
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Ericsson. 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.onap.so.bpmn.BaseTaskTest;
-import org.onap.so.bpmn.common.BuildingBlockExecution;
-import org.onap.so.bpmn.common.exceptions.RequiredExecutionVariableExeception;
-import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParameter;
-import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParametersProvider;
-import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.NullInputParameter;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
-import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
-import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
-import org.onap.so.client.exception.BBObjectNotFoundException;
-
-/**
- * @author waqas.ikram@est.tech
- */
-public class InputParameterRetrieverTaskTest extends BaseTaskTest {
-
- private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
-
- @Mock
- private InputParametersProvider inputParametersProvider;
-
- @Test
- public void testGGetInputParameters_inputParameterStoredInExecutionContext() throws BBObjectNotFoundException {
- final InputParameterRetrieverTask objUnderTest =
- new InputParameterRetrieverTask(inputParametersProvider, extractPojosForBB);
-
- final InputParameter inputParameter = new InputParameter(Collections.emptyMap(), Collections.emptyList());
- when(inputParametersProvider.getInputParameter(Mockito.any(GenericVnf.class))).thenReturn(inputParameter);
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(new GenericVnf());
- objUnderTest.getInputParameters(stubbedxecution);
-
- final Object actual = stubbedxecution.getVariable(Constants.INPUT_PARAMETER);
- assertNotNull(actual);
- assertTrue(actual instanceof InputParameter);
- }
-
- @Test
- public void testGGetInputParameters_ThrowExecption_NullInputParameterStoredInExecutionContext()
- throws BBObjectNotFoundException {
- final InputParameterRetrieverTask objUnderTest =
- new InputParameterRetrieverTask(inputParametersProvider, extractPojosForBB);
-
- when(inputParametersProvider.getInputParameter(Mockito.any(GenericVnf.class)))
- .thenThrow(RuntimeException.class);
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(new GenericVnf());
- objUnderTest.getInputParameters(stubbedxecution);
-
- final Object actual = stubbedxecution.getVariable(Constants.INPUT_PARAMETER);
- assertNotNull(actual);
- assertTrue(actual instanceof NullInputParameter);
- }
-
-
- private class StubbedBuildingBlockExecution implements BuildingBlockExecution {
-
- private final Map<String, Serializable> execution = new HashMap<>();
-
- @Override
- public GeneralBuildingBlock getGeneralBuildingBlock() {
- return null;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getVariable(final String key) {
- return (T) execution.get(key);
- }
-
- @Override
- public <T> T getRequiredVariable(final String key) throws RequiredExecutionVariableExeception {
- return null;
- }
-
- @Override
- public void setVariable(final String key, final Serializable value) {
- execution.put(key, value);
- }
-
- @Override
- public Map<ResourceKey, String> getLookupMap() {
- return Collections.emptyMap();
- }
-
- @Override
- public String getFlowToBeCalled() {
- return null;
- }
-
- @Override
- public int getCurrentSequence() {
- return 0;
- }
-
- }
-}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java
index 7b63e5f811..686b4f80cc 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java
@@ -20,9 +20,11 @@
package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
-import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.DUMMY_URL;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.ADDITIONAL_PARAMS;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.EXT_VIRTUAL_LINKS;
+import java.util.HashMap;
+import java.util.Map;
import java.util.UUID;
-import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.VnfmBasicHttpConfigProvider;
/**
* @author waqas.ikram@est.tech
@@ -30,6 +32,7 @@ import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.VnfmBasicHttpConfigPro
*/
public class TestConstants {
+ public static final String EXT_VIRTUAL_LINK_ID = "ac1ed33d-8dc1-4800-8ce8-309b99c38eec";
public static final String DUMMY_GENERIC_VND_ID = "5956a99d-9736-11e8-8caf-022ac9304eeb";
public static final String DUMMY_BASIC_AUTH = "Basic 123abc";
public static final String DUMMY_URL = "http://localhost:30406/so/vnfm-adapter/v1/";
@@ -38,6 +41,19 @@ public class TestConstants {
public static final String DUMMY_JOB_ID = UUID.randomUUID().toString();
public static final String JOB_STATUS_EXPECTED_URL = DUMMY_URL + "jobs/" + DUMMY_JOB_ID;
+ public static final String EXT_VIRTUAL_LINK_VALUE = "{\"id\":\"" + EXT_VIRTUAL_LINK_ID + "\","
+ + "\"tenant\":{\"cloudOwner\":\"CloudOwner\",\"regionName\":\"RegionOne\","
+ + "\"tenantId\":\"80c26954-2536-4bca-9e20-10f8a2c9c2ad\"},\"resourceId\":\"8ef8cd54-75fd-4372-a6dd-2e05ea8fbd9b\","
+ + "\"extCps\":[{\"cpdId\":\"f449292f-2f0f-4656-baa3-a18d86bac80f\","
+ + "\"cpConfig\":[{\"cpInstanceId\":\"07876709-b66f-465c-99a7-0f4d026197f2\","
+ + "\"linkPortId\":null,\"cpProtocolData\":null}]}],\"extLinkPorts\":null}";
+
+ public static final String ADDITIONAL_PARAMS_VALUE = "{\"image_id\": \"DUMMYVNF\",\"instance_type\": \"m1.small\","
+ + "\"ftp_address\": \"ftp://0.0.0.0:2100/\"}";
+
+ public static final String EXT_VIRTUAL_LINKS_VALUE = "[" + EXT_VIRTUAL_LINK_VALUE + "]";
+
+
public static VnfmBasicHttpConfigProvider getVnfmBasicHttpConfigProvider() {
return getVnfmBasicHttpConfigProvider(DUMMY_URL, DUMMY_BASIC_AUTH);
}
@@ -49,6 +65,14 @@ public class TestConstants {
return vnfmBasicHttpConfigProvider;
}
+ public static Map<String, Object> getUserParamsMap(final String additionalParams,
+ final String extVirtualLinksValue) {
+ final Map<String, Object> userParams = new HashMap<>();
+ userParams.put(ADDITIONAL_PARAMS, additionalParams);
+ userParams.put(EXT_VIRTUAL_LINKS, extVirtualLinksValue);
+ return userParams;
+ }
+
private TestConstants() {}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameterRetrieverTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameterRetrieverTaskTest.java
new file mode 100644
index 0000000000..9003510be7
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameterRetrieverTaskTest.java
@@ -0,0 +1,248 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.ADDITIONAL_PARAMS_VALUE;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.EXT_VIRTUAL_LINKS_VALUE;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.EXT_VIRTUAL_LINK_ID;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.getUserParamsMap;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.exceptions.RequiredExecutionVariableExeception;
+import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants;
+import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.InputParameterRetrieverTask;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.client.sdnc.SDNCClient;
+import org.onap.vnfmadapter.v1.model.ExternalVirtualLink;
+import org.onap.vnfmadapter.v1.model.ExternalVirtualLinkCpConfig;
+import org.onap.vnfmadapter.v1.model.ExternalVirtualLinkExtCps;
+
+/**
+ * @author waqas.ikram@est.tech
+ */
+public class InputParameterRetrieverTaskTest extends BaseTaskTest {
+
+ private static final String INSTANCE_TYPE_VALUE_1 = "m1.small";
+
+ private static final String INSTANCE_TYPE_VALUE_2 = "m1.large";
+
+ private static final String INSTANCE_TYPE = "instance_type";
+
+ private static final String RANDOM_EXT_VIRTUAL_LINK_ID = UUID.randomUUID().toString();
+
+ private static final String CPU_INSTANCE_ID = EXT_VIRTUAL_LINK_ID;
+
+ private static final String FLAVOR_VALUE = "ubuntu";
+
+ private static final String FLAVOR = "flavor_type";
+
+ private final StubbedBuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+
+ @Mock
+ private InputParametersProvider<GenericVnf> sdncInputParametersProvider;
+
+ private final InputParametersProvider<Map<String, Object>> userParamsinputParametersProvider =
+ new UserParamInputParametersProvider();
+
+ @Mock
+ private SDNCClient mockedSdncClient;
+
+ @Test
+ public void testGetInputParameters_inputParameterStoredInExecutionContext() throws BBObjectNotFoundException {
+ final InputParameterRetrieverTask objUnderTest = new InputParameterRetrieverTask(sdncInputParametersProvider,
+ userParamsinputParametersProvider, extractPojosForBB);
+
+
+ final GeneralBuildingBlock buildingBlock =
+ getGeneralBuildingBlock(getUserParamsMap(ADDITIONAL_PARAMS_VALUE, null));
+ stubbedxecution.setGeneralBuildingBlock(buildingBlock);
+
+ final InputParameter inputParameter = new InputParameter(Collections.emptyMap(), Collections.emptyList());
+ when(sdncInputParametersProvider.getInputParameter(Mockito.any(GenericVnf.class))).thenReturn(inputParameter);
+
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(new GenericVnf());
+ objUnderTest.getInputParameters(stubbedxecution);
+
+ final Object actual = stubbedxecution.getVariable(Constants.INPUT_PARAMETER);
+ assertNotNull(actual);
+ assertTrue(actual instanceof InputParameter);
+ final InputParameter actualInputParameter = (InputParameter) actual;
+ final Map<String, String> actualAdditionalParams = actualInputParameter.getAdditionalParams();
+ assertEquals(3, actualAdditionalParams.size());
+
+ final String actualInstanceType = actualAdditionalParams.get(INSTANCE_TYPE);
+ assertEquals(INSTANCE_TYPE_VALUE_1, actualInstanceType);
+
+ }
+
+ @Test
+ public void testGetInputParameters_ThrowExecption_NullInputParameterStoredInExecutionContext()
+ throws BBObjectNotFoundException {
+ final InputParameterRetrieverTask objUnderTest = new InputParameterRetrieverTask(sdncInputParametersProvider,
+ userParamsinputParametersProvider, extractPojosForBB);
+
+ when(sdncInputParametersProvider.getInputParameter(Mockito.any(GenericVnf.class)))
+ .thenThrow(RuntimeException.class);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(new GenericVnf());
+ objUnderTest.getInputParameters(stubbedxecution);
+
+ final Object actual = stubbedxecution.getVariable(Constants.INPUT_PARAMETER);
+ assertNotNull(actual);
+ assertTrue(actual instanceof NullInputParameter);
+ }
+
+ @Test
+ public void testGetInputParameters_SdncAndUserParamInputParameterStoredInExecutionContext()
+ throws BBObjectNotFoundException {
+ final InputParameterRetrieverTask objUnderTest = new InputParameterRetrieverTask(sdncInputParametersProvider,
+ userParamsinputParametersProvider, extractPojosForBB);
+
+
+ final GeneralBuildingBlock buildingBlock =
+ getGeneralBuildingBlock(getUserParamsMap(ADDITIONAL_PARAMS_VALUE, EXT_VIRTUAL_LINKS_VALUE));
+ stubbedxecution.setGeneralBuildingBlock(buildingBlock);
+
+ final InputParameter inputParameter = new InputParameter(getAdditionalParams(), getExternalVirtualLink());
+ when(sdncInputParametersProvider.getInputParameter(Mockito.any(GenericVnf.class))).thenReturn(inputParameter);
+
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(new GenericVnf());
+ objUnderTest.getInputParameters(stubbedxecution);
+
+ final Object actual = stubbedxecution.getVariable(Constants.INPUT_PARAMETER);
+ assertNotNull(actual);
+ assertTrue(actual instanceof InputParameter);
+ final InputParameter actualInputParameter = (InputParameter) actual;
+ final Map<String, String> actualAdditionalParams = actualInputParameter.getAdditionalParams();
+ assertEquals(4, actualAdditionalParams.size());
+
+ final String actualInstanceType = actualAdditionalParams.get(INSTANCE_TYPE);
+ assertEquals(INSTANCE_TYPE_VALUE_1, actualInstanceType);
+
+ assertEquals(FLAVOR_VALUE, actualAdditionalParams.get(FLAVOR));
+ final List<ExternalVirtualLink> actualExtVirtualLinks = actualInputParameter.getExtVirtualLinks();
+ assertEquals(2, actualExtVirtualLinks.size());
+
+ final Optional<ExternalVirtualLink> externalVirtualLink0 = actualExtVirtualLinks.stream()
+ .filter(extVirtualLink -> EXT_VIRTUAL_LINK_ID.equals(extVirtualLink.getId())).findAny();
+ assertTrue(externalVirtualLink0.isPresent());
+ assertEquals(EXT_VIRTUAL_LINK_ID, externalVirtualLink0.get().getId());
+
+ final Optional<ExternalVirtualLink> externalVirtualLink1 = actualExtVirtualLinks.stream()
+ .filter(extVirtualLink -> RANDOM_EXT_VIRTUAL_LINK_ID.equals(extVirtualLink.getId())).findAny();
+ assertTrue(externalVirtualLink1.isPresent());
+ assertEquals(RANDOM_EXT_VIRTUAL_LINK_ID, externalVirtualLink1.get().getId());
+
+
+ }
+
+ private List<ExternalVirtualLink> getExternalVirtualLink() {
+ return Arrays.asList(
+ new ExternalVirtualLink().id(RANDOM_EXT_VIRTUAL_LINK_ID).addExtCpsItem(new ExternalVirtualLinkExtCps()
+ .addCpConfigItem(new ExternalVirtualLinkCpConfig().cpInstanceId(CPU_INSTANCE_ID))));
+ }
+
+ private Map<String, String> getAdditionalParams() {
+ final Map<String, String> additionalParams = new HashMap<>();
+ additionalParams.put(FLAVOR, FLAVOR_VALUE);
+ additionalParams.put(INSTANCE_TYPE, INSTANCE_TYPE_VALUE_2);
+ return additionalParams;
+ }
+
+
+ private GeneralBuildingBlock getGeneralBuildingBlock(final Map<String, Object> userParams) {
+ final GeneralBuildingBlock buildingBlock = new GeneralBuildingBlock();
+ final RequestContext requestContext = new RequestContext();
+ final RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUserParams(Arrays.asList(userParams));
+ requestContext.setRequestParameters(requestParameters);
+ buildingBlock.setRequestContext(requestContext);
+ return buildingBlock;
+
+ }
+
+ private class StubbedBuildingBlockExecution implements BuildingBlockExecution {
+
+ private final Map<String, Serializable> execution = new HashMap<>();
+ private GeneralBuildingBlock buildingBlock;
+
+ private void setGeneralBuildingBlock(final GeneralBuildingBlock buildingBlock) {
+ this.buildingBlock = buildingBlock;
+ }
+
+ @Override
+ public GeneralBuildingBlock getGeneralBuildingBlock() {
+ return buildingBlock;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getVariable(final String key) {
+ return (T) execution.get(key);
+ }
+
+ @Override
+ public <T> T getRequiredVariable(final String key) throws RequiredExecutionVariableExeception {
+ return null;
+ }
+
+ @Override
+ public void setVariable(final String key, final Serializable value) {
+ execution.put(key, value);
+ }
+
+ @Override
+ public Map<ResourceKey, String> getLookupMap() {
+ return Collections.emptyMap();
+ }
+
+ @Override
+ public String getFlowToBeCalled() {
+ return null;
+ }
+
+ @Override
+ public int getCurrentSequence() {
+ return 0;
+ }
+
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameterTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameterTest.java
new file mode 100644
index 0000000000..6dee904fde
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameterTest.java
@@ -0,0 +1,79 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.vnfmadapter.v1.model.ExternalVirtualLink;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@ericsson.com)
+ *
+ */
+public class InputParameterTest {
+ @Test
+ public void test_putAdditionalParams_addsEntryToExistingMap() {
+ final InputParameter objUnderTest = new InputParameter();
+ objUnderTest.setAdditionalParams(getMap("name", "value"));
+ objUnderTest.putAdditionalParams(getMap("name1", "value1"));
+
+ final Map<String, String> additionalParams = objUnderTest.getAdditionalParams();
+ assertEquals(2, additionalParams.size());
+ assertTrue(additionalParams.containsKey("name"));
+ assertTrue(additionalParams.containsKey("name1"));
+
+ }
+
+ @Test
+ public void test_addExtVirtualLinks_adddistinctEntriesToExistingList() {
+ final InputParameter objUnderTest = new InputParameter();
+ String firstId = UUID.randomUUID().toString();
+ String secondId = UUID.randomUUID().toString();
+ objUnderTest.setExtVirtualLinks(getExternalVirtualLinkList(firstId));
+ objUnderTest.addExtVirtualLinks(getExternalVirtualLinkList(secondId));
+ objUnderTest.addExtVirtualLinks(getExternalVirtualLinkList(secondId));
+ objUnderTest.addExtVirtualLinks(getExternalVirtualLinkList(secondId));
+
+ final List<ExternalVirtualLink> externalVirtualLinks = objUnderTest.getExtVirtualLinks();
+ assertEquals(2, externalVirtualLinks.size());
+
+ }
+
+ private List<ExternalVirtualLink> getExternalVirtualLinkList(final String id) {
+ final ExternalVirtualLink externalVirtualLink = new ExternalVirtualLink();
+ externalVirtualLink.setId(id);
+ final List<ExternalVirtualLink> list = new ArrayList<>();
+ list.add(externalVirtualLink);
+ return list;
+ }
+
+ private Map<String, String> getMap(final String name, final String value) {
+ final Map<String, String> map = new HashMap<>();
+ map.put(name, value);
+ return map;
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/NullInputParameterTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/NullInputParameterTest.java
new file mode 100644
index 0000000000..e076df7a9b
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/NullInputParameterTest.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils;
+
+import static org.junit.Assert.assertTrue;
+import java.util.Collections;
+import org.junit.Test;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@ericsson.com)
+ *
+ */
+public class NullInputParameterTest {
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void test_addExtVirtualLinks_throwException() {
+ NullInputParameter.NULL_INSTANCE.addExtVirtualLinks(Collections.emptyList());
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void test_setAdditionalParams_throwException() {
+ NullInputParameter.NULL_INSTANCE.setAdditionalParams(Collections.emptyMap());
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void test_setExtVirtualLinks_throwException() {
+ NullInputParameter.NULL_INSTANCE.setExtVirtualLinks(Collections.emptyList());
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void test_putAdditionalParams_throwException() {
+ NullInputParameter.NULL_INSTANCE.putAdditionalParams(Collections.emptyMap());
+ }
+
+ @Test
+ public void test_getAdditionalParams_ReturnEmptyCollection() {
+ assertTrue(NullInputParameter.NULL_INSTANCE.getAdditionalParams().isEmpty());
+ }
+
+ @Test
+ public void test_getExtVirtualLinks_ReturnEmptyCollection() {
+ assertTrue(NullInputParameter.NULL_INSTANCE.getExtVirtualLinks().isEmpty());
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProviderImplTest.java
index 51e86c1fea..e2e37ac6e4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProviderImplTest.java
@@ -48,7 +48,7 @@ import org.onap.vnfmadapter.v1.model.ExternalVirtualLink;
* @author waqas.ikram@est.tech
*/
@RunWith(MockitoJUnitRunner.class)
-public class InputParametersProviderImplTest {
+public class SdncInputParametersProviderImplTest {
private static final String BASE_DIR = "src/test/resources/__files/";
@@ -89,7 +89,7 @@ public class InputParametersProviderImplTest {
@Test
public void testGetInputParameter_ValidResponseFromSdncInvalidData_EmptyInputParameter() throws Exception {
when(mockedSdncClient.get(Mockito.eq(URL))).thenReturn(getReponseAsString(INVALID_PRE_LOAD_SDNC_RESPONSE));
- final InputParametersProvider objUnderTest = new InputParametersProviderImpl(mockedSdncClient);
+ final InputParametersProvider<GenericVnf> objUnderTest = new SdncInputParametersProvider(mockedSdncClient);
final InputParameter actual = objUnderTest.getInputParameter(getGenericVnf());
assertNotNull(actual);
assertTrue(actual.getAdditionalParams().isEmpty());
@@ -99,7 +99,7 @@ public class InputParametersProviderImplTest {
@Test
public void testGetInputParameter_ExceptionThrownFromSdnc_EmptyInputParameter() throws Exception {
when(mockedSdncClient.get(Mockito.eq(URL))).thenThrow(RuntimeException.class);
- final InputParametersProvider objUnderTest = new InputParametersProviderImpl(mockedSdncClient);
+ final InputParametersProvider<GenericVnf> objUnderTest = new SdncInputParametersProvider(mockedSdncClient);
final InputParameter actual = objUnderTest.getInputParameter(getGenericVnf());
assertNotNull(actual);
assertTrue(actual instanceof NullInputParameter);
@@ -110,7 +110,7 @@ public class InputParametersProviderImplTest {
@Test
public void testGetInputParameter_InvalidResponseData_EmptyInputParameter() throws Exception {
when(mockedSdncClient.get(Mockito.eq(URL))).thenReturn(getReponseAsString(INVALID_ADDITIONAL_AND_EXT_VM_DATA));
- final InputParametersProvider objUnderTest = new InputParametersProviderImpl(mockedSdncClient);
+ final InputParametersProvider<GenericVnf> objUnderTest = new SdncInputParametersProvider(mockedSdncClient);
final InputParameter actual = objUnderTest.getInputParameter(getGenericVnf());
assertNotNull(actual);
assertTrue(actual.getAdditionalParams().isEmpty());
@@ -120,7 +120,7 @@ public class InputParametersProviderImplTest {
@Test
public void testGetInputParameter_EmptyResponseData_EmptyInputParameter() throws Exception {
when(mockedSdncClient.get(Mockito.eq(URL))).thenReturn("");
- final InputParametersProvider objUnderTest = new InputParametersProviderImpl(mockedSdncClient);
+ final InputParametersProvider<GenericVnf> objUnderTest = new SdncInputParametersProvider(mockedSdncClient);
final InputParameter actual = objUnderTest.getInputParameter(getGenericVnf());
assertNotNull(actual);
assertTrue(actual instanceof NullInputParameter);
@@ -131,7 +131,7 @@ public class InputParametersProviderImplTest {
@Test
public void testGetInputParameter_InvalidVnfParamsResponseData_EmptyInputParameter() throws Exception {
when(mockedSdncClient.get(Mockito.eq(URL))).thenReturn(getReponseAsString(INVALID_VNF_PARAMS));
- final InputParametersProvider objUnderTest = new InputParametersProviderImpl(mockedSdncClient);
+ final InputParametersProvider<GenericVnf> objUnderTest = new SdncInputParametersProvider(mockedSdncClient);
final InputParameter actual = objUnderTest.getInputParameter(getGenericVnf());
assertNotNull(actual);
assertTrue(actual.getAdditionalParams().isEmpty());
@@ -140,7 +140,7 @@ public class InputParametersProviderImplTest {
private void assertValues(final GenericVnf genericVnf) throws MapperException, BadResponseException, IOException {
when(mockedSdncClient.get(Mockito.eq(URL))).thenReturn(getReponseAsString(PRE_LOAD_SDNC_RESPONSE));
- final InputParametersProvider objUnderTest = new InputParametersProviderImpl(mockedSdncClient);
+ final InputParametersProvider<GenericVnf> objUnderTest = new SdncInputParametersProvider(mockedSdncClient);
final InputParameter actual = objUnderTest.getInputParameter(genericVnf);
assertNotNull(actual);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/UserParamInputParametersProviderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/UserParamInputParametersProviderTest.java
new file mode 100644
index 0000000000..e6d4ad056a
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/UserParamInputParametersProviderTest.java
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.ADDITIONAL_PARAMS_VALUE;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.EXT_VIRTUAL_LINKS_VALUE;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.EXT_VIRTUAL_LINK_VALUE;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.getUserParamsMap;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.vnfmadapter.v1.model.ExternalVirtualLink;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@ericsson.com)
+ *
+ */
+public class UserParamInputParametersProviderTest {
+
+ @Test
+ public void testGetInputParameter_ValidUserParams_NotEmptyInputParameter() throws Exception {
+ final InputParametersProvider<Map<String, Object>> objUnderTest = new UserParamInputParametersProvider();
+
+ final InputParameter actual =
+ objUnderTest.getInputParameter(getUserParamsMap(ADDITIONAL_PARAMS_VALUE, EXT_VIRTUAL_LINKS_VALUE));
+ assertNotNull(actual);
+
+ final Map<String, String> actualAdditionalParams = actual.getAdditionalParams();
+ assertEquals(3, actualAdditionalParams.size());
+
+ final String actualInstanceType = actualAdditionalParams.get("instance_type");
+ assertEquals("m1.small", actualInstanceType);
+
+ final List<ExternalVirtualLink> actualExtVirtualLinks = actual.getExtVirtualLinks();
+ assertEquals(1, actualExtVirtualLinks.size());
+
+ final ExternalVirtualLink actualExternalVirtualLink = actualExtVirtualLinks.get(0);
+ assertEquals("ac1ed33d-8dc1-4800-8ce8-309b99c38eec", actualExternalVirtualLink.getId());
+
+ }
+
+ @Test
+ public void testGetInputParameter_EmptyOrNullUserParams_EmptyInputParameter() throws Exception {
+ final InputParametersProvider<Map<String, Object>> objUnderTest = new UserParamInputParametersProvider();
+
+ InputParameter actual = objUnderTest.getInputParameter(Collections.emptyMap());
+ assertNotNull(actual);
+ assertTrue(actual.getAdditionalParams().isEmpty());
+ assertTrue(actual.getExtVirtualLinks().isEmpty());
+
+ actual = objUnderTest.getInputParameter(null);
+ assertNotNull(actual);
+ assertTrue(actual instanceof NullInputParameter);
+ assertTrue(actual.getAdditionalParams().isEmpty());
+ assertTrue(actual.getExtVirtualLinks().isEmpty());
+
+ }
+
+ @Test
+ public void testGetInputParameter_InValidExtVirtualLinks_NotEmptyInputParameter() throws Exception {
+ final InputParametersProvider<Map<String, Object>> objUnderTest = new UserParamInputParametersProvider();
+
+ final InputParameter actual =
+ objUnderTest.getInputParameter(getUserParamsMap(ADDITIONAL_PARAMS_VALUE, EXT_VIRTUAL_LINK_VALUE));
+ assertNotNull(actual);
+
+ final Map<String, String> actualAdditionalParams = actual.getAdditionalParams();
+ assertEquals(3, actualAdditionalParams.size());
+
+ final String actualInstanceType = actualAdditionalParams.get("instance_type");
+ assertEquals("m1.small", actualInstanceType);
+
+ assertTrue(actual.getExtVirtualLinks().isEmpty());
+
+ }
+
+}