summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java219
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java208
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java9
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java9
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java21
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java37
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java7
15 files changed, 344 insertions, 222 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java
index 1c1d6b73fd..39a209efa8 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java
@@ -1,22 +1,22 @@
/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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
- *
+* ============LICENSE_START=======================================================
+* ONAP - SO
+* ================================================================================
+* Copyright (C) 2017 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=========================================================
- */
+* 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.common;
@@ -31,92 +31,107 @@ import org.onap.so.bpmn.common.exceptions.RequiredExecutionVariableExeception;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
public class DelegateExecutionImpl implements BuildingBlockExecution, Serializable {
- private final Map<String, Serializable> seedMap;
- private transient DelegateExecution execution;
- private static final String INVALID_INPUT_MISSING = "Expected variable of \"%s\" not found in execution";
- private static final String INVALID_INPUT_CLASS_CAST = "Expected variable of \"%s\" was the wrong object type in the execution";
-
- private static final String MISSING_MSG = "Execution variable \"gBBInput\" cannot be null when executing building blocks";
- private static final String MALFORMED_MSG = "Execution variable \"gBBInput\" must contain an element of type GeneralBuildingBlock";
-
- public DelegateExecutionImpl(Map<String, Serializable> seedMap) {
- this.seedMap = seedMap;
- }
-
- public DelegateExecutionImpl(DelegateExecution execution) {
- this.seedMap = new HashMap<>();
- execution.getVariables().forEach((key, value) -> {
- if (value instanceof Serializable) {
- seedMap.put(key, (Serializable)value);
- }
- });
- /* must occur for junit tests to work */
- this.execution = execution;
- }
- @Override
- public GeneralBuildingBlock getGeneralBuildingBlock() {
- try {
- GeneralBuildingBlock generalBuildingBlock = (GeneralBuildingBlock) execution.getVariable("gBBInput");
-
- if (generalBuildingBlock == null) {
- throw new MissingBuildingBlockInputException(MISSING_MSG);
- }
-
- return generalBuildingBlock;
- } catch (ClassCastException e) {
- throw new MalformedBuildingBlockInputException(MALFORMED_MSG, e);
- }
- }
-
- @Override
- public <T> T getVariable(String key) {
- return this.get(key);
- }
-
- @Override
- public <T> T getRequiredVariable(String key) throws RequiredExecutionVariableExeception {
- final T result;
-
- result = this.get(key);
- if (result == null) {
- throw new RequiredExecutionVariableExeception(String.format(INVALID_INPUT_MISSING, key));
-
- }
- return result;
- }
-
- @Override
- public void setVariable(String key, Serializable value) {
- this.execution.setVariable(key, value);
- }
-
- @Override
- public Map<ResourceKey, String> getLookupMap() {
- return this.get("lookupKeyMap");
- }
-
- @Override
- public String getFlowToBeCalled() {
- return this.get("flowToBeCalled");
- }
- public DelegateExecution getDelegateExecution() {
- return this.execution;
- }
-
- public void setDelegateExecution(DelegateExecution execution) {
- this.execution = execution;
- this.seedMap.forEach((key, value) -> {
- if (!execution.hasVariable(key)) {
- execution.setVariable(key, value);
- }
- });
- }
-
- protected <T> T get(String key) {
- final Object value = this.execution.getVariable(key);
-
- return (T)value;
- }
+ private static final long serialVersionUID = 5559067662634919395L;
+
+ @JsonProperty
+ private final Map<String, Serializable> seedMap;
+
+ private transient DelegateExecution execution;
+ private static final String INVALID_INPUT_MISSING = "Expected variable of \"%s\" not found in execution";
+
+ private static final String MISSING_MSG =
+ "Execution variable \"gBBInput\" cannot be null when executing building blocks";
+ private static final String MALFORMED_MSG =
+ "Execution variable \"gBBInput\" must contain an element of type GeneralBuildingBlock";
+
+ public DelegateExecutionImpl(final Map<String, Serializable> seedMap) {
+ this.seedMap = seedMap;
+ }
+
+ public DelegateExecutionImpl(final DelegateExecution execution) {
+ this.seedMap = new HashMap<>();
+ execution.getVariables().forEach((key, value) -> {
+ if (value instanceof Serializable) {
+ seedMap.put(key, (Serializable) value);
+ }
+ });
+ /* must occur for junit tests to work */
+ this.execution = execution;
+ }
+
+ @JsonIgnore
+ @Override
+ public GeneralBuildingBlock getGeneralBuildingBlock() {
+ try {
+ final GeneralBuildingBlock generalBuildingBlock = (GeneralBuildingBlock) execution.getVariable("gBBInput");
+
+ if (generalBuildingBlock == null) {
+ throw new MissingBuildingBlockInputException(MISSING_MSG);
+ }
+
+ return generalBuildingBlock;
+ } catch (final ClassCastException e) {
+ throw new MalformedBuildingBlockInputException(MALFORMED_MSG, e);
+ }
+ }
+
+ @Override
+ public <T> T getVariable(final String key) {
+ return this.get(key);
+ }
+
+ @Override
+ public <T> T getRequiredVariable(final String key) throws RequiredExecutionVariableExeception {
+ final T result;
+
+ result = this.get(key);
+ if (result == null) {
+ throw new RequiredExecutionVariableExeception(String.format(INVALID_INPUT_MISSING, key));
+
+ }
+ return result;
+ }
+
+ @Override
+ public void setVariable(final String key, final Serializable value) {
+ this.execution.setVariable(key, value);
+ }
+
+ @JsonIgnore
+ @Override
+ public Map<ResourceKey, String> getLookupMap() {
+ return this.get("lookupKeyMap");
+ }
+
+ @JsonIgnore
+ @Override
+ public String getFlowToBeCalled() {
+ return this.get("flowToBeCalled");
+ }
+
+ @JsonIgnore
+ public DelegateExecution getDelegateExecution() {
+ return this.execution;
+ }
+
+ public void setDelegateExecution(final DelegateExecution execution) {
+ this.execution = execution;
+ this.seedMap.forEach((key, value) -> {
+ if (!execution.hasVariable(key)) {
+ execution.setVariable(key, value);
+ }
+ });
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> T get(final String key) {
+ final Object value = this.execution.getVariable(key);
+ return (T) value;
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java
index 32a18d5a7a..a30aadc1f8 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java
@@ -20,19 +20,15 @@
package org.onap.so.bpmn.common;
-import static org.hamcrest.CoreMatchers.hasItems;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
-import static org.mockito.ArgumentMatchers.contains;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -46,101 +42,115 @@ import org.onap.so.bpmn.common.exceptions.MissingBuildingBlockInputException;
import org.onap.so.bpmn.common.exceptions.RequiredExecutionVariableExeception;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
public class DelegateExecutionImplTest {
- @Rule
- public ExpectedException thrown= ExpectedException.none();
-
-
- @Test
- public void getVariable() throws RequiredExecutionVariableExeception {
- Map<String, Serializable> map = new HashMap<>();
- map.put("var1", "value1");
- map.put("var2", "value2");
- map.put("list1", (Serializable)Arrays.asList("value1", "value2"));
- DelegateExecutionImpl impl = create(map);
-
- assertEquals("value1", impl.getVariable("var1"));
- assertEquals("value2", impl.getRequiredVariable("var2"));
- assertThat(impl.getVariable("list1"), IsIterableContainingInOrder.contains("value1", "value2"));
-
- }
-
-
- @Test
- public void getRequiredVariableNotFound() throws RequiredExecutionVariableExeception {
- DelegateExecutionImpl impl = create();
-
- thrown.expect(RequiredExecutionVariableExeception.class);
- impl.getRequiredVariable("var1");
- }
-
-
- @Test
- public void setVariable() {
- DelegateExecutionImpl impl = create();
- impl.setVariable("var1", "value1");
-
- assertEquals("value1", impl.get("var1"));
- }
-
- @Test
- public void getGeneralBuildingBlock() {
- GeneralBuildingBlock gBB = mock(GeneralBuildingBlock.class);
- Map<String, Serializable> map = new HashMap<>();
- map.put("gBBInput", gBB);
- DelegateExecutionImpl impl = create(map);
-
- assertEquals(gBB, impl.getGeneralBuildingBlock());
- }
-
- @Test
- public void getGeneralBuildingBlockNotFound() {
-
- DelegateExecutionImpl impl = create();
-
- thrown.expect(MissingBuildingBlockInputException.class);
- impl.getGeneralBuildingBlock();
- }
-
- @Test
- public void getGeneralBuildingBlockCastException() {
- Map<String, Serializable> map = new HashMap<>();
- map.put("gBBInput", new DelegateExecutionFake());
- DelegateExecutionImpl impl = create(map);
-
- thrown.expect(MalformedBuildingBlockInputException.class);
- impl.getGeneralBuildingBlock();
- }
-
- @Test
- public void getDelegateExecution() {
- DelegateExecutionImpl impl = create();
-
- assertNotNull(impl.getDelegateExecution());
- }
-
- @Test
- public void getLookupMap() {
- Map<String, Serializable> lookup = new HashMap<>();
- Map<String, Serializable> map = new HashMap<>();
- map.put("lookupKeyMap", (Serializable) lookup);
- DelegateExecutionImpl impl = create(map);
-
- assertEquals(lookup, impl.getLookupMap());
- }
-
- private DelegateExecutionImpl create() {
- return create(new HashMap<String, Serializable>());
- }
-
- private DelegateExecutionImpl create(Map<String, Serializable> map) {
- DelegateExecutionFake fake = new DelegateExecutionFake();
-
- for (Entry<String, Serializable> entry : map.entrySet()) {
- fake.setVariable(entry.getKey(), entry.getValue());
- }
- return new DelegateExecutionImpl(fake);
- }
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+
+ @Test
+ public void getVariable() throws RequiredExecutionVariableExeception {
+ final Map<String, Serializable> map = new HashMap<>();
+ map.put("var1", "value1");
+ map.put("var2", "value2");
+ map.put("list1", (Serializable) Arrays.asList("value1", "value2"));
+ final DelegateExecutionImpl impl = create(map);
+
+ assertEquals("value1", impl.getVariable("var1"));
+ assertEquals("value2", impl.getRequiredVariable("var2"));
+ assertThat(impl.getVariable("list1"), IsIterableContainingInOrder.contains("value1", "value2"));
+
+ }
+
+
+ @Test
+ public void getRequiredVariableNotFound() throws RequiredExecutionVariableExeception {
+ final DelegateExecutionImpl impl = create();
+
+ thrown.expect(RequiredExecutionVariableExeception.class);
+ impl.getRequiredVariable("var1");
+ }
+
+
+ @Test
+ public void setVariable() {
+ final DelegateExecutionImpl impl = create();
+ impl.setVariable("var1", "value1");
+
+ assertEquals("value1", impl.get("var1"));
+ }
+
+ @Test
+ public void getGeneralBuildingBlock() {
+ final GeneralBuildingBlock gBB = mock(GeneralBuildingBlock.class);
+ final Map<String, Serializable> map = new HashMap<>();
+ map.put("gBBInput", gBB);
+ final DelegateExecutionImpl impl = create(map);
+
+ assertEquals(gBB, impl.getGeneralBuildingBlock());
+ }
+
+ @Test
+ public void getGeneralBuildingBlockNotFound() {
+ final DelegateExecutionImpl impl = create();
+ thrown.expect(MissingBuildingBlockInputException.class);
+ impl.getGeneralBuildingBlock();
+ }
+
+ @Test
+ public void getGeneralBuildingBlockCastException() {
+ final Map<String, Serializable> map = new HashMap<>();
+ map.put("gBBInput", new DelegateExecutionFake());
+ final DelegateExecutionImpl impl = create(map);
+
+ thrown.expect(MalformedBuildingBlockInputException.class);
+ impl.getGeneralBuildingBlock();
+ }
+
+ @Test
+ public void getDelegateExecution() {
+ final DelegateExecutionImpl impl = create();
+
+ assertNotNull(impl.getDelegateExecution());
+ }
+
+ @Test
+ public void getLookupMap() {
+ final Map<String, Serializable> lookup = new HashMap<>();
+ final Map<String, Serializable> map = new HashMap<>();
+ map.put("lookupKeyMap", (Serializable) lookup);
+ final DelegateExecutionImpl impl = create(map);
+
+ assertEquals(lookup, impl.getLookupMap());
+ }
+
+ @Test
+ public void testDelegateExecutionImpl_serializeDelegateExecutionImplObject_shouldNotThrowAnyExceptionWhenSerializing() {
+ final DelegateExecutionImpl objectUnderTest = create();
+
+ try {
+ final ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.writeValueAsString(objectUnderTest);
+ } catch (final JsonProcessingException e) {
+ fail("Should be possible to serialize DelegateExecutionImpl object");
+ }
+
+ }
+
+ private DelegateExecutionImpl create() {
+ return create(new HashMap<String, Serializable>());
+ }
+
+ private DelegateExecutionImpl create(final Map<String, Serializable> map) {
+ final DelegateExecutionFake fake = new DelegateExecutionFake();
+
+ for (final Entry<String, Serializable> entry : map.entrySet()) {
+ fake.setVariable(entry.getKey(), entry.getValue());
+ }
+ return new DelegateExecutionImpl(fake);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java
index b11e2caafa..7b86756afa 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java
@@ -21,6 +21,7 @@
package org.onap.so.client.sdnc.mapper;
import java.net.URI;
+import java.util.UUID;
import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation;
@@ -52,9 +53,13 @@ public class GCTopologyOperationRequestMapper {
Configuration vnrConfiguration,
GenericVnf voiceVnf, String sdncReqId,URI callbackUri) {
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();
GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId,callbackUri.toString());
- GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, reqAction);
+ GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction);
GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, false);
GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = generalTopologyObjectMapper.buildConfigurationInformation(vnrConfiguration,true);
GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = generalTopologyObjectMapper.buildGcRequestInformation(voiceVnf,null);
@@ -74,11 +79,15 @@ public class GCTopologyOperationRequestMapper {
RequestContext requestContext,
Configuration vnrConfiguration, String sdncReqId, URI callbackUri) {
+ String msoRequestId = null;
+ if (requestContext != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();
GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId,callbackUri.toString());
GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
- .buildGenericResourceApiRequestinformationRequestInformation(sdncReqId,
+ .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId,
GenericResourceApiRequestActionEnumeration.DELETEGENERICCONFIGURATIONINSTANCE);
GenericResourceApiServiceinformationServiceInformation serviceInformation = new GenericResourceApiServiceinformationServiceInformation();
serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId());
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
index b086b8a7ff..756e5b068e 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
@@ -60,10 +60,10 @@ public class GeneralTopologyObjectMapper {
/*
* Build GenericResourceApiRequestinformationRequestInformation
*/
- public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation(String sdncReqId, GenericResourceApiRequestActionEnumeration requestAction){
+ public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation(String msoReqId, GenericResourceApiRequestActionEnumeration requestAction){
GenericResourceApiRequestinformationRequestInformation requestInformation = new GenericResourceApiRequestinformationRequestInformation();
- requestInformation.setRequestId(sdncReqId);
+ requestInformation.setRequestId(msoReqId);
requestInformation.setRequestAction(requestAction);
requestInformation.setSource("MSO");
return requestInformation;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java
index 188a228e5d..aef7e9e044 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java
@@ -57,8 +57,12 @@ public class NetworkTopologyOperationRequestMapper {
Customer customer, RequestContext requestContext, CloudRegion cloudRegion) {
GenericResourceApiNetworkOperationInformation req = new GenericResourceApiNetworkOperationInformation();
String sdncReqId = UUID.randomUUID().toString();
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);
- GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, reqAction);
+ GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction);
GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
GenericResourceApiNetworkinformationNetworkInformation networkInformation = generalTopologyObjectMapper.buildNetworkInformation(network);
GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = buildNetworkRequestInput(network, serviceInstance, cloudRegion);
@@ -68,7 +72,7 @@ public class NetworkTopologyOperationRequestMapper {
req.setServiceInformation(serviceInformation);
req.setNetworkInformation(networkInformation);
- if (requestContext.getUserParams() != null) {
+ if (requestContext != null && requestContext.getUserParams() != null) {
for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
GenericResourceApiParam networkInputParameters = new GenericResourceApiParam();
GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java
index 505466b22c..cdb4ab96aa 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java
@@ -49,9 +49,13 @@ public class ServiceTopologyOperationMapper{
SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction,ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) {
String sdncReqId = UUID.randomUUID().toString();
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
GenericResourceApiServiceOperationInformation servOpInput = new GenericResourceApiServiceOperationInformation();
GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);
- GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, resourceAction);
+ GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, resourceAction);
GenericResourceApiServiceinformationServiceInformation servInfo = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
GenericResourceApiServicerequestinputServiceRequestInput servReqInfo = new GenericResourceApiServicerequestinputServiceRequestInput();
@@ -62,7 +66,7 @@ public class ServiceTopologyOperationMapper{
servOpInput.setServiceInformation(servInfo);
servOpInput.setServiceRequestInput(servReqInfo);
- if(requestContext.getUserParams()!=null){
+ if(requestContext != null && requestContext.getUserParams()!=null){
for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput = new GenericResourceApiServicerequestinputServiceRequestInput();
serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName());
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
index b8c5fad41d..86c718d165 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
@@ -96,8 +96,12 @@ public class VfModuleTopologyOperationRequestMapper {
}
String sdncReqId = UUID.randomUUID().toString();
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
- GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId,
+ GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId,
requestAction);
GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, includeModelInformation);
GenericResourceApiVnfinformationVnfInformation vnfInformation = generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, includeModelInformation);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java
index 7de393bb2f..85e5b85529 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java
@@ -59,11 +59,15 @@ public class VnfTopologyOperationRequestMapper {
GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance,
Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing) {
String sdncReqId = UUID.randomUUID().toString();
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
GenericResourceApiVnfOperationInformation req = new GenericResourceApiVnfOperationInformation();
GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper
.buildSdncRequestHeader(svcAction, sdncReqId);
GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
- .buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, requestAction);
+ .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction);
GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper
.buildServiceInformation(serviceInstance, requestContext, customer, true);
GenericResourceApiVnfinformationVnfInformation vnfInformation = generalTopologyObjectMapper
@@ -84,7 +88,7 @@ public class VnfTopologyOperationRequestMapper {
req.setVnfInformation(vnfInformation);
GenericResourceApiParam vnfInputParameters = new GenericResourceApiParam();
- if (requestContext.getUserParams() != null) {
+ if (requestContext != null && requestContext.getUserParams() != null) {
for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
paramItem.setName(entry.getKey());
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java
index 1bcc464fa0..d362996948 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java
@@ -21,6 +21,7 @@
package org.onap.so.client.adapter.network;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
@@ -104,7 +105,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
DeleteNetworkResponse mockResponse = new DeleteNetworkResponse();
mockResponse.setNetworkDeleted(true);
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
@@ -119,7 +120,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
DeleteNetworkError mockResponse = new DeleteNetworkError();
mockResponse.setMessage("Error in delete network");
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
@@ -136,7 +137,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
RollbackNetworkResponse mockResponse = new RollbackNetworkResponse();
mockResponse.setNetworkRolledBack(true);
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
@@ -154,7 +155,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
RollbackNetworkError mockResponse = new RollbackNetworkError();
mockResponse.setMessage("Error in rollback network");
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java
index 3387920d40..cb3d91b82a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java
@@ -21,6 +21,7 @@
package org.onap.so.client.adapter.vnf;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
@@ -102,7 +103,7 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
RollbackVfModuleResponse mockResponse = new RollbackVfModuleResponse();
mockResponse.setVfModuleRolledback(true);
stubFor(
- post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
+ delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
@@ -120,7 +121,7 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
mockResponse.setMessage("Error in rollback Vf module");
stubFor(
- post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
+ delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
@@ -134,7 +135,7 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
DeleteVfModuleResponse mockResponse = new DeleteVfModuleResponse();
mockResponse.setVfModuleDeleted(true);
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
@@ -149,7 +150,7 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
mockResponse.setMessage("Error in delete Vf module");
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java
index 0ca80c75f7..302bb551c3 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java
@@ -75,6 +75,7 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup {
Assert.assertEquals("VLAN-NETWORK-RECEPTOR", genericInfo.getConfigurationInformation().getConfigurationType());
Assert.assertEquals("uuid",genericInfo.getSdncRequestHeader().getSvcRequestId());
Assert.assertEquals("http://localhost",genericInfo.getSdncRequestHeader().getSvcNotificationUrl());
+ Assert.assertEquals("MsoRequestId",genericInfo.getRequestInformation().getRequestId());
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java
index 6a14f8b567..1bfa78ad6d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java
@@ -23,6 +23,7 @@ package org.onap.so.client.sdnc.mapper;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.io.IOException;
@@ -109,6 +110,7 @@ public class NetworkTopologyOperationRequestMapperTest {
userParams.put("key1", "value1");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
+ requestContext.setMsoRequestId("MsoRequestId");
network = new L3Network();
network.setNetworkId("TEST_NETWORK_ID");
@@ -138,8 +140,24 @@ public class NetworkTopologyOperationRequestMapperTest {
assertThat(networkSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId")
.ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", networkSDNCrequest.getRequestInformation().getRequestId());
}
+
+ @Test
+ public void createGenericResourceApiNetworkOperationInformationReqContextNullTest() throws Exception {
+ RequestContext rc = new RequestContext();
+ rc.setMsoRequestId(null);
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
+ rc, cloudRegion);
+ assertNotNull(networkSDNCrequest.getRequestInformation().getRequestId());
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest2 = mapper.reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
+ null, cloudRegion);
+ assertNotNull(networkSDNCrequest2.getRequestInformation().getRequestId());
+ }
+
@Test
public void reqMapperTest() throws Exception {
@@ -175,7 +193,8 @@ public class NetworkTopologyOperationRequestMapperTest {
assertThat(reqMapperUnassign, sameBeanAs(networkSDNCrequestUnassign).ignoring("sdncRequestHeader.svcRequestId")
.ignoring("requestInformation.requestId"));
-
+ assertEquals("MsoRequestId", networkSDNCrequestUnassign.getRequestInformation().getRequestId());
+
}
@Test
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java
index 0bf06a0bb0..1919ef437b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java
@@ -22,6 +22,8 @@ package org.onap.so.client.sdnc.mapper;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -80,10 +82,14 @@ public class ServiceTopologyOperationMapperTest {
userParams.put("key1", "value1");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
+ requestContext.setMsoRequestId("MsoRequestId");
GenericResourceApiServiceOperationInformation serviceOpInformation = mapper.reqMapper(
SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
requestContext);
+ GenericResourceApiServiceOperationInformation serviceOpInformationNullReqContext = mapper.reqMapper(
+ SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
+ null);
String jsonToCompare = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json")));
@@ -92,5 +98,7 @@ public class ServiceTopologyOperationMapperTest {
GenericResourceApiOnapmodelinformationOnapModelInformation.class);
assertThat(reqMapper1, sameBeanAs(serviceOpInformation.getServiceInformation().getOnapModelInformation()));
+ assertEquals("MsoRequestId", serviceOpInformation.getRequestInformation().getRequestId());
+ assertNotNull(serviceOpInformationNullReqContext.getRequestInformation().getRequestId());
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
index 282f23caa7..7fce8c48c8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
@@ -23,6 +23,7 @@ package org.onap.so.client.sdnc.mapper;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.nio.file.Files;
@@ -102,6 +103,7 @@ public class VfModuleTopologyOperationRequestMapperTest {
RequestParameters requestParameters = new RequestParameters();
requestParameters.setUsePreload(true);
requestContext.setRequestParameters(requestParameters);
+ requestContext.setMsoRequestId("MsoRequestId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("testVnfId");
@@ -148,6 +150,7 @@ public class VfModuleTopologyOperationRequestMapperTest {
assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
.ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
}
@Test
@@ -168,10 +171,13 @@ public class VfModuleTopologyOperationRequestMapperTest {
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("testVfModuleId");
vfModule.setVfModuleName("testVfModuleName");
+
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("MsoRequestId");
GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(
SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null,
- null, null, null);
+ null, requestContext, null);
String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationUnassign.json")));
@@ -182,6 +188,35 @@ public class VfModuleTopologyOperationRequestMapperTest {
assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
.ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
+ }
+
+ @Test
+ public void unassignGenericResourceApiVfModuleInformationNullMsoReqIdTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ // prepare and set vnf instance
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("testVnfId");
+ vnf.setVnfType("testVnfType");
+
+ // prepare and set vf module instance
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId");
+ vfModule.setVfModuleName("testVfModuleName");
+
+ RequestContext requestContext = new RequestContext();
+
+ GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(
+ SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null,
+ null, requestContext, null);
+
+ assertNotNull(vfModuleSDNCrequest.getRequestInformation().getRequestId());
}
@Test
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
index 229a8cf601..64b532fd07 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
@@ -21,6 +21,7 @@
package org.onap.so.client.sdnc.mapper;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.util.ArrayList;
@@ -122,12 +123,16 @@ public class VnfTopologyOperationRequestMapperTest {
userParams.put("key1", "value1");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
+ requestContext.setMsoRequestId("MsoRequestId");
CloudRegion cloudRegion = new CloudRegion();
GenericResourceApiVnfOperationInformation vnfOpInformation = mapper.reqMapper(
SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
cloudRegion, requestContext,true);
+ GenericResourceApiVnfOperationInformation vnfOpInformationNullReqContext = mapper.reqMapper(
+ SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
+ cloudRegion, null,true);
assertNull(vnfOpInformation.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
assertEquals("vnfModelCustomizationUUID", vnfOpInformation.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid());
@@ -136,5 +141,7 @@ public class VnfTopologyOperationRequestMapperTest {
assertEquals("l3-network-ig-222", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(1).getVnfNetworkInstanceGroupId());
assertEquals("entitlementPoolUuid", vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(1).getValue());
assertEquals("licenseKeyGroupUuid", vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(2).getValue());
+ assertEquals("MsoRequestId", vnfOpInformation.getRequestInformation().getRequestId());
+ assertNotNull(vnfOpInformationNullReqContext.getRequestInformation().getRequestId());
}
}