From c5f38f5de2f49d3f2fa7f03808f9f063f1cb2ed9 Mon Sep 17 00:00:00 2001 From: "Hockla, Ali (ah999m)" Date: Wed, 13 Sep 2017 09:24:43 -0500 Subject: Added changes for vDNS Use Case -Renamed remaining MSO classes and packages to SO and modified drl accordingly -Connected SO Interface to SO Simulator -Added vDNS Control Loop junit -Modified SOActorServiceProvider to reflect AAI class changes (POLICY-103) Issue-ID: POLICY-102 Change-Id: Iea5d3f096c4ccfedde68e79d7593d66331127aaf Signed-off-by: Hockla, Ali (ah999m) --- controlloop/common/simulators/pom.xml | 9 +- .../onap/policy/simulators/MsoSimulatorJaxRs.java | 37 ------ .../onap/policy/simulators/SoSimulatorJaxRs.java | 44 +++++++ .../main/java/org/onap/policy/simulators/Util.java | 6 +- .../onap/policy/simulators/MsoSimulatorTest.java | 59 --------- .../onap/policy/simulators/SoSimulatorTest.java | 133 +++++++++++++++++++++ 6 files changed, 188 insertions(+), 100 deletions(-) delete mode 100644 controlloop/common/simulators/src/main/java/org/onap/policy/simulators/MsoSimulatorJaxRs.java create mode 100644 controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java delete mode 100644 controlloop/common/simulators/src/test/java/org/onap/policy/simulators/MsoSimulatorTest.java create mode 100644 controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java (limited to 'controlloop/common/simulators') diff --git a/controlloop/common/simulators/pom.xml b/controlloop/common/simulators/pom.xml index 9d3b71c0d..26a81a8ff 100644 --- a/controlloop/common/simulators/pom.xml +++ b/controlloop/common/simulators/pom.xml @@ -47,10 +47,17 @@ org.onap.policy.drools-applications - mso + so ${project.version} test + + org.onap.policy.drools-applications + so + 1.1.0-SNAPSHOT + provided + + org.onap.policy.drools-applications vfc diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/MsoSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/MsoSimulatorJaxRs.java deleted file mode 100644 index 824c547ce..000000000 --- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/MsoSimulatorJaxRs.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============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.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; - -@Path("/serviceInstances") -public class MsoSimulatorJaxRs { - - @POST - @Path("/v2/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModulesHTTPS/1.1") - public String msoPostQuery(@PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId) - { - return "{\"requestReferences\": {\"instanceId\": \"ff305d54-75b4-ff1b-bdb2-eb6b9e5460ff\", \"requestId\": \"rq1234d1-5a33-ffdf-23ab-12abad84e331\"}}"; - } - -} 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 new file mode 100644 index 000000000..1ebb281fd --- /dev/null +++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java @@ -0,0 +1,44 @@ +/*- + * ============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.PathParam; +import javax.ws.rs.core.MediaType; + +import org.onap.policy.so.SORequest; +import org.onap.policy.so.util.Serialization; + +@Path("/serviceInstances") +public class SoSimulatorJaxRs { + + @POST + @Path("/v2/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModulesHTTPS/1.1") + @Consumes(MediaType.APPLICATION_JSON) + public String SoPostQuery(@PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, String req) + { + SORequest request = Serialization.gsonPretty.fromJson(req, SORequest.class); + return "{\"requestReferences\": {\"instanceId\": \"ff305d54-75b4-ff1b-bdb2-eb6b9e5460ff\", \"requestId\": " + request.requestId + "}}"; + } + +} 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 27cc6e0fa..e0eb1ff01 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 @@ -22,7 +22,7 @@ package org.onap.policy.simulators; import org.onap.policy.drools.http.server.HttpServletServer; import org.onap.policy.simulators.AaiSimulatorJaxRs; -import org.onap.policy.simulators.MsoSimulatorJaxRs; +import org.onap.policy.simulators.SoSimulatorJaxRs; import org.onap.policy.simulators.VfcSimulatorJaxRs; public class Util { @@ -33,9 +33,9 @@ public class Util { return testServer; } - public static HttpServletServer buildMsoSim() throws InterruptedException { + public static HttpServletServer buildSoSim() throws InterruptedException { HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6667, "/", false, true); - testServer.addServletClass("/*", MsoSimulatorJaxRs.class.getName()); + testServer.addServletClass("/*", SoSimulatorJaxRs.class.getName()); testServer.waitedStart(5000); return testServer; } diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/MsoSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/MsoSimulatorTest.java deleted file mode 100644 index 917288ed5..000000000 --- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/MsoSimulatorTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============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 static org.junit.Assert.*; - -import java.util.HashMap; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.drools.http.server.HttpServletServer; -import org.onap.policy.mso.SOResponse; -import org.onap.policy.mso.util.Serialization; -import org.onap.policy.rest.RESTManager; -import org.onap.policy.rest.RESTManager.Pair; - -public class MsoSimulatorTest { - - @BeforeClass - public static void setUpSimulator() { - try { - Util.buildMsoSim(); - } catch (InterruptedException e) { - fail(e.getMessage()); - } - } - - @AfterClass - public static void tearDownSimulator() { - HttpServletServer.factory.destroy(); - } - - @Test - public void testResponse(){ - Pair httpDetails = RESTManager.post("http://localhost:6667/serviceInstances/v2/12345/vnfs/12345/vfModulesHTTPS/1.1", "username", "password", new HashMap(), "application/json", "Some Request Here"); - assertNotNull(httpDetails); - SOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, SOResponse.class); - assertNotNull(response); - } -} 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 new file mode 100644 index 000000000..0a7cd4168 --- /dev/null +++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java @@ -0,0 +1,133 @@ +/*- + * ============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 static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.UUID; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.drools.http.server.HttpServletServer; +import org.onap.policy.so.SOCloudConfiguration; +import org.onap.policy.so.SOModelInfo; +import org.onap.policy.so.SORelatedInstance; +import org.onap.policy.so.SORelatedInstanceListElement; +import org.onap.policy.so.SORequest; +import org.onap.policy.so.SORequestDetails; +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 (InterruptedException 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 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); + } +} -- cgit 1.2.3-korg