diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test')
3 files changed, 317 insertions, 6 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java index c7c181744f..adfee796f2 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java @@ -19,19 +19,53 @@ */ package org.onap.so.bpmn.common.resource; +import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.onap.so.BaseTest; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.so.bpmn.mock.FileUtil; import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.ok; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static org.junit.Assert.assertEquals; - +import static org.junit.Assert.assertTrue; public class ResourceRequestBuilderTest extends BaseTest { + private Map<String, Object> userInputMap = null; + + private String serviceInput = null; + + @Before + public void initializeMockObjects() { + + if (null == this.userInputMap) { + ObjectMapper mapper = new ObjectMapper(); + + try { + String serviceInputRequest = FileUtil.readResourceFile("__files/UUI-SO-REQ.json"); + this.userInputMap = mapper.readValue(serviceInputRequest, new TypeReference<Map<String, Object>>() {}); + } catch (Exception e) { + Assert.fail(e.getMessage()); + } + } + + if (null == this.serviceInput) { + + try { + this.serviceInput = FileUtil.readResourceFile("__files/SERVICE-SO-REQ-INPUT.json"); + } catch (Exception e) { + Assert.fail(e.getMessage()); + } + } + + } + @Test public void getResourceInputTest() throws Exception { @@ -102,7 +136,7 @@ public class ResourceRequestBuilderTest extends BaseTest { HashMap serviceInput = new HashMap(); serviceInput.put("key", "value"); Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest( - "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput); + "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput, null); assertEquals(stringObjectMap.get("a"), "value"); } @@ -173,7 +207,7 @@ public class ResourceRequestBuilderTest extends BaseTest { HashMap serviceInput = new HashMap(); serviceInput.put("key1", "value"); Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest( - "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput); + "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput, null); assertEquals(stringObjectMap.get("a"), "default_value"); } @@ -244,7 +278,7 @@ public class ResourceRequestBuilderTest extends BaseTest { HashMap serviceInput = new HashMap(); serviceInput.put("key1", "value"); Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest( - "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput); + "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput, null); assertEquals(stringObjectMap.get("a"), "value"); } @@ -337,7 +371,7 @@ public class ResourceRequestBuilderTest extends BaseTest { HashMap serviceInput = new HashMap(); serviceInput.put("key1", "value"); Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest( - "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput); + "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput, null); assertEquals(0, stringObjectMap.size()); } @@ -382,8 +416,78 @@ public class ResourceRequestBuilderTest extends BaseTest { HashMap serviceInput = new HashMap(); serviceInput.put("key2", "value"); Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest( - "c3954379-4efe-431c-8258-f84905b158e5", "a00404d5-d7eb-4c46-b6b6-9cf2d087e545", serviceInput); + "c3954379-4efe-431c-8258-f84905b158e5", "a00404d5-d7eb-4c46-b6b6-9cf2d087e545", serviceInput, null); assertEquals(stringObjectMap.get("a"), ""); } + @Test + public void getListResourceInputTest() throws Exception { + + + + wireMockServer.stubFor(get(urlEqualTo( + "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) + .willReturn(ok(this.serviceInput))); + + // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080"); + + // VF level request + Map<String, Object> currentVFData = new HashMap<>(); + Map<String, Object> stringObjectMap = + ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5", + "a00404d5-d7eb-4c46-b6b6-9cf2d087e545", this.userInputMap, currentVFData); + assertEquals("b", stringObjectMap.get("a")); + assertEquals("hub_spoke", stringObjectMap.get("topology")); + assertEquals("defaultvpn", stringObjectMap.get("name")); + assertTrue(((String) stringObjectMap.get("sitelist")).contains("[")); + + // vfc level request + stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5", + "e776449e-2b10-45c5-9217-2775c88ca1a0", this.userInputMap, currentVFData); + assertEquals("", stringObjectMap.get("a")); + assertEquals("layer3-port", stringObjectMap.get("portswitch")); + assertEquals("192.168.10.1", stringObjectMap.get("ipAddress")); + assertEquals("vCPE", stringObjectMap.get("deviceName")); + + // vfc level request + stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5", + "e776449e-2b10-45c5-9217-2775c88ca1a1", this.userInputMap, currentVFData); + assertEquals("", stringObjectMap.get("a")); + assertEquals("layer2-port", stringObjectMap.get("portswitch")); + assertEquals("192.168.11.1", stringObjectMap.get("ipAddress")); + assertEquals("CPE_Beijing", stringObjectMap.get("deviceName")); + + // VF level request + stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5", + "e776449e-2b10-45c5-9217-2775c88ca1c1", this.userInputMap, currentVFData); + assertEquals("Huawei Private Cloud", stringObjectMap.get("address")); + assertEquals("dsvpn_hub1", stringObjectMap.get("role")); + assertTrue(((String) stringObjectMap.get("wanlist")).contains("[")); + assertTrue(((String) stringObjectMap.get("devlist")).contains("[")); + + // VFC request + stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5", + "e776449e-2b10-45c5-9217-2775c88cb1a1", this.userInputMap, currentVFData); + assertEquals("Huawei Private Cloud", stringObjectMap.get("address")); + assertEquals("20000", stringObjectMap.get("postcode")); + assertEquals("single_gateway", stringObjectMap.get("type")); + assertEquals("vCPE", stringObjectMap.get("deviceName")); + assertEquals("20.20.20.1", stringObjectMap.get("systemip")); + assertEquals("default_ipv6", stringObjectMap.get("systemipv6")); + + + // VFC request again + /* + * stringObjectMap = ResourceRequestBuilder.buildResouceRequest( "c3954379-4efe-431c-8258-f84905b158e5", + * "e776449e-2b10-45c5-9217-2775c88cb1f1", this.userInputMap, currentVFData); + * assertEquals("Huawei Public Cloud", stringObjectMap.get("address")); assertEquals("20001", + * stringObjectMap.get("postcode")); assertEquals("multiple_gateway", stringObjectMap.get("type")); + * assertEquals("CPE_Beijing", stringObjectMap.get("deviceName")); assertEquals("20.20.20.2", + * stringObjectMap.get("systemip")); + */ + + + } + + } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/SERVICE-SO-REQ-INPUT.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/SERVICE-SO-REQ-INPUT.json new file mode 100644 index 0000000000..938b45e5a4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/SERVICE-SO-REQ-INPUT.json @@ -0,0 +1,206 @@ +{ + "serviceResources": { + "modelInfo": { + "modelName": "demoVFWCL", + "modelUuid": "c3954379-4efe-431c-8258-f84905b158e5", + "modelInvariantUuid": "0cbff61e-3b0a-4eed-97ce-b1b4faa03493", + "modelVersion": "1.0" + }, + "serviceType": "", + "serviceRole": "", + "environmentContext": null, + "resourceOrder": "res1,res2", + "workloadContext": "Production", + "serviceVnfs": [ + + { + "modelInfo": { + "modelName": "15968a6e-2fe5-41bf-a481", + "modelUuid": "808abda3-2023-4105-92d2-e62644b61d53", + "modelInvariantUuid": "6e4ffc7c-497e-4a77-970d-af966e642d31", + "modelVersion": "1.0", + "modelCustomizationUuid": "a00404d5-d7eb-4c46-b6b6-9cf2d087e545", + "modelInstanceName": "15968a6e-2fe5-41bf-a481 0" + }, + "toscaNodeType": "org.openecomp.resource.vf.15968a6e2fe541bfA481", + "nfFunction": null, + "resourceInput": "{\"a\":\"b\",\"topology\":\"[sdwanvpnresource_list,INDEX,sdwanvpn_topology]|default_topo\",\"name\":\"[sdwanvpnresource_list,INDEX,sdwanvpn_name]|default_name\",\"sitelist\":\"[sdwanvpnresource_list,INDEX,sdwansitelan_list]|default_sitelist\"}", + "nfType": null, + "nfRole": null, + "nfNamingCode": null, + "multiStageDesign": "false", + "vfModules": [{ + "modelInfo": { + "modelName": "15968a6e2fe541bfA481..base_vfw..module-0", + "modelUuid": "ec7fadde-1e5a-42f7-8255-cb19e475ff45", + "modelInvariantUuid": "61ab8b64-a014-4cf3-8a5a-b5ef388f8819", + "modelVersion": "1", + "modelCustomizationUuid": "123aff6b-854f-4026-ae1e-cc74a3924576" + }, + "isBase": true, + "vfModuleLabel": "base_vfw", + "initialCount": 1, + "hasVolumeGroup": true + }] + }, + + { + "modelInfo": { + "modelName": "f971106a-248f-4202-9d1f", + "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add7e", + "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89f3", + "modelVersion": "1.0", + "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88ca1a0", + "modelInstanceName": "f971106a-248f-4202-9d1f 0" + }, + "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d1f", + "nfFunction": null, + "nfType": null, + "nfRole": null, + "resourceInput": "{\"a\":\"b|\",\"portswitch\":\"[sdwansitelan_list,INDEX,portSwitch]|default_portswitch\",\"ipAddress\":\"[sdwansitelan_list,INDEX,ipAddress]|default_ipAddress\",\"deviceName\":\"[sdwansitelan_list,INDEX,deviceName]|default_deviceName\"}", + "nfNamingCode": null, + "multiStageDesign": "false", + "vfModules": [{ + "modelInfo": { + "modelName": "F971106a248f42029d1f..base_vpkg..module-0", + "modelUuid": "47d5273a-7456-4786-9035-b3911944cc35", + "modelInvariantUuid": "0ea3e57e-ac7a-425a-928b-b4aee8806c15", + "modelVersion": "1", + "modelCustomizationUuid": "9ed9fef6-d3f8-4433-9807-7e23393a16bc" + }, + "isBase": true, + "vfModuleLabel": "base_vpkg", + "initialCount": 1, + "hasVolumeGroup": true + }] + }, + + { + "modelInfo": { + "modelName": "f971106a-248f-4202-9d1e", + "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add7d", + "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89f2", + "modelVersion": "1.0", + "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88ca1a1", + "modelInstanceName": "f971106a-248f-4202-9d1e 0" + }, + "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d1f", + "nfFunction": null, + "nfType": null, + "nfRole": null, + "resourceInput": "{\"a\":\"b|\",\"portswitch\":\"[sdwansitelan_list,INDEX,portSwitch]|default_portswitch\",\"ipAddress\":\"[sdwansitelan_list,INDEX,ipAddress]|default_ipAddress\",\"deviceName\":\"[sdwansitelan_list,INDEX,deviceName]|default_deviceName\"}", + "nfNamingCode": null, + "multiStageDesign": "false", + "vfModules": [{ + "modelInfo": { + "modelName": "F971106a248f42029d1f..base_vpkg..module-0", + "modelUuid": "47d5273a-7456-4786-9035-b3911944cc35", + "modelInvariantUuid": "0ea3e57e-ac7a-425a-928b-b4aee8806c15", + "modelVersion": "1", + "modelCustomizationUuid": "9ed9fef6-d3f8-4433-9807-7e23393a16bc" + }, + "isBase": true, + "vfModuleLabel": "base_vpkg", + "initialCount": 1, + "hasVolumeGroup": true + }] + }, + + { + "modelInfo": { + "modelName": "f971106a-248f-4202-9d2e", + "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add8d", + "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89c2", + "modelVersion": "1.0", + "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88ca1c1", + "modelInstanceName": "f971106a-248f-4202-9d2e 0" + }, + "toscaNodeType": "org.openecomp.resource.vf.F971106a248f42029d1f", + "nfFunction": null, + "nfType": null, + "nfRole": null, + "resourceInput": "{\"address\":\"[sdwansiteresource_list,INDEX,sdwansite_address]|default_address\",\"role\":\"[sdwansiteresource_list,INDEX,sdwansite_role]|default_role\",\"wanlist\":\"[sdwansiteresource_list,INDEX,sdwansitewan_list]|default_wanlist\",\"devlist\":\"[sdwansiteresource_list,INDEX,sdwandevice_list]|default_devlist\"}", + "nfNamingCode": null, + "multiStageDesign": "false", + "vfModules": [{ + "modelInfo": { + "modelName": "F971106a248f42029d1f..base_vpkg..module-0", + "modelUuid": "47d5273a-7456-4786-9035-b3911944cc35", + "modelInvariantUuid": "0ea3e57e-ac7a-425a-928b-b4aee8806c15", + "modelVersion": "1", + "modelCustomizationUuid": "9ed9fef6-d3f8-4433-9807-7e23393a16bc" + }, + "isBase": true, + "vfModuleLabel": "base_vpkg", + "initialCount": 1, + "hasVolumeGroup": true + }] + }, + + { + "modelInfo": { + "modelName": "f971106a-248f-4202-9d3e", + "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add9d", + "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89f3", + "modelVersion": "1.0", + "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88cb1a1", + "modelInstanceName": "f971106a-248f-4202-9d3e 0" + }, + "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d1f", + "nfFunction": null, + "nfType": null, + "nfRole": null, + "resourceInput": "{\"address\":\"sdwansite_address|default_address\", \"postcode\":\"sdwansite_postcode|default_postcode\",\"type\":\"sdwansite_type|default_role\",\"deviceName\":\"[sdwansitewan_list,INDEX,deviceName]|default_deviceName\",\"systemip\":\"[sdwandevice_list,INDEX,systemIp]|default_systemip\", \"systemipv6\":\"[sdwandevice_list,INDEX,systemIpv6]|default_ipv6\"}", + "nfNamingCode": null, + "multiStageDesign": "false", + "vfModules": [{ + "modelInfo": { + "modelName": "F971106a248f42029d1f..base_vpkg..module-0", + "modelUuid": "47d5273a-7456-4786-9035-b3911944cc35", + "modelInvariantUuid": "0ea3e57e-ac7a-425a-928b-b4aee8806c15", + "modelVersion": "1", + "modelCustomizationUuid": "9ed9fef6-d3f8-4433-9807-7e23393a16bc" + }, + "isBase": true, + "vfModuleLabel": "base_vpkg", + "initialCount": 1, + "hasVolumeGroup": true + }] + }, + + { + "modelInfo": { + "modelName": "f971106a-248f-4202-9d5e", + "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add3d", + "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe8393", + "modelVersion": "1.0", + "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88cb1f1", + "modelInstanceName": "f971106a-248f-4202-9d5e 0" + }, + "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d3f", + "nfFunction": null, + "nfType": null, + "nfRole": null, + "resourceInput": "{\"address\":\"sdwansite_address|default_address\", \"postcode\":\"sdwansite_postcode|default_postcode\",\"type\":\"sdwansite_type|default_role\",\"deviceName\":\"[sdwansitewan_list,INDEX,deviceName]|default_deviceName\",\"systemip\":\"[sdwandevice_list,INDEX,systemIp]|default_systemip\"}", + "nfNamingCode": null, + "multiStageDesign": "false", + "vfModules": [{ + "modelInfo": { + "modelName": "F971106a248f42029d1f..base_vpkg..module-0", + "modelUuid": "47d5273a-7456-4786-9035-b3911944cc35", + "modelInvariantUuid": "0ea3e57e-ac7a-425a-928b-b4aee8806c15", + "modelVersion": "1", + "modelCustomizationUuid": "9ed9fef6-d3f8-4433-9807-7e23393a16bc" + }, + "isBase": true, + "vfModuleLabel": "base_vpkg", + "initialCount": 1, + "hasVolumeGroup": true + }] + } + + ], + "serviceNetworks": [], + "serviceAllottedResources": [] + } +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/UUI-SO-REQ.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/UUI-SO-REQ.json new file mode 100644 index 0000000000..e6161862ae --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/UUI-SO-REQ.json @@ -0,0 +1 @@ +{
"sdwanvpnresource_list":[
{
"sdwanvpn_topology":"hub_spoke",
"sdwanvpn_name":"defaultvpn",
"sdwansitelan_list":[
{
"role":"Hub",
"portType":"GE",
"portSwitch":"layer3-port",
"vlanId":"",
"ipAddress":"192.168.10.1",
"deviceName":"vCPE",
"portNumer":"0/0/1"
},
{
"role":"Hub",
"portType":"GE",
"portSwitch":"layer2-port",
"vlanId":"55",
"ipAddress":"192.168.11.1",
"deviceName":"CPE_Beijing",
"portNumer":"0/0/1"
}
]
}
],
"sdwansiteresource_list":[
{
"sdwansite_emails":"chenchuanyu@huawei.com",
"sdwansite_address":"Huawei Private Cloud",
"sdwansite_description":"DC Site",
"sdwansite_role":"dsvpn_hub1",
"sdwansite_postcode":"20000",
"sdwansite_type":"single_gateway",
"sdwansite_latitude":"",
"sdwansite_controlPoint":"",
"sdwansite_longitude":"",
"sdwansitewan_list":[
{
"providerIpAddress":"",
"portType":"GE",
"inputBandwidth":"1000",
"ipAddress":"",
"name":"10000",
"transportNetworkName":"internet",
"outputBandwidth":"10000",
"deviceName":"vCPE",
"portNumber":"0/0/0",
"ipMode":"DHCP",
"publicIP":"119.3.7.113"
}
],
"sdwandevice_list":[
{
"esn":"XXXXXXX",
"vendor":"Huawei",
"name":"vCPE",
"type":"AR1000V",
"version":"1.0",
"class":"VNF",
"systemIp":"20.20.20.1"
}
]
},
{
"sdwansite_emails":"chenchuanyu@huawei.com",
"sdwansite_address":"Huawei Public Cloud",
"sdwansite_description":"DC Site",
"sdwansite_role":"dsvpn_hub",
"sdwansite_postcode":"20001",
"sdwansite_type":"multiple_gateway",
"sdwansite_latitude":"",
"sdwansite_controlPoint":"",
"sdwansite_longitude":"",
"sdwansitewan_list":[
{
"providerIpAddress":"",
"portType":"GE",
"inputBandwidth":"1000",
"ipAddress":"172.18.1.2/24",
"name":"10000",
"transportNetworkName":"internet",
"outputBandwidth":"10000",
"deviceName":"CPE_Beijing",
"portNumber":"0/0/0",
"ipMode":"Static",
"publicIP":""
}
],
"sdwandevice_list":[
{
"esn":"XXXXXXX",
"vendor":"Huawei",
"name":"CPE_Beijing",
"type":"AR161",
"version":"1.0",
"class":"PNF",
"systemIp":"20.20.20.2"
}
]
}
]
}
\ No newline at end of file |