summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2019-07-23 05:30:31 +0000
committerGerrit Code Review <gerrit@onap.org>2019-07-23 05:30:31 +0000
commit5184b28f6ec1170ae035ddd749d8bdf5b2064904 (patch)
tree41f5811c8b56094bb63ba1a784048ab384f4a253 /bpmn/MSOCommonBPMN/src/test
parentbbdb1c45a93194db2712d8c146e263a03737f25c (diff)
parentf4bf9e7ad4746fbec415c0ad34fa57f168840e30 (diff)
Merge "Enhanced List Level flow with backward support"
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test')
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/InstnaceResourceListTest.java76
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/InstanceResourceList/InstanceResourceList.json26
2 files changed, 97 insertions, 5 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/InstnaceResourceListTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/InstnaceResourceListTest.java
index 3be67c965c..f3233f2350 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/InstnaceResourceListTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/InstnaceResourceListTest.java
@@ -3,6 +3,7 @@ package org.onap.so.bpmn.common.resource;
import org.junit.Assert;
import org.junit.Test;
import org.onap.so.bpmn.core.domain.GroupResource;
+import org.onap.so.bpmn.core.domain.ModelInfo;
import org.onap.so.bpmn.core.domain.Resource;
import org.onap.so.bpmn.core.domain.ResourceType;
import org.onap.so.bpmn.core.domain.VnfResource;
@@ -23,15 +24,67 @@ public class InstnaceResourceListTest {
String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json")));
List<Resource> instanceResourceList =
InstanceResourceList.getInstanceResourceList(createResourceSequence(), uuiRequest);
- Assert.assertEquals(4, instanceResourceList.size());
+ Assert.assertEquals(7, instanceResourceList.size());
Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType());
Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(1).getResourceType());
- Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(2).getResourceType());
+ Assert.assertEquals("device", instanceResourceList.get(1).getModelInfo().getModelName());
+ Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(2).getResourceType());
+ Assert.assertEquals("sitewan", instanceResourceList.get(2).getModelInfo().getModelName());
Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(3).getResourceType());
+ Assert.assertEquals("sitewan", instanceResourceList.get(3).getModelInfo().getModelName());
+ Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(4).getResourceType());
+ Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(5).getResourceType());
+ Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(6).getResourceType());
}
- private List<Resource> createResourceSequence() {
- List<Resource> resourceList = new ArrayList<>();
+ // Test when PK is empty
+ @Test
+ public void testSimpleVFResource() throws IOException {
+ String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json")));
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setResourceInput("{\"a\":\"ipaddress|127.0.0.1\"}");
+ List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest);
+ Assert.assertEquals(1, instanceResourceList.size());
+ Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType());
+ }
+
+ // Test when PK is not empty and PK does not contain any groups
+ @Test
+ public void testVFWithEmptyGroupResource() throws IOException {
+ String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json")));
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setResourceInput("{\"a\":\"[emptygroup_list,INDEX,name]\"}");
+ List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest);
+ Assert.assertEquals(1, instanceResourceList.size());
+ Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType());
+ }
+
+ // Test when PK is not empty and contains a group which SK is empty
+ @Test
+ public void testVFWithEmptyGroupKeyResource() throws IOException {
+ String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json")));
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setResourceInput("{\"a\":\"[emptygroup_list,INDEX,name]\"}");
+
+ VnfcResource vnfcResource = new VnfcResource();
+ vnfcResource.setResourceInput("{\"a\":\"test|default_value\"}");
+ GroupResource groupResource = new GroupResource();
+ groupResource.setVnfcs(Arrays.asList(vnfcResource));
+ ModelInfo wanModel = new ModelInfo();
+ wanModel.setModelName("wan");
+ groupResource.setModelInfo(wanModel);
+
+ vnfResource.setGroupOrder("wan");
+ vnfResource.setGroups(Arrays.asList(groupResource));
+
+ List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest);
+ Assert.assertEquals(2, instanceResourceList.size());
+ Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType());
+ Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(1).getResourceType());
+ Assert.assertEquals("wan", instanceResourceList.get(1).getModelInfo().getModelName());
+ }
+
+ private VnfResource createResourceSequence() {
VnfResource vnfResource = new VnfResource();
vnfResource.setResourceInput("{\"a\":\"[sdwansiteresource_list,INDEX,sdwansiteresource_list]\"}");
@@ -40,7 +93,20 @@ public class InstnaceResourceListTest {
GroupResource groupResource = new GroupResource();
groupResource.setVnfcs(Arrays.asList(vnfcResource));
+ ModelInfo wanModel = new ModelInfo();
+ wanModel.setModelName("sitewan");
+ groupResource.setModelInfo(wanModel);
+
+ VnfcResource vnfcDeviceResource = new VnfcResource();
+ vnfcDeviceResource.setResourceInput("{\"a\":\"[sdwandevice_list,INDEX,test]\"}");
+ GroupResource groupResource2 = new GroupResource();
+ groupResource2.setVnfcs(Arrays.asList(vnfcDeviceResource));
+ ModelInfo deviceModel = new ModelInfo();
+ deviceModel.setModelName("device");
+ groupResource2.setModelInfo(deviceModel);
- return Arrays.asList(vnfResource, groupResource);
+ vnfResource.setGroupOrder("device,sitewan");
+ vnfResource.setGroups(Arrays.asList(groupResource, groupResource2));
+ return vnfResource;
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/InstanceResourceList/InstanceResourceList.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/InstanceResourceList/InstanceResourceList.json
index 0b3d9f0bbe..a111ae2646 100644
--- a/bpmn/MSOCommonBPMN/src/test/resources/__files/InstanceResourceList/InstanceResourceList.json
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/InstanceResourceList/InstanceResourceList.json
@@ -67,6 +67,19 @@
}
],
"requestInputs":{
+ "emptygroup_list": [
+ {
+ "topology": "hub_spoke",
+ "name": "defaultvpn",
+ "role":"Hub",
+ "portType":"GE",
+ "portSwitch":"layer3-port",
+ "vlanId":"",
+ "ipAddress":"192.168.10.1",
+ "deviceName":"vCPE",
+ "portNumer":"0/0/1"
+ }
+ ],
"sdwanvpnresource_list":[
{
"sdwanvpn_topology":"hub_spoke",
@@ -117,6 +130,19 @@
"portNumber":"0/0/0",
"ipMode":"DHCP",
"publicIP":"119.3.7.113"
+ },
+ {
+ "providerIpAddress":"",
+ "portType":"GE",
+ "inputBandwidth":"1200",
+ "ipAddress":"",
+ "name":"10001",
+ "transportNetworkName":"internet",
+ "outputBandwidth":"10001",
+ "deviceName":"vCPE",
+ "portNumber":"0/0/0",
+ "ipMode":"DHCP",
+ "publicIP":"119.3.7.114"
}
],
"sdwandevice_list":[