summaryrefslogtreecommitdiffstats
path: root/controlloop/common/simulators
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/simulators')
-rw-r--r--controlloop/common/simulators/pom.xml7
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java18
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/GuardSimulatorJaxRs.java47
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java2
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java81
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java20
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java121
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java58
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java198
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java75
10 files changed, 406 insertions, 221 deletions
diff --git a/controlloop/common/simulators/pom.xml b/controlloop/common/simulators/pom.xml
index fc0d4c2d3..952d9b687 100644
--- a/controlloop/common/simulators/pom.xml
+++ b/controlloop/common/simulators/pom.xml
@@ -56,7 +56,12 @@
<version>1.1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>guard</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.onap.policy.drools-applications</groupId>
<artifactId>vfc</artifactId>
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
index a9c35b6ce..59e97c239 100644
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
@@ -25,6 +25,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.onap.policy.aai.AAINQRequest;
@@ -35,6 +36,7 @@ public class AaiSimulatorJaxRs {
@GET
@Path("/v8/network/generic-vnfs/generic-vnf/{vnfId}")
+ @Produces("application/json")
public String aaiGetQuery (@PathParam("vnfID") 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\" }]} ]}}";
@@ -43,6 +45,7 @@ public class AaiSimulatorJaxRs {
@POST
@Path("/search/named-query")
@Consumes(MediaType.APPLICATION_JSON)
+ @Produces("application/json")
public String aaiPostQuery(String req)
{
AAINQRequest request = Serialization.gsonPretty.fromJson(req, AAINQRequest.class);
@@ -53,28 +56,35 @@ public class AaiSimulatorJaxRs {
}
else
{
- return "{\"inventory-response-item\": [{\"model-name\": \"service-instance\",\"generic-vnf\": {\"vnf-id\": \"de7cc3ab-0212-47df-9e64-da1c79234deb\",\"vnf-name\": \"ZRDM2MMEX39\",\"vnf-type\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1503082370097\",\"model-invariant-id\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\",\"model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\"},\"extra-properties\": {},\"inventory-response-items\": {\"inventory-response-item\": [{\"model-name\": \"service-instance\",\"service-instance\": {\"service-instance-id\": \"37b8cdb7-94eb-468f-a0c2-4e3c3546578e\",\"service-instance-name\": \"Changed Service Instance NAME\",\"model-invariant-id\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\",\"model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\",\"resource-version\": \"1503082993532\",\"orchestration-status\": \"Active\"},\"extra-properties\": {},\"inventory-response-items\": {\"inventory-response-item\": [{\"model-name\": \"pnf\",\"generic-vnf\": {\"vnf-id\": \"jimmy-test\",\"vnf-name\": \"jimmy-test-vnf\",\"vnf-type\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1504013830207\",\"model-invariant-id\": \"862b25a1-262a-4961-bdaa-cdc55d69785a\",\"model-version-id\": \"e9f1fa7d-c839-418a-9601-03dc0d2ad687\"},\"extra-properties\": {}},{\"model-name\": \"service-instance\",\"generic-vnf\": {\"vnf-id\": \"jimmy-test-vnf2\",\"vnf-name\": \"jimmy-test-vnf2-named\",\"vnf-type\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1504014833841\",\"model-invariant-id\": \"Eace933104d443b496b8.nodes.heat.vpg\",\"model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\"},\"extra-properties\": {}}]}}]}}]}";
+ String vnfID = request.instanceFilters.instanceFilter.get(0).get("generic-vnf").get("vnf-id");
+ return "{\"inventory-response-item\": [{\"model-name\": \"service-instance\",\"generic-vnf\": {\"vnf-id\": \""+ vnfID + "\",\"vnf-name\": \"ZRDM2MMEX39\",\"vnf-type\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1503082370097\",\"model-invariant-id\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\",\"model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\"},\"extra-properties\": {},\"inventory-response-items\": {\"inventory-response-item\": [{\"model-name\": \"service-instance\",\"service-instance\": {\"service-instance-id\": \"37b8cdb7-94eb-468f-a0c2-4e3c3546578e\",\"service-instance-name\": \"Changed Service Instance NAME\",\"model-invariant-id\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\",\"model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\",\"resource-version\": \"1503082993532\",\"orchestration-status\": \"Active\"},\"extra-properties\": {},\"inventory-response-items\": {\"inventory-response-item\": [{\"model-name\": \"pnf\",\"generic-vnf\": {\"vnf-id\": \"jimmy-test\",\"vnf-name\": \"jimmy-test-vnf\",\"vnf-type\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1504013830207\",\"model-invariant-id\": \"862b25a1-262a-4961-bdaa-cdc55d69785a\",\"model-version-id\": \"e9f1fa7d-c839-418a-9601-03dc0d2ad687\"},\"extra-properties\": {}},{\"model-name\": \"service-instance\",\"generic-vnf\": {\"vnf-id\": \"jimmy-test-vnf2\",\"vnf-name\": \"jimmy-test-vnf2-named\",\"vnf-type\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1504014833841\",\"model-invariant-id\": \"Eace933104d443b496b8.nodes.heat.vpg\",\"model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\"},\"extra-properties\": {}}]}}]}}]}";
}
}
@GET
@Path("/v11/network/generic-vnfs/generic-vnf?vnf-name={vnfName}")
+ @Produces("application/json")
public String getByVnfName (@PathParam("vnfName") String vnfName)
{
- return "{ \"vnf-id\": \"5e49ca06-2972-4532-9ed4-6d071588d792\", \"vnf-name\": \"USUCP0PCOIL0110UJRT01\", \"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, \"is-closed-loop-disabled\": false, \"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\" }]} ]}}";
+ boolean isDisabled = "disableClosedLoop".equals(vnfName);
+ return "{ \"vnf-id\": \"5e49ca06-2972-4532-9ed4-6d071588d792\", \"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, \"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\" }]} ]}}";
}
@GET
@Path("/v11/network/generic-vnfs/generic-vnf/{vnfId}")
+ @Produces("application/json")
public String getByVnfId (@PathParam("vnfId") String vnfId)
{
- return "{ \"vnf-id\": \"5e49ca06-2972-4532-9ed4-6d071588d792\", \"vnf-name\": \"USUCP0PCOIL0110UJRT01\", \"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, \"is-closed-loop-disabled\": false, \"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\" }]} ]}}";
+ boolean isDisabled = "disableClosedLoop".equals(vnfId);
+ return "{ \"vnf-id\": \"" + vnfId + "\", \"vnf-name\": \"USUCP0PCOIL0110UJRT01\", \"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, \"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\" }]} ]}}";
}
@GET
@Path("/v11/nodes/vservers?vserver-name={vserverName}")
+ @Produces("application/json")
public String getByVserverName (@PathParam("vserverName") String vserverName)
{
- return "{\"vserver\": [{ \"vserver-id\": \"d0668d4f-c25e-4a1b-87c4-83845c01efd8\", \"vserver-name\": \"USMSO1SX7NJ0103UJZZ01-vjunos0\", \"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\": false, \"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\"}]} ]}}]}";
+ boolean isDisabled = "disableClosedLoop".equals(vserverName);
+ return "{\"vserver\": [{ \"vserver-id\": \"d0668d4f-c25e-4a1b-87c4-83845c01efd8\", \"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 + ", \"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\"}]} ]}}]}";
}
}
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/GuardSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/GuardSimulatorJaxRs.java
new file mode 100644
index 000000000..7415130ea
--- /dev/null
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/GuardSimulatorJaxRs.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * simulators
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.onap.policy.simulators;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.json.JSONObject;
+
+@Path("/pdp/api")
+public class GuardSimulatorJaxRs {
+
+ @POST
+ @Path("/getDecision")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces("application/json")
+ public String getGuardDecision(String req){
+ String clName = new JSONObject(req).getJSONObject("decisionAttributes").getString("clname");
+ if ("denyGuard".equals(clName))
+ {
+ return "{\"decision\": \"DENY\", \"details\": \"Decision Deny. You asked for it\"}";
+ }
+ else
+ return "{\"decision\": \"PERMIT\", \"details\": \"Decision Permit. OK!\"}";
+ }
+}
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java
index 1ebb281fd..b9e657764 100644
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java
@@ -24,6 +24,7 @@ import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.onap.policy.so.SORequest;
@@ -35,6 +36,7 @@ public class SoSimulatorJaxRs {
@POST
@Path("/v2/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModulesHTTPS/1.1")
@Consumes(MediaType.APPLICATION_JSON)
+ @Produces("application/json")
public String SoPostQuery(@PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, String req)
{
SORequest request = Serialization.gsonPretty.fromJson(req, SORequest.class);
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
index 9fbb2b50f..cd45d3134 100644
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
@@ -7,9 +7,9 @@
* 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.
@@ -24,35 +24,54 @@ import java.io.IOException;
import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.utils.NetworkUtil;
-import org.onap.policy.simulators.AaiSimulatorJaxRs;
-import org.onap.policy.simulators.SoSimulatorJaxRs;
-import org.onap.policy.simulators.VfcSimulatorJaxRs;
public class Util {
- public static HttpServletServer buildAaiSim() throws InterruptedException, IOException {
- HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6666, "/", false, true);
- testServer.addServletClass("/*", AaiSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
- throw new IllegalStateException("cannot connect to port " + testServer.getPort());
- return testServer;
- }
-
- public static HttpServletServer buildSoSim() throws InterruptedException, IOException {
- HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6667, "/", false, true);
- testServer.addServletClass("/*", SoSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
- throw new IllegalStateException("cannot connect to port " + testServer.getPort());
- return testServer;
- }
-
- public static HttpServletServer buildVfcSim() throws InterruptedException, IOException {
- HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6668, "/", false, true);
- testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
- throw new IllegalStateException("cannot connect to port " + testServer.getPort());
- return testServer;
- }
+ public static final String AAISIM_SERVER_NAME = "aaiSim";
+ public static final String SOSIM_SERVER_NAME = "soSim";
+ public static final String VFCSIM_SERVER_NAME = "vfcSim";
+ public static final String GUARDSIM_SERVER_NAME = "guardSim";
+
+ public static final int AAISIM_SERVER_PORT = 6666;
+ public static final int SOSIM_SERVER_PORT = 6667;
+ public static final int VFCSIM_SERVER_PORT = 6668;
+ public static final int GUARDSIM_SERVER_PORT = 6669;
+
+ public static HttpServletServer buildAaiSim() throws InterruptedException, IOException {
+ final HttpServletServer testServer = HttpServletServer.factory.build(AAISIM_SERVER_NAME,
+ "localhost", AAISIM_SERVER_PORT, "/", false, true);
+ testServer.addServletClass("/*", AaiSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
+ throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+ return testServer;
+ }
+
+ public static HttpServletServer buildSoSim() throws InterruptedException, IOException {
+ final HttpServletServer testServer = HttpServletServer.factory.build(SOSIM_SERVER_NAME,
+ "localhost", SOSIM_SERVER_PORT, "/", false, true);
+ testServer.addServletClass("/*", SoSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
+ throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+ return testServer;
+ }
+
+ public static HttpServletServer buildVfcSim() throws InterruptedException, IOException {
+ final HttpServletServer testServer = HttpServletServer.factory.build(VFCSIM_SERVER_NAME,
+ "localhost", VFCSIM_SERVER_PORT, "/", false, true);
+ testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
+ throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+ return testServer;
+ }
+
+ public static HttpServletServer buildGuardSim() throws InterruptedException, IOException {
+ HttpServletServer testServer = HttpServletServer.factory.build(GUARDSIM_SERVER_NAME, "localhost", GUARDSIM_SERVER_PORT, "/", false, true);
+ testServer.addServletClass("/*", GuardSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
+ throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+ return testServer;
+ }
}
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
index 51a85ce60..926536e31 100644
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
@@ -24,21 +24,33 @@ import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.Context;
@Path("/api/nslcm/v1")
public class VfcSimulatorJaxRs {
@POST
@Path("/ns/{nsInstanceId}/heal")
- public String vfcPostQuery(@PathParam("nsInstanceId") String nsInstanceId)
+ @Produces("application/json")
+ public String vfcPostQuery(@PathParam("nsInstanceId") String nsInstanceId,
+ @Context final HttpServletResponse response)
{
+ response.setStatus(HttpServletResponse.SC_ACCEPTED);
+ try {
+ response.flushBuffer();
+ }catch(Exception e){}
+
return "{\"jobId\":\"1\"}";
}
@GET
- @Path("/jobs/{jobId}&responseId={responseId}")
- public String vfcGetQuery(@PathParam("jobId") String jobId, @PathParam("responseId") String responseId){
- return "{\"jobId\" : "+jobId+",\"responseDescriptor\" : {\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\": "+responseId+",\"responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"1\"}, {\"progress\" : \"41\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"2\"}]}}";
+ @Path("/jobs/{jobId}")
+ @Produces("application/json")
+ public String vfcGetQuery(@PathParam("jobId") String jobId) {
+ return "{\"jobId\" : "+jobId+",\"responseDescriptor\" : {\"progress\" : \"40\",\"status\" : \"finished\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\": 101 ,\"responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"1\"}, {\"progress\" : \"41\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"2\"}]}}";
}
}
+
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
index f5d42c9ce..121a889f7 100644
--- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
@@ -40,67 +40,74 @@ import org.onap.policy.aai.AAINQQueryParameters;
import org.onap.policy.aai.AAINQRequest;
import org.onap.policy.aai.AAINQResponse;
import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.utils.LoggerUtil;
public class AaiSimulatorTest {
- @BeforeClass
- public static void setUpSimulator() {
- try {
- Util.buildAaiSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
+ @BeforeClass
+ public static void setUpSimulator() {
+ LoggerUtil.setLevel("ROOT", "INFO");
+ LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
+ try {
+ Util.buildAaiSim();
+ } catch (final Exception e) {
+ fail(e.getMessage());
+ }
+ }
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- }
+ @AfterClass
+ public static void tearDownSimulator() {
+ HttpServletServer.factory.destroy();
+ }
- @Test
- public void testGet() {
- AAIGETVnfResponse response = AAIManager.getQueryByVnfID("http://localhost:6666/aai/v11/network/generic-vnfs/generic-vnf/", "testUser", "testPass", UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792");
- assertNotNull(response);
- assertNotNull(response.relationshipList);
- }
+ @Test
+ public void testGet() {
+ final AAIGETVnfResponse response = AAIManager.getQueryByVnfID(
+ "http://localhost:6666/aai/v11/network/generic-vnfs/generic-vnf/", "testUser", "testPass",
+ UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792");
+ assertNotNull(response);
+ assertNotNull(response.relationshipList);
+ }
- @Test
- public void testPost() {
- AAINQRequest request = new AAINQRequest();
- AAINQQueryParameters tempQueryParameters = new AAINQQueryParameters();
- AAINQNamedQuery tempNamedQuery = new AAINQNamedQuery();
- tempNamedQuery.namedQueryUUID = UUID.fromString("4ff56a54-9e3f-46b7-a337-07a1d3c6b469");
- tempQueryParameters.namedQuery = tempNamedQuery;
- request.queryParameters = 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.instanceFilter = tempInstanceFilter;
- request.instanceFilters = tempInstanceFilters;
-
- AAINQResponse response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass", request, UUID.randomUUID());
- assertNotNull(response);
- assertNotNull(response.inventoryResponseItems);
-
- tempNamedQuery.namedQueryUUID = UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087");
- tempQueryParameters.namedQuery = tempNamedQuery;
- request.queryParameters = 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.instanceFilter = tempInstanceFilter;
- request.instanceFilters = tempInstanceFilters;
-
- response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass", request, UUID.randomUUID());
- assertNotNull(response);
- assertNotNull(response.inventoryResponseItems);
- }
+ @Test
+ public void testPost() {
+ final AAINQRequest request = new AAINQRequest();
+ final AAINQQueryParameters tempQueryParameters = new AAINQQueryParameters();
+ final AAINQNamedQuery tempNamedQuery = new AAINQNamedQuery();
+ tempNamedQuery.namedQueryUUID = UUID.fromString("4ff56a54-9e3f-46b7-a337-07a1d3c6b469");
+ tempQueryParameters.namedQuery = tempNamedQuery;
+ request.queryParameters = 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.instanceFilter = tempInstanceFilter;
+ request.instanceFilters = tempInstanceFilters;
+
+ AAINQResponse response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass",
+ request, UUID.randomUUID());
+ assertNotNull(response);
+ assertNotNull(response.inventoryResponseItems);
+
+ tempNamedQuery.namedQueryUUID = UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087");
+ tempQueryParameters.namedQuery = tempNamedQuery;
+ request.queryParameters = 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.instanceFilter = tempInstanceFilter;
+ request.instanceFilters = tempInstanceFilters;
+
+ response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass", request,
+ UUID.randomUUID());
+ assertNotNull(response);
+ assertNotNull(response.inventoryResponseItems);
+ }
}
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java
new file mode 100644
index 000000000..41dc28875
--- /dev/null
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * simulators
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.onap.policy.simulators;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.utils.LoggerUtil;
+import org.onap.policy.guard.PolicyGuardXacmlHelper;
+import org.onap.policy.guard.PolicyGuardXacmlRequestAttributes;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+public class GuardSimulatorTest {
+
+ @BeforeClass
+ public static void setupSimulator() {
+ LoggerUtil.setLevel("ROOT", "INFO");
+ LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
+ try {
+ Util.buildGuardSim();
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+ HttpServletServer.factory.destroy();
+ }
+
+ @Test
+ public void testGuard() {
+ PolicyGuardXacmlRequestAttributes request = new PolicyGuardXacmlRequestAttributes("clname_id", "actor_id", "operation_id", "target_id", "request_id");
+ String xacmlResponse = PolicyGuardXacmlHelper.callPDP("http://localhost:6669/pdp/api/getDecision", request);
+ assertNotNull(xacmlResponse);
+ }
+}
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
index 2cf6b8e0c..683da86b7 100644
--- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,7 +20,8 @@
package org.onap.policy.simulators;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
import java.util.HashMap;
import java.util.UUID;
@@ -29,6 +30,9 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.utils.LoggerUtil;
+import org.onap.policy.rest.RESTManager;
+import org.onap.policy.rest.RESTManager.Pair;
import org.onap.policy.so.SOCloudConfiguration;
import org.onap.policy.so.SOModelInfo;
import org.onap.policy.so.SORelatedInstance;
@@ -39,95 +43,105 @@ import org.onap.policy.so.SORequestInfo;
import org.onap.policy.so.SORequestParameters;
import org.onap.policy.so.SOResponse;
import org.onap.policy.so.util.Serialization;
-import org.onap.policy.rest.RESTManager;
-import org.onap.policy.rest.RESTManager.Pair;
public class SoSimulatorTest {
-
- @BeforeClass
- public static void setUpSimulator() {
- try {
- Util.buildSoSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- }
-
- /**
- * Create dummy SO request for TestResponse() junit
- */
- private SORequest createTestRequest() {
-
- // Construct SO Request
- SORequest request = new SORequest();
- request.requestId = UUID.randomUUID();
- request.requestDetails = new SORequestDetails();
- request.requestDetails.modelInfo = new SOModelInfo();
- request.requestDetails.cloudConfiguration = new SOCloudConfiguration();
- request.requestDetails.requestInfo = new SORequestInfo();
- request.requestDetails.requestParameters = new SORequestParameters();
- request.requestDetails.requestParameters.userParams = null;
- //
- // cloudConfiguration
- //
- request.requestDetails.cloudConfiguration.lcpCloudRegionId = "DFW";
- request.requestDetails.cloudConfiguration.tenantId = "1015548";
- //
- // modelInfo
- //
- request.requestDetails.modelInfo.modelType = "vfModule";
- request.requestDetails.modelInfo.modelInvariantId = "f32568ec-2f1c-458a-864b-0593d53d141a";
- request.requestDetails.modelInfo.modelNameVersionId = "69615025-879d-4f0d-afe3-b7d1a7eeed1f";
- request.requestDetails.modelInfo.modelName = "C15ce9e1E9144c8fB8bb..dnsscaling..module-1";
- request.requestDetails.modelInfo.modelVersion = "1.0";
- //
- // requestInfo
- //
- request.requestDetails.requestInfo.instanceName = "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8";
- request.requestDetails.requestInfo.source = "POLICY";
- request.requestDetails.requestInfo.suppressRollback = false;
- //
- // relatedInstanceList
- //
- SORelatedInstanceListElement relatedInstanceListElement1 = new SORelatedInstanceListElement();
- SORelatedInstanceListElement relatedInstanceListElement2 = new SORelatedInstanceListElement();
- relatedInstanceListElement1.relatedInstance = new SORelatedInstance();
- relatedInstanceListElement2.relatedInstance = new SORelatedInstance();
- //
- relatedInstanceListElement1.relatedInstance.instanceId = "cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5";
- relatedInstanceListElement1.relatedInstance.modelInfo = new SOModelInfo();
- relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
- relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b";
- relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = "5c996219-b2e2-4c76-9b43-7e8672a33c1d";
- relatedInstanceListElement1.relatedInstance.modelInfo.modelName = "8330e932-2a23-4943-8606";
- relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = "1.0";
- //
- relatedInstanceListElement2.relatedInstance.instanceId = "594e2fe0-48b8-41ff-82e2-3d4bab69b192";
- relatedInstanceListElement2.relatedInstance.modelInfo = new SOModelInfo();
- relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
- relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = "033a32ed-aa65-4764-a736-36f2942f1aa0";
- relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = "d4d072dc-4e21-4a03-9524-628985819a8e";
- relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "c15ce9e1-e914-4c8f-b8bb";
- relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "1";
- relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = "c15ce9e1-e914-4c8f-b8bb 1";
- //
- request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
- request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
-
- return request;
- }
-
- @Test
- public void testResponse(){
- String request = Serialization.gsonPretty.toJson(createTestRequest());
- Pair<Integer, String> httpDetails = RESTManager.post("http://localhost:6667/serviceInstances/v2/12345/vnfs/12345/vfModulesHTTPS/1.1", "username", "password", new HashMap<>(), "application/json", request);
- assertNotNull(httpDetails);
- SOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, SOResponse.class);
- assertNotNull(response);
- }
+
+ @BeforeClass
+ public static void setUpSimulator() {
+ LoggerUtil.setLevel("ROOT", "INFO");
+ LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
+ try {
+ Util.buildSoSim();
+ } catch (final Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+ HttpServletServer.factory.destroy();
+ }
+
+ /**
+ * Create dummy SO request for TestResponse() junit
+ */
+ private SORequest createTestRequest() {
+
+ // Construct SO Request
+ final SORequest request = new SORequest();
+ request.requestId = UUID.randomUUID();
+ request.requestDetails = new SORequestDetails();
+ request.requestDetails.modelInfo = new SOModelInfo();
+ request.requestDetails.cloudConfiguration = new SOCloudConfiguration();
+ request.requestDetails.requestInfo = new SORequestInfo();
+ request.requestDetails.requestParameters = new SORequestParameters();
+ request.requestDetails.requestParameters.userParams = null;
+ //
+ // cloudConfiguration
+ //
+ request.requestDetails.cloudConfiguration.lcpCloudRegionId = "DFW";
+ request.requestDetails.cloudConfiguration.tenantId = "1015548";
+ //
+ // modelInfo
+ //
+ request.requestDetails.modelInfo.modelType = "vfModule";
+ request.requestDetails.modelInfo.modelInvariantId = "f32568ec-2f1c-458a-864b-0593d53d141a";
+ request.requestDetails.modelInfo.modelNameVersionId = "69615025-879d-4f0d-afe3-b7d1a7eeed1f";
+ request.requestDetails.modelInfo.modelName = "C15ce9e1E9144c8fB8bb..dnsscaling..module-1";
+ request.requestDetails.modelInfo.modelVersion = "1.0";
+ //
+ // requestInfo
+ //
+ request.requestDetails.requestInfo.instanceName =
+ "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8";
+ request.requestDetails.requestInfo.source = "POLICY";
+ request.requestDetails.requestInfo.suppressRollback = false;
+ //
+ // relatedInstanceList
+ //
+ final SORelatedInstanceListElement relatedInstanceListElement1 =
+ new SORelatedInstanceListElement();
+ final SORelatedInstanceListElement relatedInstanceListElement2 =
+ new SORelatedInstanceListElement();
+ relatedInstanceListElement1.relatedInstance = new SORelatedInstance();
+ relatedInstanceListElement2.relatedInstance = new SORelatedInstance();
+ //
+ relatedInstanceListElement1.relatedInstance.instanceId = "cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5";
+ relatedInstanceListElement1.relatedInstance.modelInfo = new SOModelInfo();
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId =
+ "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId =
+ "5c996219-b2e2-4c76-9b43-7e8672a33c1d";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelName = "8330e932-2a23-4943-8606";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = "1.0";
+ //
+ relatedInstanceListElement2.relatedInstance.instanceId = "594e2fe0-48b8-41ff-82e2-3d4bab69b192";
+ relatedInstanceListElement2.relatedInstance.modelInfo = new SOModelInfo();
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId =
+ "033a32ed-aa65-4764-a736-36f2942f1aa0";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId =
+ "d4d072dc-4e21-4a03-9524-628985819a8e";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "c15ce9e1-e914-4c8f-b8bb";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "1";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName =
+ "c15ce9e1-e914-4c8f-b8bb 1";
+ //
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
+
+ return request;
+ }
+
+ @Test
+ public void testResponse() {
+ final String request = Serialization.gsonPretty.toJson(this.createTestRequest());
+ final Pair<Integer, String> httpDetails = RESTManager.post(
+ "http://localhost:6667/serviceInstances/v2/12345/vnfs/12345/vfModulesHTTPS/1.1", "username",
+ "password", new HashMap<>(), "application/json", request);
+ assertNotNull(httpDetails);
+ final SOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, SOResponse.class);
+ assertNotNull(response);
+ }
}
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
index 0fb41ab9b..a063277ed 100644
--- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,6 +21,7 @@
package org.onap.policy.simulators;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.HashMap;
@@ -29,40 +30,50 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.utils.LoggerUtil;
import org.onap.policy.rest.RESTManager;
import org.onap.policy.rest.RESTManager.Pair;
import org.onap.policy.vfc.VFCResponse;
import org.onap.policy.vfc.util.Serialization;
public class VfcSimulatorTest {
-
- @BeforeClass
- public static void setUpSimulator() {
- try {
- Util.buildVfcSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- }
-
- @Test
- public void testPost(){
- Pair<Integer, String> httpDetails = RESTManager.post("http://localhost:6668/api/nslcm/v1/ns/1234567890/heal", "username", "password", new HashMap<String, String>(), "application/json", "Some Request Here");
- assertNotNull(httpDetails);
- VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
- assertNotNull(response);
- }
-
- @Test
- public void testGet(){
- Pair<Integer, String> httpDetails = RESTManager.get("http://localhost:6668/api/nslcm/v1/jobs/1234&responseId=5678", "username", "password", new HashMap<String, String>());
- assertNotNull(httpDetails);
- VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
- assertNotNull(response);
- }
+
+ @BeforeClass
+ public static void setUpSimulator() {
+ LoggerUtil.setLevel("ROOT", "INFO");
+ LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
+ try {
+ Util.buildVfcSim();
+ } catch (final Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+ HttpServletServer.factory.destroy();
+ }
+
+ @Test
+ public void testPost() {
+ final Pair<Integer, String> httpDetails =
+ RESTManager.post("http://localhost:6668/api/nslcm/v1/ns/1234567890/heal", "username",
+ "password", new HashMap<String, String>(), "application/json", "Some Request Here");
+ assertNotNull(httpDetails);
+ assertTrue(httpDetails.a == 202);
+ final VFCResponse response =
+ Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
+ assertNotNull(response);
+ }
+
+ @Test
+ public void testGet() {
+ final Pair<Integer, String> httpDetails =
+ RESTManager.get("http://localhost:6668/api/nslcm/v1/jobs/1234", "username", "password",
+ new HashMap<String, String>());
+ assertNotNull(httpDetails);
+ final VFCResponse response =
+ Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
+ assertNotNull(response);
+ }
}