aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2019-03-25 19:41:23 +0000
committerwaqas.ikram <waqas.ikram@est.tech>2019-03-25 19:41:23 +0000
commit448899ee55a6cf1c55b5510adceba8b3bab98297 (patch)
tree33247077dcf4d56e37ed1d5a28081f0c70f9de18 /bpmn/so-bpmn-tasks
parente2a3995dd8dba9b9a18635ce37e4805dadcdb0fd (diff)
Added input parameter loading handling from SDNC
Change-Id: I9076d793468db659358c7ef0e7cc859886d7fe17 Issue-ID: SO-1624 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/pom.xml6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java5
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTask.java74
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java12
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameter.java81
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProvider.java31
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImpl.java161
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/NullInputParameter.java37
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java91
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java125
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java181
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java38
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponse.json127
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json47
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json39
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json34
17 files changed, 1093 insertions, 2 deletions
diff --git a/bpmn/so-bpmn-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml
index ce1cdd5068..8adffb29b5 100644
--- a/bpmn/so-bpmn-tasks/pom.xml
+++ b/bpmn/so-bpmn-tasks/pom.xml
@@ -156,5 +156,11 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
+ <dependency>
+ <groupId>nl.jqno.equalsverifier</groupId>
+ <artifactId>equalsverifier</artifactId>
+ <version>2.5.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java
index d03173d0ac..667ac133af 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java
@@ -27,6 +27,8 @@ public class Constants {
public static final String CREATE_VNF_REQUEST_PARAM_NAME = "createVnfRequest";
public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse";
+
+ public static final String INPUT_PARAMETER = "inputParameter";
public static final String DOT = ".";
public static final String UNDERSCORE = "_";
@@ -34,6 +36,9 @@ public class Constants {
public static final String VNFM_ADAPTER_DEFAULT_URL = "http://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/";
public static final String VNFM_ADAPTER_DEFAULT_AUTH = "Basic dm5mbTpwYXNzd29yZDEk";
+
+ public static final String FORWARD_SLASH = "/";
+ public static final String PRELOAD_VNFS_URL = "/restconf/config/VNF-API:preload-vnfs/vnf-preload-list/";
private Constants() {}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTask.java
new file mode 100644
index 0000000000..ebb9d521c3
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTask.java
@@ -0,0 +1,74 @@
+/*-
+ * ============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.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.INPUT_PARAMETER;
+import static org.onap.so.bpmn.servicedecomposition.entities.ResourceKey.GENERIC_VNF_ID;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+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.tasks.ExtractPojosForBB;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class retrieve input parameters
+ *
+ * @author waqas.ikram@est.tech
+ */
+@Component
+public class InputParameterRetrieverTask {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(InputParameterRetrieverTask.class);
+
+ private final InputParametersProvider inputParametersProvider;
+
+ private final ExtractPojosForBB extractPojosForBB;
+
+ @Autowired
+ public InputParameterRetrieverTask(final InputParametersProvider inputParametersProvider,
+ final ExtractPojosForBB extractPojosForBB) {
+ this.inputParametersProvider = inputParametersProvider;
+ this.extractPojosForBB = extractPojosForBB;
+ }
+
+ public void getInputParameters(final BuildingBlockExecution execution) {
+ try {
+ LOGGER.debug("Executing getInputParameters ...");
+
+ final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
+ final InputParameter inputParameter = inputParametersProvider.getInputParameter(vnf);
+
+ LOGGER.debug("inputParameter: {}", inputParameter);
+ execution.setVariable(INPUT_PARAMETER, inputParameter);
+
+ LOGGER.debug("Finished executing getInputParameters ...");
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to invoke create and instantiation request", exception);
+ execution.setVariable(INPUT_PARAMETER, NullInputParameter.NULL_INSTANCE);
+ }
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java
index 23ddb6f3f7..4e15474e46 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java
@@ -23,11 +23,14 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_REQUEST_PARAM_NAME;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_RESPONSE_PARAM_NAME;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.DOT;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.INPUT_PARAMETER;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.SPACE;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.UNDERSCORE;
import static org.onap.so.bpmn.servicedecomposition.entities.ResourceKey.GENERIC_VNF_ID;
import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParameter;
+import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.NullInputParameter;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
@@ -83,10 +86,14 @@ public class VnfmAdapterCreateVnfTask {
final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
final ModelInfoGenericVnf modelInfoGenericVnf = vnf.getModelInfoGenericVnf();
+ final InputParameter inputParameter = getInputParameter(execution);
+
final CreateVnfRequest createVnfRequest = new CreateVnfRequest();
createVnfRequest.setName(getName(vnf.getVnfName(), modelInfoGenericVnf.getModelInstanceName()));
createVnfRequest.setTenant(getTenant(cloudRegion));
+ createVnfRequest.setAdditionalParams(inputParameter.getAdditionalParams());
+ createVnfRequest.setExternalVirtualLinks(inputParameter.getExtVirtualLinks());
LOGGER.info("CreateVnfRequest : {}", createVnfRequest);
@@ -99,6 +106,11 @@ public class VnfmAdapterCreateVnfTask {
}
}
+ private InputParameter getInputParameter(final BuildingBlockExecution execution) {
+ final InputParameter inputParameter = execution.getVariable(INPUT_PARAMETER);
+ return inputParameter != null ? inputParameter : NullInputParameter.NULL_INSTANCE;
+ }
+
/**
* Invoke VNFM adapter to create and instantiate VNF
*
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameter.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameter.java
new file mode 100644
index 0000000000..5ade3240a0
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameter.java
@@ -0,0 +1,81 @@
+/*-
+ * ============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 java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.vnfmadapter.v1.model.ExternalVirtualLink;
+
+/**
+ * Wrapper class for instance parameters which are based on SOL003
+ *
+ * @author waqas.ikram@est.tech
+ */
+public class InputParameter implements Serializable {
+
+ private static final long serialVersionUID = 42034634585595304L;
+
+ private Map<String, String> additionalParams = new HashMap<>();
+
+ private List<ExternalVirtualLink> extVirtualLinks = new ArrayList<>();
+
+ public InputParameter(final Map<String, String> additionalParams, final List<ExternalVirtualLink> extVirtualLinks) {
+ this.additionalParams = additionalParams;
+ this.extVirtualLinks = extVirtualLinks;
+ }
+
+ /**
+ * @return the additionalParams
+ */
+ public Map<String, String> getAdditionalParams() {
+ return additionalParams;
+ }
+
+ /**
+ * @return the extVirtualLinks
+ */
+ public List<ExternalVirtualLink> getExtVirtualLinks() {
+ return extVirtualLinks;
+ }
+
+ /**
+ * @param additionalParams the additionalParams to set
+ */
+ public void setAdditionalParams(final Map<String, String> additionalParams) {
+ this.additionalParams = additionalParams;
+ }
+
+ /**
+ * @param extVirtualLinks the extVirtualLinks to set
+ */
+ public void setExtVirtualLinks(final List<ExternalVirtualLink> extVirtualLinks) {
+ this.extVirtualLinks = extVirtualLinks;
+ }
+
+ @Override
+ public String toString() {
+ return "InputParameter [additionalParams=" + additionalParams + ", extVirtualLinks=" + extVirtualLinks + "]";
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProvider.java
new file mode 100644
index 0000000000..55203fb7cc
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProvider.java
@@ -0,0 +1,31 @@
+/*-
+ * ============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 org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+
+/**
+ * @author waqas.ikram@est.tech
+ */
+public interface InputParametersProvider {
+
+ InputParameter getInputParameter(final GenericVnf genericVnf);
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImpl.java
new file mode 100644
index 0000000000..6027e78d8b
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImpl.java
@@ -0,0 +1,161 @@
+/*-
+ * ============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.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.FORWARD_SLASH;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.PRELOAD_VNFS_URL;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
+import org.onap.so.client.sdnc.SDNCClient;
+import org.onap.vnfmadapter.v1.model.ExternalVirtualLink;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.jayway.jsonpath.JsonPath;
+
+import net.minidev.json.JSONArray;
+
+/**
+ * This class retrieve pre-load data from SDNC using <br/>
+ * <b>GET</b> /config/VNF-API:preload-vnfs/vnf-preload-list/{vnf-name}/{vnf-type}
+ *
+ * @author waqas.ikram@est.tech
+ */
+@Service
+public class InputParametersProviderImpl implements InputParametersProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(InputParametersProviderImpl.class);
+
+ private static final String EXT_VIRTUAL_LINKS = "extVirtualLinks";
+ private static final String ADDITIONAL_PARAMS = "additionalParams";
+ private static final String VNF_PARAMETERS_PATH = "$..vnf-parameters";
+
+ private final SDNCClient sdncClient;
+
+ @Autowired
+ public InputParametersProviderImpl(final SDNCClient sdncClient) {
+ this.sdncClient = sdncClient;
+ }
+
+ @Override
+ public InputParameter getInputParameter(final GenericVnf genericVnf) {
+ final String vnfName = genericVnf.getVnfName();
+ final String vnfType = getVnfType(genericVnf);
+ final String url = getPreloadVnfsUrl(vnfName, vnfType);
+
+ try {
+ LOGGER.debug("Will query sdnc for input parameters using url: {}", url);
+ final String jsonResponse = sdncClient.get(url);
+
+ final JSONArray vnfParametersArray = JsonPath.read(jsonResponse, VNF_PARAMETERS_PATH);
+ if (vnfParametersArray != null) {
+ for (int index = 0; index < vnfParametersArray.size(); index++) {
+ final Object vnfParametersObject = vnfParametersArray.get(index);
+ if (vnfParametersObject instanceof JSONArray) {
+ final JSONArray vnfParameters = (JSONArray) vnfParametersObject;
+ final Map<String, String> vnfParametersMap = getVnfParameterMap(vnfParameters);
+ return new InputParameter(getAdditionalParameters(vnfParametersMap),
+ getExtVirtualLinks(vnfParametersMap));
+ }
+ }
+ }
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to retrieve/parse input parameters using URL: {} ", url, exception);
+ }
+ LOGGER.warn("No input parameters found ...");
+ return NullInputParameter.NULL_INSTANCE;
+
+ }
+
+ private List<ExternalVirtualLink> getExtVirtualLinks(final Map<String, String> vnfParametersMap)
+ throws JsonParseException, IOException {
+ try {
+ final String extVirtualLinksString = vnfParametersMap.get(EXT_VIRTUAL_LINKS);
+
+ if (extVirtualLinksString != null && !extVirtualLinksString.isEmpty()) {
+ final ObjectMapper mapper = new ObjectMapper();
+ final TypeReference<List<ExternalVirtualLink>> extVirtualLinksStringTypeRef =
+ new TypeReference<List<ExternalVirtualLink>>() {};
+
+ return mapper.readValue(extVirtualLinksString, extVirtualLinksStringTypeRef);
+ }
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to parse {} ", EXT_VIRTUAL_LINKS, exception);
+ }
+ return Collections.emptyList();
+ }
+
+ private Map<String, String> getAdditionalParameters(final Map<String, String> vnfParametersMap)
+ throws JsonParseException, IOException {
+ try {
+ final String additionalParamsString = vnfParametersMap.get(ADDITIONAL_PARAMS);
+ if (additionalParamsString != null && !additionalParamsString.isEmpty()) {
+ final ObjectMapper mapper = new ObjectMapper();
+ final TypeReference<Map<String, String>> typeRef = new TypeReference<Map<String, String>>() {};
+ return mapper.readValue(additionalParamsString, typeRef);
+ }
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to parse {} ", ADDITIONAL_PARAMS, exception);
+ }
+ return Collections.emptyMap();
+ }
+
+ private Map<String, String> getVnfParameterMap(final JSONArray array) {
+ try {
+ if (array != null) {
+ final ObjectMapper mapper = new ObjectMapper();
+ final VnfParameter[] readValue = mapper.readValue(array.toJSONString(), VnfParameter[].class);
+ LOGGER.debug("Vnf parameters: {}", Arrays.asList(readValue));
+ return Arrays.asList(readValue).stream()
+ .filter(vnfParam -> vnfParam.getName() != null && vnfParam.getValue() != null)
+ .collect(Collectors.toMap(VnfParameter::getName, VnfParameter::getValue));
+ }
+ } catch (final IOException exception) {
+ LOGGER.error("Unable to parse vnf parameters : {}", array, exception);
+ }
+ return Collections.emptyMap();
+ }
+
+ private String getPreloadVnfsUrl(final String vnfName, final String vnfType) {
+ return PRELOAD_VNFS_URL + vnfName + FORWARD_SLASH + vnfType;
+ }
+
+ private String getVnfType(final GenericVnf genericVnf) {
+ final ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+ if (modelInfoGenericVnf != null && modelInfoGenericVnf.getModelName() != null) {
+ return modelInfoGenericVnf.getModelName();
+ }
+ return genericVnf.getVnfType();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/NullInputParameter.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/NullInputParameter.java
new file mode 100644
index 0000000000..fb877ac55d
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/NullInputParameter.java
@@ -0,0 +1,37 @@
+/*-
+ * ============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 java.util.Collections;
+
+/**
+ * @author waqas.ikram@est.tech
+ */
+public class NullInputParameter extends InputParameter {
+
+ private static final long serialVersionUID = -7261286746726871696L;
+
+ public static final NullInputParameter NULL_INSTANCE = new NullInputParameter();
+
+ private NullInputParameter() {
+ super(Collections.emptyMap(), Collections.emptyList());
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java
new file mode 100644
index 0000000000..11e93e733d
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java
@@ -0,0 +1,91 @@
+/*-
+ * ============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 java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * This is used to deserialize vnf-parameters from vnf-preload-list/{vnf-name}/{vnf-type} response
+ *
+ * @author waqas.ikram@est.tech
+ */
+public class VnfParameter {
+
+ @JsonProperty("vnf-parameter-name")
+ private String name;
+
+ @JsonProperty("vnf-parameter-value")
+ private String value;
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(final String value) {
+ this.value = value;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((value == null) ? 0 : value.hashCode());
+ return Objects.hash(name, value);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj instanceof VnfParameter) {
+ VnfParameter other = (VnfParameter) obj;
+ return Objects.equals(name, other.name) && Objects.equals(value, other.value);
+ }
+
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "VnfParameter [name=" + name + ", value=" + value + "]";
+ }
+
+}
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
new file mode 100644
index 0000000000..803b58b4b8
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java
@@ -0,0 +1,125 @@
+/*-
+ * ============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;
+ }
+
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java
index ddfc08e08f..20abe6ece1 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_REQUEST_PARAM_NAME;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_RESPONSE_PARAM_NAME;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.INPUT_PARAMETER;
import java.io.Serializable;
import java.util.Collections;
@@ -41,8 +42,7 @@ import org.mockito.Mock;
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.VnfmAdapterCreateVnfTask;
-import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.VnfmAdapterServiceProvider;
+import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParameter;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
@@ -83,6 +83,8 @@ public class VnfmAdapterCreateVnfTaskTest extends BaseTaskTest {
public void testBuildCreateVnfRequest_withValidValues_storesRequestInExecution() throws Exception {
final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ stubbedxecution.setVariable(INPUT_PARAMETER,
+ new InputParameter(Collections.emptyMap(), Collections.emptyList()));
when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
objUnderTest.buildCreateVnfRequest(stubbedxecution);
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/InputParametersProviderImplTest.java
new file mode 100644
index 0000000000..d21942d08f
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java
@@ -0,0 +1,181 @@
+/*-
+ * ============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.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.FORWARD_SLASH;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.PRELOAD_VNFS_URL;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.DUMMY_GENERIC_VND_ID;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
+import org.onap.so.client.exception.BadResponseException;
+import org.onap.so.client.exception.MapperException;
+import org.onap.so.client.sdnc.SDNCClient;
+import org.onap.vnfmadapter.v1.model.ExternalVirtualLink;
+
+/**
+ * @author waqas.ikram@est.tech
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class InputParametersProviderImplTest {
+
+ private static final String BASE_DIR = "src/test/resources/__files/";
+
+ private static final Path PRE_LOAD_SDNC_RESPONSE = Paths.get(BASE_DIR + "SDNCClientPrelaodDataResponse.json");
+
+ private static final Path INVALID_PRE_LOAD_SDNC_RESPONSE =
+ Paths.get(BASE_DIR + "SDNCClientPrelaodDataResponseWithInvalidData.json");
+
+ private static final Path INVALID_ADDITIONAL_AND_EXT_VM_DATA =
+ Paths.get(BASE_DIR + "SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json");
+
+
+ private static final Path INVALID_VNF_PARAMS =
+ Paths.get(BASE_DIR + "SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json");
+
+
+ private static final String MODEL_NAME = "MODEL_NAME";
+
+ private static final String GENERIC_VNF_NAME = "GENERIC_VNF_NAME";
+
+ private static final String URL = PRELOAD_VNFS_URL + GENERIC_VNF_NAME + FORWARD_SLASH + MODEL_NAME;
+
+ private static final String GENERIC_VNF_TYPE = MODEL_NAME;
+
+ @Mock
+ private SDNCClient mockedSdncClient;
+
+ @Test
+ public void testGetInputParameter_ValidResponseFromSdnc_NotEmptyInputParameter() throws Exception {
+ assertValues(getGenericVnf());
+ }
+
+ @Test
+ public void testGetInputParameter_ValidResponseFromSdncAndVnfType_NotEmptyInputParameter() throws Exception {
+ assertValues(getGenericVnf(GENERIC_VNF_TYPE));
+ }
+
+ @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 InputParameter actual = objUnderTest.getInputParameter(getGenericVnf());
+ assertNotNull(actual);
+ assertTrue(actual.getAdditionalParams().isEmpty());
+ assertTrue(actual.getExtVirtualLinks().isEmpty());
+ }
+
+ @Test
+ public void testGetInputParameter_ExceptionThrownFromSdnc_EmptyInputParameter() throws Exception {
+ when(mockedSdncClient.get(Mockito.eq(URL))).thenThrow(RuntimeException.class);
+ final InputParametersProvider objUnderTest = new InputParametersProviderImpl(mockedSdncClient);
+ final InputParameter actual = objUnderTest.getInputParameter(getGenericVnf());
+ assertNotNull(actual);
+ assertTrue(actual instanceof NullInputParameter);
+ assertTrue(actual.getAdditionalParams().isEmpty());
+ assertTrue(actual.getExtVirtualLinks().isEmpty());
+ }
+
+ @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 InputParameter actual = objUnderTest.getInputParameter(getGenericVnf());
+ assertNotNull(actual);
+ assertTrue(actual.getAdditionalParams().isEmpty());
+ assertTrue(actual.getExtVirtualLinks().isEmpty());
+ }
+
+ @Test
+ public void testGetInputParameter_EmptyResponseData_EmptyInputParameter() throws Exception {
+ when(mockedSdncClient.get(Mockito.eq(URL))).thenReturn("");
+ final InputParametersProvider objUnderTest = new InputParametersProviderImpl(mockedSdncClient);
+ final InputParameter actual = objUnderTest.getInputParameter(getGenericVnf());
+ assertNotNull(actual);
+ assertTrue(actual instanceof NullInputParameter);
+ assertTrue(actual.getAdditionalParams().isEmpty());
+ assertTrue(actual.getExtVirtualLinks().isEmpty());
+ }
+
+ @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 InputParameter actual = objUnderTest.getInputParameter(getGenericVnf());
+ assertNotNull(actual);
+ assertTrue(actual.getAdditionalParams().isEmpty());
+ assertTrue(actual.getExtVirtualLinks().isEmpty());
+ }
+
+ 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 InputParameter actual = objUnderTest.getInputParameter(genericVnf);
+ 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());
+ }
+
+ private String getReponseAsString(final Path filePath) throws IOException {
+ return new String(Files.readAllBytes(filePath));
+ }
+
+ private GenericVnf getGenericVnf() {
+ final GenericVnf genericVnf = getGenericVnf(GENERIC_VNF_TYPE);
+ final ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelName(MODEL_NAME);
+ genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+ return genericVnf;
+ }
+
+ private GenericVnf getGenericVnf(final String vnfType) {
+ final GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId(DUMMY_GENERIC_VND_ID);
+ genericVnf.setVnfName(GENERIC_VNF_NAME);
+ genericVnf.setVnfType(vnfType);
+ return genericVnf;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java
new file mode 100644
index 0000000000..46018b8f39
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java
@@ -0,0 +1,38 @@
+/*-
+ * ============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 org.junit.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+import nl.jqno.equalsverifier.Warning;
+
+/**
+ * @author waqas.ikram@est.tech
+ *
+ */
+public class VnfParameterTest {
+ @Test
+ public void testVnfParameter_equalAndHasCode() throws ClassNotFoundException {
+ EqualsVerifier.forClass(VnfParameter.class).suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS)
+ .verify();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponse.json
new file mode 100644
index 0000000000..0de25616e3
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponse.json
@@ -0,0 +1,127 @@
+{
+ "vnf-preload-list": [
+ {
+ "vnf-name": "GENERIC_VNF_NAME",
+ "vnf-type": "SIMPLE",
+ "preload-data":
+ {
+ "network-topology-information":
+ {
+ },
+ "vnf-topology-information":
+ {
+ "vnf-topology-identifier":
+ {
+ "service-type": "vCPE",
+ "vnf-type": "SIMPLE",
+ "vnf-name": "GENERIC_VNF_NAME",
+ "generic-vnf-name": "GENERIC_VNF_NAME",
+ "generic-vnf-type": "SIMPLE"
+ },
+ "vnf-parameters": [
+ {
+ "vnf-parameter-name": "extra_console",
+ "vnf-parameter-value": "ttyS1"
+ },
+ {
+ "vnf-parameter-name": "vnfUsername",
+ "vnf-parameter-value": "vnf_user"
+ },
+ {
+ "vnf-parameter-name": "additionalParams",
+ "vnf-parameter-value": "{\"image_id\": \"DUMMYVNF\",\"instance_type\": \"m1.small\",\"ftp_address\": \"ftp://0.0.0.0:2100/\"}"
+ },
+ {
+ "vnf-parameter-name": "fsb_admin_gateway_ip_1",
+ "vnf-parameter-value": "0.0.0.0"
+ },
+ {
+ "vnf-parameter-name": "availability_zone_1"
+ },
+ {
+ "vnf-parameter-name": "fsb_admin_gateway_ip_2"
+ },
+ {
+ "vnf-parameter-name": "fsb_admin_prefix_length",
+ "vnf-parameter-value": "28"
+ },
+ {
+ "vnf-parameter-name": "ONAPMME_OMCN_vLC_P4_prefix_length",
+ "vnf-parameter-value": "28"
+ },
+ {
+ "vnf-parameter-name": "gpbs",
+ "vnf-parameter-value": "2"
+ },
+ {
+ "vnf-parameter-name": "fsb_admin_ip_2",
+ "vnf-parameter-value": "192.0.0.1"
+ },
+ {
+ "vnf-parameter-name": "internal_mtu",
+ "vnf-parameter-value": "1500"
+ },
+ {
+ "vnf-parameter-name": "storage_drbd_sync_rate",
+ "vnf-parameter-value": "0"
+ },
+ {
+ "vnf-parameter-name": "ONAPMME_MEDIA_vLC_P3_net_id",
+ "vnf-parameter-value": "ONAPMME_MEDIA_vLC_P3"
+ },
+ {
+ "vnf-parameter-name": "extVirtualLinks",
+ "vnf-parameter-value": "[{\"id\":\"ac1ed33d-8dc1-4800-8ce8-309b99c38eec\",\"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}]"
+ },
+ {
+ "vnf-parameter-name": "vnfIpAddress",
+ "vnf-parameter-value": "127.0.0.0"
+ },
+ {
+ "vnf-parameter-name": "node_type",
+ "vnf-parameter-value": "sgsnl"
+ },
+ {
+ "vnf-parameter-name": "ONAPMME_SIG_vLC_P2_net_id",
+ "vnf-parameter-value": "ONAPMME_SIG_vLC_P2"
+ },
+ {
+ "vnf-parameter-name": "updateOss",
+ "vnf-parameter-value": "false"
+ },
+ {
+ "vnf-parameter-name": "tmo",
+ "vnf-parameter-value": "0"
+ },
+ {
+ "vnf-parameter-name": "ss7",
+ "vnf-parameter-value": "Not_Applicable"
+ },
+ {
+ "vnf-parameter-name": "ONAPMME_OMCN_vLC_P4_net_id",
+ "vnf-parameter-value": "ONAPMME_OMCN_vLC_P4"
+ },
+ {
+ "vnf-parameter-name": "key_name"
+ },
+ {
+ "vnf-parameter-name": "fsb_admin_dns_server_ip_2"
+ },
+ {
+ "vnf-parameter-name": "time_zone",
+ "vnf-parameter-value": "GMT"
+ },
+ {
+ "vnf-parameter-name": "enableRollback",
+ "vnf-parameter-value": "false"
+ }
+ ]
+ },
+ "oper-status":
+ {
+ "order-status": "PendingAssignment"
+ }
+ }
+ }
+ ]
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json
new file mode 100644
index 0000000000..c2cf2b2f28
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json
@@ -0,0 +1,47 @@
+{
+ "vnf-preload-list": [
+ {
+ "vnf-name": "GENERIC_VNF_NAME",
+ "vnf-type": "SIMPLE",
+ "preload-data":
+ {
+ "network-topology-information":
+ {
+ },
+ "vnf-topology-information":
+ {
+ "vnf-topology-identifier":
+ {
+ "service-type": "vCPE",
+ "vnf-type": "SIMPLE",
+ "vnf-name": "GENERIC_VNF_NAME",
+ "generic-vnf-name": "GENERIC_VNF_NAME",
+ "generic-vnf-type": "SIMPLE"
+ },
+ "vnf-parameters": [
+ {
+ "vnf-parameter-name": "extra_console",
+ "vnf-parameter-value": "ttyS1"
+ },
+ {
+ "vnf-parameter-name": "vnfUsername",
+ "vnf-parameter-value": "vnf_user"
+ },
+ {
+ "vnf-parameter-name": "additionalParams",
+ "vnf-parameter-value": "[\"abc\"]"
+ },
+ {
+ "vnf-parameter-name": "extVirtualLinks",
+ "vnf-parameter-value": "{\"def\":\"123\"}"
+ }
+ ]
+ },
+ "oper-status":
+ {
+ "order-status": "PendingAssignment"
+ }
+ }
+ }
+ ]
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json
new file mode 100644
index 0000000000..552adb9125
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json
@@ -0,0 +1,39 @@
+{
+ "vnf-preload-list": [
+ {
+ "vnf-name": "GENERIC_VNF_NAME",
+ "vnf-type": "SIMPLE",
+ "preload-data":
+ {
+ "network-topology-information":
+ {
+ },
+ "vnf-topology-information":
+ {
+ "vnf-topology-identifier":
+ {
+ "service-type": "vCPE",
+ "vnf-type": "SIMPLE",
+ "vnf-name": "GENERIC_VNF_NAME",
+ "generic-vnf-name": "GENERIC_VNF_NAME",
+ "generic-vnf-type": "SIMPLE"
+ },
+ "vnf-parameters": [
+ {
+ "vnf-parameter-name": "extra_console",
+ "vnf-parameter-value": "ttyS1"
+ },
+ {
+ "vnf-parameter-name": "vnfUsername",
+ "vnf-parameter-value": "vnf_user"
+ }
+ ]
+ },
+ "oper-status":
+ {
+ "order-status": "PendingAssignment"
+ }
+ }
+ }
+ ]
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json
new file mode 100644
index 0000000000..e19ad1c9d3
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json
@@ -0,0 +1,34 @@
+{
+ "vnf-preload-list": [
+ {
+ "vnf-name": "GENERIC_VNF_NAME",
+ "vnf-type": "SIMPLE",
+ "preload-data":
+ {
+ "network-topology-information":
+ {
+ },
+ "vnf-topology-information":
+ {
+ "vnf-topology-identifier":
+ {
+ "service-type": "vCPE",
+ "vnf-type": "SIMPLE",
+ "vnf-name": "GENERIC_VNF_NAME",
+ "generic-vnf-name": "GENERIC_VNF_NAME",
+ "generic-vnf-type": "SIMPLE"
+ },
+ "vnf-parameters": [
+ {
+ "hello": "world"
+ }
+ ]
+ },
+ "oper-status":
+ {
+ "order-status": "PendingAssignment"
+ }
+ }
+ }
+ ]
+}