summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-10-29 14:27:44 +0200
committerIttay Stern <ittay.stern@att.com>2019-10-29 17:57:50 +0200
commitbf74c24500acf037e24ff75008bbda83fe1be72b (patch)
treefd3fcbf82eeb4f38944b94152e96741cd332b4ab
parent8cb79d98ec8c9f2b2ec495eca11ca067dbc06acb (diff)
Test aai_get_service_instance_topology with vf-module placement data
Issue-ID: VID-603 Change-Id: I2ce89cac91417ef4b60a3943da80f0ff03f865ad Signed-off-by: Ittay Stern <ittay.stern@att.com>
-rw-r--r--vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/Placement.java46
-rw-r--r--vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetVfModulesByVnf.java16
-rw-r--r--vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIStandardQueryGet.java48
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java10
-rw-r--r--vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceInstance.json5
5 files changed, 82 insertions, 43 deletions
diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/Placement.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/Placement.java
index b665fc30f..3018f5f06 100644
--- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/Placement.java
+++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/Placement.java
@@ -10,5 +10,51 @@ public class Placement {
this.lcpRegionId = lcpRegionId;
this.tenantId = tenantId;
}
+
+ public static class Util {
+ static String placementRelationship(String relatedTo, Placement placement) {
+ return "" +
+ "{" +
+ " \"related-to\": \"" + relatedTo + "\"," +
+ " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
+ " \"related-link\": " + relatedLink(placement) + "," +
+ " \"relationship-data\": [" +
+ " {" +
+ " \"relationship-key\": \"cloud-region.cloud-owner\"," +
+ " \"relationship-value\": \"" + placement.cloudOwner + "\"" +
+ " }," +
+ " {" +
+ " \"relationship-key\": \"cloud-region.cloud-region-id\"," +
+ " \"relationship-value\": \"" + placement.lcpRegionId + "\"" +
+ " }," +
+ " {" +
+ " \"relationship-key\": \"tenant.tenant-id\"," +
+ " \"relationship-value\": \"" + placement.tenantId + "\"" +
+ " }," +
+ " {" +
+ " \"relationship-key\": \"vserver.vserver-id\"," +
+ " \"relationship-value\": \"5eef9f6d-9933-4bc6-9a1a-862d61309437\"" +
+ " }" +
+ " ]," +
+ " \"related-to-property\": [" +
+ " {" +
+ " \"property-key\": \"vserver.vserver-name\"," +
+ " \"property-value\": \"zolson5bfapn01dns002\"" +
+ " }" +
+ " ]" +
+ "}";
+ }
+
+ private static String relatedLink(Placement placement) {
+ return ""
+ + "\""
+ + "/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/"
+ + placement.lcpRegionId
+ + "/tenants/tenant/"
+ + placement.tenantId
+ + "/vservers/vserver/5eef9f6d-9933-4bc6-9a1a-862d61309437"
+ + "\"";
+ }
+ }
}
diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetVfModulesByVnf.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetVfModulesByVnf.java
index 798a02642..7a35abc12 100644
--- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetVfModulesByVnf.java
+++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetVfModulesByVnf.java
@@ -5,9 +5,16 @@ import org.springframework.http.HttpMethod;
public class PresetAAIGetVfModulesByVnf extends BaseAAIPreset {
private final String vnfInstanceId;
+ private final Placement vfModule1Placement;
public PresetAAIGetVfModulesByVnf(String vnfInstanceId) {
this.vnfInstanceId = vnfInstanceId;
+ vfModule1Placement = null;
+ }
+
+ public PresetAAIGetVfModulesByVnf(String vnfInstanceId, Placement vfModule2Placement) {
+ this.vnfInstanceId = vnfInstanceId;
+ this.vfModule1Placement = vfModule2Placement;
}
@Override
@@ -20,6 +27,14 @@ public class PresetAAIGetVfModulesByVnf extends BaseAAIPreset {
return getRootPath() + "/network/generic-vnfs/generic-vnf/" + this.vnfInstanceId + "/vf-modules";
}
+ private String placementRelationship(Placement placement) {
+ if (placement != null) {
+ return "," + Placement.Util.placementRelationship("vserver", placement);
+ } else {
+ return "";
+ }
+ }
+
@Override
public Object getResponseBody() {
return "" +
@@ -72,6 +87,7 @@ public class PresetAAIGetVfModulesByVnf extends BaseAAIPreset {
" }" +
" ]" +
" }" +
+ placementRelationship(vfModule1Placement) +
" ]" +
" }" +
" }" +
diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIStandardQueryGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIStandardQueryGet.java
index 642f941e8..7709a0abc 100644
--- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIStandardQueryGet.java
+++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIStandardQueryGet.java
@@ -1,23 +1,22 @@
package org.onap.simulator.presetGenerator.presets.aai;
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+import static org.apache.commons.text.StringEscapeUtils.escapeJson;
+import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.ATT_AIC;
+import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.hvf6;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StrSubstitutor;
import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset;
import org.springframework.http.HttpMethod;
-import java.util.UUID;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
-import static org.apache.commons.text.StringEscapeUtils.escapeJson;
-import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.ATT_AIC;
-import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.hvf6;
-
public class PresetAAIStandardQueryGet extends BaseAAIPreset {
private final String instanceId;
private final String instanceName;
@@ -289,36 +288,7 @@ public class PresetAAIStandardQueryGet extends BaseAAIPreset {
private String buildPlacementRelationship() {
String relatedTo = StringUtils.equals(instanceType,"vf-module")? "vserver": "tenant";
- return "" +
- " {" +
- " \"related-to\": \"" + relatedTo + "\"," +
- " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
- " \"related-link\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/" + this.placement.lcpRegionId + "/tenants/tenant/" + this.placement.tenantId+ "/vservers/vserver/5eef9f6d-9933-4bc6-9a1a-862d61309437\"," +
- " \"relationship-data\": [" +
- " {" +
- " \"relationship-key\": \"cloud-region.cloud-owner\"," +
- " \"relationship-value\": \""+ this.placement.cloudOwner+"\"" +
- " }," +
- " {" +
- " \"relationship-key\": \"cloud-region.cloud-region-id\"," +
- " \"relationship-value\": \"" + this.placement.lcpRegionId + "\"" +
- " }," +
- " {" +
- " \"relationship-key\": \"tenant.tenant-id\"," +
- " \"relationship-value\": \"" + this.placement.tenantId + "\"" +
- " }," +
- " {" +
- " \"relationship-key\": \"vserver.vserver-id\"," +
- " \"relationship-value\": \"5eef9f6d-9933-4bc6-9a1a-862d61309437\"" +
- " }" +
- " ]," +
- " \"related-to-property\": [" +
- " {" +
- " \"property-key\": \"vserver.vserver-name\"," +
- " \"property-value\": \"zolson5bfapn01dns002\"" +
- " }" +
- " ]" +
- " }" ;
+ return Placement.Util.placementRelationship(relatedTo, placement);
}
@Override
diff --git a/vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java
index a563bd77d..e5a2a739b 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java
@@ -9,6 +9,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.ATT_AIC;
import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.ATT_NC;
+import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.AUK51A;
import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.hvf6;
import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.olson3;
import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.defaultPlacement;
@@ -240,7 +241,12 @@ public class ServiceTreeApiTest extends BaseApiTest {
"\"in-maint\": true,", ImmutableMultimap.of("volume-group", volumeGroup1.getReqPath()),
new Placement(ATT_AIC, hvf6, "88a6ca3ee0394ade9403f075db23167e"));
- PresetAAIGetVfModulesByVnf vfModules2 = new PresetAAIGetVfModulesByVnf(vnfPreset2.getInstanceId());
+
+ Placement vfModule2Placement
+ = new Placement(ATT_NC, AUK51A, "73bb4c548dc048d78eccecd445ac06fc");
+
+ PresetAAIGetVfModulesByVnf twoVfModulesPreset =
+ new PresetAAIGetVfModulesByVnf(vnfPreset2.getInstanceId(), vfModule2Placement);
final PresetAAIStandardQueryGet serviceInstance =
PresetAAIStandardQueryGet.ofServiceInstance("service-instance-id", "6e59c5de-f052-46fa-aa7e-2fca9d674c44", "d27e42cf-087e-4d31-88ac-6c4b7585f800", "global-customer-id", "service-instance-type",
@@ -255,7 +261,7 @@ public class ServiceTreeApiTest extends BaseApiTest {
serviceInstance,
l3NetworkPreset3, l3NetworkPreset4, vnfPreset1, vnfPreset2, collection1,
volumeGroup1, l3NetworkPreset1, l3NetworkPreset2, instanceGroup1,
- vlanTag1, vfModules2,
+ vlanTag1, twoVfModulesPreset,
new PresetAAIModelsByInvariantIdGet(ImmutableList.of("d27e42cf-087e-4d31-88ac-6c4b7585f800")),
new PresetGetSessionSlotCheckIntervalGet(),
new PresetAAIGetSubscribersGet(),
diff --git a/vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceInstance.json b/vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceInstance.json
index 50786d36b..d20760b6b 100644
--- a/vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceInstance.json
+++ b/vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceInstance.json
@@ -160,9 +160,10 @@
},
"uuid": "dc229cd8-c132-4455-8517-5c1787c18b14",
"productFamilyId": null,
- "lcpCloudRegionId": null,
+ "cloudOwner": "att-nc",
+ "lcpCloudRegionId": "auk51a",
"legacyRegion": null,
- "tenantId": null,
+ "tenantId": "73bb4c548dc048d78eccecd445ac06fc",
"lineOfBusiness": null,
"platformName": null,
"isBase": true,