diff options
author | Charles Cole <cc847m@att.com> | 2017-09-08 14:10:57 -0500 |
---|---|---|
committer | Charles Cole <cc847m@att.com> | 2017-09-11 13:09:17 -0500 |
commit | 8d338012d725cb16ebdbff0eb3ff7f47ad08f6d1 (patch) | |
tree | d6cb270df5d886f4b557d850c38ac1c3f5cba46d /controlloop/common/simulators/src/test | |
parent | 6f8b23793f90a3bc944f63be6f11a8f17f78220d (diff) |
Move the simulators to a new package
Moved the simulators to the simulators project in controlloop/common.
They can now be accessed with the Util class in the simulators project
or the Util class in template.demo, for backwards compatability. Also
renamed AaiSimulator to AaiSimulatorJaxRs
Issue-IS: POLICY-200
Change-Id: Id131af0243777db31a8f22e110d8a708dc033dcf
Signed-off-by: Charles Cole <cc847m@att.com>
Diffstat (limited to 'controlloop/common/simulators/src/test')
3 files changed, 195 insertions, 0 deletions
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 new file mode 100644 index 000000000..1b12b2527 --- /dev/null +++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java @@ -0,0 +1,66 @@ +/*- + * ============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.assertNotNull; +import static org.junit.Assert.fail; + +import java.util.UUID; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.aai.AAIGETResponse; +import org.onap.policy.aai.AAINQF199.AAINQF199Manager; +import org.onap.policy.aai.AAINQF199.AAINQF199Request; +import org.onap.policy.aai.AAINQF199.AAINQF199Response; +import org.onap.policy.drools.http.server.HttpServletServer; + +public class AaiSimulatorTest { + + @BeforeClass + public static void setUpSimulator() { + try { + Util.buildAaiSim(); + } catch (InterruptedException e) { + fail(e.getMessage()); + } + } + + @AfterClass + public static void tearDownSimulator() { + HttpServletServer.factory.destroy(); + } + + @Test + public void testGet() { + AAIGETResponse response = AAINQF199Manager.getQuery("http://localhost:6666", "testUser", "testPass", UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792"); + assertNotNull(response); + assertNotNull(response.relationshipList); + } + + @Test + public void testPost() { + AAINQF199Response response = AAINQF199Manager.postQuery("http://localhost:6666", "testUser", "testPass", new AAINQF199Request(), UUID.randomUUID()); + assertNotNull(response); + assertNotNull(response.inventoryResponseItems); + } +} 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 new file mode 100644 index 000000000..917288ed5 --- /dev/null +++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/MsoSimulatorTest.java @@ -0,0 +1,59 @@ +/*- + * ============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<Integer, String> httpDetails = RESTManager.post("http://localhost:6667/serviceInstances/v2/12345/vnfs/12345/vfModulesHTTPS/1.1", "username", "password", new HashMap<String, String>(), "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/VfcSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java new file mode 100644 index 000000000..5bfc4a018 --- /dev/null +++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java @@ -0,0 +1,70 @@ +/*- + * ============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.Ignore; +import org.junit.Test; +import org.onap.policy.drools.http.server.HttpServletServer; +import org.onap.policy.vfc.VFCResponse; +import org.onap.policy.vfc.util.Serialization; +import org.onap.policy.rest.RESTManager; +import org.onap.policy.rest.RESTManager.Pair; + +public class VfcSimulatorTest { + + @BeforeClass + public static void setUpSimulator() { + try { + Util.buildVfcSim(); + } catch (InterruptedException 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); + } + + //This test case fails because the model code does not match the response I was given, I do not know which is wrong + @Ignore + @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); + } +} |