diff options
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); + } +} |