summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-simulators
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-simulators')
-rw-r--r--models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java271
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java88
2 files changed, 103 insertions, 256 deletions
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
index 793babf24..3b1772342 100644
--- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
+++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
@@ -23,13 +23,9 @@ package org.onap.policy.simulators;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
import java.util.UUID;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
-import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@@ -37,13 +33,10 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.apache.commons.io.IOUtils;
-import org.onap.policy.aai.AaiNqRequest;
-import org.onap.policy.aai.util.Serialization;
@Path("/aai")
public class AaiSimulatorJaxRs {
- private static final String VSERVER = "vserver";
private static final String DISABLE_CLOSEDLOOP = "disableClosedLoop";
private static final String ERROR = "error";
private static final String GETFAIL = "getFail";
@@ -60,8 +53,8 @@ public class AaiSimulatorJaxRs {
@Produces("application/json")
public String aaiGetQuery(@PathParam("vnfID") final String vnfId) {
return "{\"relationship-list\": {\"relationship\":[{\"related-to-property\": [{\"property-key\": "
- + "\"service-instance.service-instance-name\"}]},{\"related-to-property\": [ {\"property-key\": "
- + "\"vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
+ + "\"service-instance.service-instance-name\"}]},{\"related-to-property\": [ {\"property-key\": "
+ + "\"vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
}
/**
@@ -73,14 +66,19 @@ public class AaiSimulatorJaxRs {
@Path("/v16/search/nodes-query")
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
- public String aaiGetVserverQuery() {
- return "{\"result-data\":[{\"resource-type\": \"vserver\",\"resource-link\":\"/aai/v15/"
+ public String aaiGetVserverQuery(@QueryParam("filter") final String filter) {
+ if (filter.equals("vserver-name:EQUALS:f953c499-4b1e-426b-8c6d-e9e9f1fc730f")
+ || filter.equals("vserver-name:EQUALS:OzVServer")
+ || filter.equals("vserver-name:EQUALS:testVserverName")) {
+ return "{\"result-data\":[{\"resource-type\": \"vserver\",\"resource-link\":\"/aai/v15/"
+ "cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants"
+ "/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/"
+ "6c3b3714-e36c-45af-9f16-7d3a73d99497\"}]}}";
+ } else {
+ return null;
+ }
}
-
/**
* A&AI put query.
*
@@ -93,56 +91,8 @@ public class AaiSimulatorJaxRs {
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String aaiPutQuery(final String req) throws IOException {
- return IOUtils.toString(getClass().getResource("aai/AaiCqResponse.json"), StandardCharsets.UTF_8);
- }
-
- /**
- * A&AI post query.
- *
- * @param req the request
- * @return the response
- * @throws IOException if a response file cannot be read
- */
- @POST
- @Path("/search/named-query")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String aaiPostQuery(final String req) throws IOException {
- final AaiNqRequest request = Serialization.gsonPretty.fromJson(req, AaiNqRequest.class);
-
- if (request.getInstanceFilters().getInstanceFilter().get(0).containsKey(VSERVER)) {
- final String vserverName =
- request.getInstanceFilters().getInstanceFilter().get(0).get(VSERVER).get("vserver-name");
- if (ERROR.equals(vserverName)) {
- Map<String, String> params = new TreeMap<>();
- params.put("type", VSERVER);
- return load("aai/AaiNqResponse-Error.json", params);
- } else {
- // vll format - new
- // new aai response from Brian 11/13/2017
- return load("aai/AaiNqResponse-Vserver.json", new TreeMap<>());
- }
- } else {
- final String vnfId =
- request.getInstanceFilters().getInstanceFilter().get(0).get("generic-vnf").get("vnf-id");
- if (ERROR.equals(vnfId)) {
- Map<String, String> params = new TreeMap<>();
- params.put("type", "generic-vnf");
- return load("aai/AaiNqResponse-Error.json", params);
- } else {
- Map<String, String> params = new TreeMap<>();
- params.put("vnfId", "" + vnfId);
- params.put("vnfName", getUuidValue(vnfId, "ZRDM2MMEX39"));
- params.put("pnfVndName", "pnf-test-" + vnfId);
- params.put("pnfVnfId", getUuidValue(params.get("pnfVndName"), "jimmy-test"));
-
- params.put("serviceInstanceVnfName", "service-instance-test-" + vnfId);
- params.put("serviceInstanceVnfId",
- getUuidValue(params.get("serviceInstanceVnfName"), "jimmy-test-vnf2"));
-
- return load("aai/AaiNqResponse-GenericVnf.json", params);
- }
- }
+ return IOUtils.toString(getClass().getResource("aai/AaiCqResponse.json"),
+ StandardCharsets.UTF_8);
}
/**
@@ -158,66 +108,66 @@ public class AaiSimulatorJaxRs {
public String getByVnfName(@QueryParam("vnf-name") final String vnfName) {
if (GETFAIL.equals(vnfName)) {
return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not"
- + " found for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/"
- + "generic-vnf\",\"Node Not Found:No Node of type generic-vnf found at network/generic-vnfs"
- + "/generic-vnf\",\"ERR.5.4.6114\"]}}}";
+ + " found for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/"
+ + "generic-vnf\",\"Node Not Found:No Node of type generic-vnf found at network/generic-vnfs"
+ + "/generic-vnf\",\"ERR.5.4.6114\"]}}}";
}
final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vnfName);
if (ERROR.equals(vnfName)) {
return "{ \"vnf-id\": \"error\", \"vnf-name\": \"" + vnfName
- + "\", \"vnf-type\": \"RT\", \"service-id\": \"d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \""
- + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \""
- + "ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \""
- + "nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \""
- + "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"prov-status\":\"ACTIVE\", "
- + "\"is-closed-loop-disabled\": " + isDisabled
- + ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \""
- + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer/"
- + "1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/"
- + "service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"relationship-data\":[{ \""
- + "relationship-key\": \"customer.global-customer-id\", \"relationship-value\": \""
- + "1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"service-subscription.service-type"
- + "\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key\": \""
- + "service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01"
- + "\"} ], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name"
- + "\"}]},{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/"
- + "cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/"
- + "USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver/3b2558f4-39d8-40e7-bfc7-30660fb52c45"
- + "\", \"relationship-data\":[{ \"relationship-key\": \"cloud-region.cloud-owner\", \""
- + "relationship-value\": \"att-aic\"},{ \"relationship-key\": \"cloud-region.cloud-region-id"
- + "\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \"tenant.tenant-id"
- + "\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \"relationship-key\": \""
- + "vserver.vserver-id\", \"relationship-value\": \"3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \""
- + "related-to-property\": [ {\"property-key\": \"vserver.vserver-name\",\"property-value\": \""
- + "USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
-
- }
- final String vnfId = getUuidValue(vnfName, "5e49ca06-2972-4532-9ed4-6d071588d792");
- return "{ \"vnf-id\": \"" + vnfId + "\", \"vnf-name\": \"" + vnfName
+ "\", \"vnf-type\": \"RT\", \"service-id\": \"d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \""
- + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \"ATT"
- + "\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \""
+ + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \""
+ + "ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \""
+ "nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \""
+ "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"prov-status\":\"ACTIVE\", "
+ "\"is-closed-loop-disabled\": " + isDisabled
+ ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \""
- + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer"
- + "/1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/"
+ + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer/"
+ + "1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/"
+ "service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"relationship-data\":[{ \""
+ "relationship-key\": \"customer.global-customer-id\", \"relationship-value\": \""
+ "1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"service-subscription.service-type"
+ "\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key\": \""
- + "service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} ], \""
- + "related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]},{ \""
- + "related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/"
- + "cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver"
- + "/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \""
- + "cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \""
- + "cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \""
- + "tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \""
- + "relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \""
- + "3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \""
- + "vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
+ + "service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01"
+ + "\"} ], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name"
+ + "\"}]},{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/"
+ + "cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/"
+ + "USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver/3b2558f4-39d8-40e7-bfc7-30660fb52c45"
+ + "\", \"relationship-data\":[{ \"relationship-key\": \"cloud-region.cloud-owner\", \""
+ + "relationship-value\": \"att-aic\"},{ \"relationship-key\": \"cloud-region.cloud-region-id"
+ + "\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \"tenant.tenant-id"
+ + "\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \"relationship-key\": \""
+ + "vserver.vserver-id\", \"relationship-value\": \"3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \""
+ + "related-to-property\": [ {\"property-key\": \"vserver.vserver-name\",\"property-value\": \""
+ + "USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
+
+ }
+ final String vnfId = getUuidValue(vnfName, "5e49ca06-2972-4532-9ed4-6d071588d792");
+ return "{ \"vnf-id\": \"" + vnfId + "\", \"vnf-name\": \"" + vnfName
+ + "\", \"vnf-type\": \"RT\", \"service-id\": \"d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \""
+ + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \"ATT"
+ + "\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \""
+ + "nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \""
+ + "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"prov-status\":\"ACTIVE\", "
+ + "\"is-closed-loop-disabled\": " + isDisabled
+ + ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \""
+ + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer"
+ + "/1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/"
+ + "service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"relationship-data\":[{ \""
+ + "relationship-key\": \"customer.global-customer-id\", \"relationship-value\": \""
+ + "1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"service-subscription.service-type"
+ + "\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key\": \""
+ + "service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} ], \""
+ + "related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]},{ \""
+ + "related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/"
+ + "cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver"
+ + "/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \""
+ + "cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \""
+ + "cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \""
+ + "tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \""
+ + "relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \""
+ + "3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \""
+ + "vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
}
/**
@@ -233,37 +183,37 @@ public class AaiSimulatorJaxRs {
public String getByVnfId(@PathParam("vnfId") final String vnfId) {
if (GETFAIL.equals(vnfId)) {
return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found"
- + " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/"
- + "generic-vnf/getFail\",\"Node Not Found:No Node of type generic-vnf found at network/"
- + "generic-vnfs/generic-vnf/getFail\",\"ERR.5.4.6114\"]}}}";
+ + " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/"
+ + "generic-vnf/getFail\",\"Node Not Found:No Node of type generic-vnf found at network/"
+ + "generic-vnfs/generic-vnf/getFail\",\"ERR.5.4.6114\"]}}}";
}
final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vnfId);
final String vnfName = getUuidValue(vnfId, "USUCP0PCOIL0110UJRT01");
return "{ \"vnf-id\": \"" + vnfId + "\", \"vnf-name\": \"" + vnfName
- + "\", \"vnf-type\": \"RT\", \"service-id\": \""
- + "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \"equipment-role\": \"UCPE\", \"orchestration-status"
- + "\": \"created\", \"management-option\": \"ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \""
- + "ipv4-loopback0-address\": \"32.40.64.57\", \"nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345"
- + "\", \"management-v6-address\": \"2001:1890:e00e:fffd::36\", \"in-maint\": false, "
- + "\"prov-status\":\"ACTIVE\", \"" + "" + "is-closed-loop-disabled\": " + isDisabled
- + ", \"resource-version\": \"1493389458092\", \""
- + "relationship-list\": {\"relationship\":[{ \"related-to\": \"service-instance\", \"related-link"
- + "\": \"/aai/v11/business/customers/customer/1610_Func_Global_20160817084727/service-subscriptions"
- + "/service-subscription/uCPE-VMS/service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \""
- + "relationship-data\":[{ \"relationship-key\": \"customer.global-customer-id\", \""
- + "relationship-value\": \"1610_Func_Global_20160817084727\"},{ \"relationship-key\": \""
- + "service-subscription.service-type\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key"
- + "\": \"service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} "
- + "], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]},"
- + "{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/"
- + "cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver"
- + "/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \""
- + "cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \""
- + "cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \""
- + "tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \""
- + "relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \""
- + "3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \""
- + "vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
+ + "\", \"vnf-type\": \"RT\", \"service-id\": \""
+ + "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \"equipment-role\": \"UCPE\", \"orchestration-status"
+ + "\": \"created\", \"management-option\": \"ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \""
+ + "ipv4-loopback0-address\": \"32.40.64.57\", \"nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345"
+ + "\", \"management-v6-address\": \"2001:1890:e00e:fffd::36\", \"in-maint\": false, "
+ + "\"prov-status\":\"ACTIVE\", \"" + "" + "is-closed-loop-disabled\": " + isDisabled
+ + ", \"resource-version\": \"1493389458092\", \""
+ + "relationship-list\": {\"relationship\":[{ \"related-to\": \"service-instance\", \"related-link"
+ + "\": \"/aai/v11/business/customers/customer/1610_Func_Global_20160817084727/service-subscriptions"
+ + "/service-subscription/uCPE-VMS/service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \""
+ + "relationship-data\":[{ \"relationship-key\": \"customer.global-customer-id\", \""
+ + "relationship-value\": \"1610_Func_Global_20160817084727\"},{ \"relationship-key\": \""
+ + "service-subscription.service-type\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key"
+ + "\": \"service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} "
+ + "], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]},"
+ + "{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/"
+ + "cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver"
+ + "/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \""
+ + "cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \""
+ + "cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \""
+ + "tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \""
+ + "relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \""
+ + "3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \""
+ + "vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
}
/**
@@ -279,47 +229,28 @@ public class AaiSimulatorJaxRs {
public String getByVserverName(@QueryParam("vserver-name") final String vserverName) {
if (GETFAIL.equals(vserverName)) {
return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found"
- + " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"nodes/vservers\",\"Node Not"
- + " Found:No Node of type generic-vnf found at nodes/vservers\",\"ERR.5.4.6114\"]}}}";
+ + " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"nodes/vservers\",\"Node Not"
+ + " Found:No Node of type generic-vnf found at nodes/vservers\",\"ERR.5.4.6114\"]}}}";
}
final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vserverName);
final String vserverId = getUuidValue(vserverName, "d0668d4f-c25e-4a1b-87c4-83845c01efd8");
- return "{\"vserver\": [{ \"vserver-id\": \"" + vserverId + "\", \"vserver-name\": \"" + vserverName
- + "\", \"vserver-name2\": \"vjunos0\", \"vserver-selflink\": \"https://aai-ext1.test.att.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver/d0668d4f-c25e-4a1b-87c4-83845c01efd8\", \"in-maint\": false, \"is-closed-loop-disabled\": "
- + isDisabled + ", \"prov-status\":\"ACTIVE\", \"resource-version\": \"1494001931513\", "
- + "\"relationship-list\": {\"relationship\":[{ \"related-to"
- + "\": \"generic-vnf\", \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/"
- + "e1a41e99-4ede-409a-8f9d-b5e12984203a\", \"relationship-data\": [ {\"relationship-key\": \""
- + "generic-vnf.vnf-id\",\"relationship-value\": \"e1a41e99-4ede-409a-8f9d-b5e12984203a\" }], \""
- + "related-to-property\": [ {\"property-key\": \"generic-vnf.vnf-name\",\"property-value\": \""
- + "USMSO1SX7NJ0103UJSW01\" }]},{ \"related-to\": \"pserver\", \"related-link\": \"/aai/v11/"
- + "cloud-infrastructure/pservers/pserver/USMSO1SX7NJ0103UJZZ01\", \"relationship-data\": [ {\""
- + "relationship-key\": \"pserver.hostname\",\"relationship-value\": \"USMSO1SX7NJ0103UJZZ01\" }], \""
- + "related-to-property\": [{\"property-key\": \"pserver.pserver-name2\"}]} ]}}]}";
+ return "{\"vserver\": [{ \"vserver-id\": \"" + vserverId + "\", \"vserver-name\": \""
+ + vserverName
+ + "\", \"vserver-name2\": \"vjunos0\", \"vserver-selflink\": \"https://aai-ext1.test.att.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver/d0668d4f-c25e-4a1b-87c4-83845c01efd8\", \"in-maint\": false, \"is-closed-loop-disabled\": "
+ + isDisabled + ", \"prov-status\":\"ACTIVE\", \"resource-version\": \"1494001931513\", "
+ + "\"relationship-list\": {\"relationship\":[{ \"related-to"
+ + "\": \"generic-vnf\", \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/"
+ + "e1a41e99-4ede-409a-8f9d-b5e12984203a\", \"relationship-data\": [ {\"relationship-key\": \""
+ + "generic-vnf.vnf-id\",\"relationship-value\": \"e1a41e99-4ede-409a-8f9d-b5e12984203a\" }], \""
+ + "related-to-property\": [ {\"property-key\": \"generic-vnf.vnf-name\",\"property-value\": \""
+ + "USMSO1SX7NJ0103UJSW01\" }]},{ \"related-to\": \"pserver\", \"related-link\": \"/aai/v11/"
+ + "cloud-infrastructure/pservers/pserver/USMSO1SX7NJ0103UJZZ01\", \"relationship-data\": [ {\""
+ + "relationship-key\": \"pserver.hostname\",\"relationship-value\": \"USMSO1SX7NJ0103UJZZ01\" }], \""
+ + "related-to-property\": [{\"property-key\": \"pserver.pserver-name2\"}]} ]}}]}";
}
private String getUuidValue(final String value, final String defaultValue) {
return value != null ? UUID.nameUUIDFromBytes(value.getBytes()).toString() : defaultValue;
}
- /**
- * Loads a JSON response from a file and then replaces parameters of the form, ${xxx}, with values.
- *
- * @param fileName name of the file containing the JSON
- * @param params parameters to be substituted
- * @return the JSON response, after parameter substitution
- * @throws IOException if the file cannot be read
- */
- private String load(String fileName, Map<String, String> params) throws IOException {
- String json = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8);
-
- // perform parameter substitution
- for (Entry<String, String> ent : params.entrySet()) {
- String name = "${" + ent.getKey() + "}";
- String value = ent.getValue();
- json = json.replace(name, value);
- }
-
- return json;
- }
}
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
index a03010a00..1d60af0e1 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
@@ -23,26 +23,14 @@ package org.onap.policy.simulators;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
import java.util.UUID;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.aai.AaiCqResponse;
-import org.onap.policy.aai.AaiGetVnfResponse;
import org.onap.policy.aai.AaiManager;
-import org.onap.policy.aai.AaiNqInstanceFilters;
-import org.onap.policy.aai.AaiNqNamedQuery;
-import org.onap.policy.aai.AaiNqQueryParameters;
-import org.onap.policy.aai.AaiNqRequest;
-import org.onap.policy.aai.AaiNqResponse;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.rest.RestManager;
@@ -66,82 +54,10 @@ public class AaiSimulatorTest {
}
@Test
- public void testGet() {
- final AaiGetVnfResponse response = new AaiManager(new RestManager()).getQueryByVnfId(
- "http://localhost:6666/aai/v11/network/generic-vnfs/generic-vnf/", "testUser", "testPass",
- UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792");
- assertNotNull(response);
- assertNotNull(response.getRelationshipList());
- }
-
- @Test
public void testCqGet() {
final AaiCqResponse response = new AaiManager(new RestManager()).getCustomQueryResponse("http://localhost:6666",
- "testUser", "testPass", UUID.randomUUID(), "Ete_vFWCLvFWSNK_7ba1fbde_0");
- assertNotNull(response);
- assertEquals(response.getVserver().getVserverName(), "Ete_vFWCLvFWSNK_7ba1fbde_0");
- }
-
- @Test
- public void testPost() {
- // check vserver named query
- final AaiNqRequest request = new AaiNqRequest();
- final AaiNqQueryParameters tempQueryParameters = new AaiNqQueryParameters();
- final AaiNqNamedQuery tempNamedQuery = new AaiNqNamedQuery();
- tempNamedQuery.setNamedQueryUuid(UUID.fromString("4ff56a54-9e3f-46b7-a337-07a1d3c6b469"));
- tempQueryParameters.setNamedQuery(tempNamedQuery);
- request.setQueryParameters(tempQueryParameters);
- Map<String, String> tempInnerMap = new HashMap<>();
- tempInnerMap.put("vserver-name", "vserver-name-16102016-aai3255-data-11-1");
- Map<String, Map<String, String>> tempOuterMap = new HashMap<>();
- tempOuterMap.put("vserver", tempInnerMap);
- List<Map<String, Map<String, String>>> tempInstanceFilter = new LinkedList<>();
- tempInstanceFilter.add(tempOuterMap);
- AaiNqInstanceFilters tempInstanceFilters = new AaiNqInstanceFilters();
- tempInstanceFilters.setInstanceFilter(tempInstanceFilter);
- request.setInstanceFilters(tempInstanceFilters);
-
- AaiNqResponse response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser",
- "testPass", request, UUID.randomUUID());
- assertNotNull(response);
- assertNotNull(response.getInventoryResponseItems());
-
- // check error response for vserver query
- tempInnerMap.put("vserver-name", "error");
-
- response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", "testPass", request,
- UUID.randomUUID());
- assertNotNull(response);
- assertNotNull(response.getRequestError());
- assertTrue(response.getRequestError().getServiceExcept().getVariables()[2].contains("vserver"));
-
- // check generic-vnf named query
- tempNamedQuery.setNamedQueryUuid(UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087"));
- tempQueryParameters.setNamedQuery(tempNamedQuery);
- request.setQueryParameters(tempQueryParameters);
- tempInnerMap = new HashMap<>();
- tempInnerMap.put("vnf-id", "de7cc3ab-0212-47df-9e64-da1c79234deb");
- tempOuterMap = new HashMap<>();
- tempOuterMap.put("generic-vnf", tempInnerMap);
- tempInstanceFilter = new LinkedList<>();
- tempInstanceFilter.add(tempOuterMap);
- tempInstanceFilters = new AaiNqInstanceFilters();
- tempInstanceFilters.setInstanceFilter(tempInstanceFilter);
- request.setInstanceFilters(tempInstanceFilters);
-
- response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", "testPass", request,
- UUID.randomUUID());
- assertNotNull(response);
- assertNotNull(response.getInventoryResponseItems());
- assertNull(response.getRequestError());
-
- // check error response for generic-vnf query
- tempInnerMap.put("vnf-id", "error");
-
- response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", "testPass", request,
- UUID.randomUUID());
+ "testUser", "testPass", UUID.randomUUID(), "f953c499-4b1e-426b-8c6d-e9e9f1fc730f");
assertNotNull(response);
- assertNotNull(response.getRequestError());
- assertTrue(response.getRequestError().getServiceExcept().getVariables()[2].contains("generic-vnf"));
+ assertEquals(response.getVserver().getVserverId(), "f953c499-4b1e-426b-8c6d-e9e9f1fc730f");
}
}