diff options
author | Liam Fallon <liam.fallon@ericsson.com> | 2017-12-14 07:40:18 -0800 |
---|---|---|
committer | Liam Fallon <liam.fallon@ericsson.com> | 2017-12-14 20:07:40 -0800 |
commit | fe4cd8e4c08a19ac543ca93c577b8b3a12a1524f (patch) | |
tree | 263a3c0dc2ad9504c6a891f6c5b9d025b0fa74b7 /controlloop/common/simulators/src/test/java | |
parent | 5cfd3b7066e6a6305e140fa59b1fccb8e3c5f81b (diff) |
Cleanup of A&AI message model module.
Fields have been made fields private in POJOs, and wrote JUnit unit tests to bring up code coverage. AAIManager also changed to use non-static methods so that it can be stubbed with Mockito.
Change-Id: I871427ced5db8a1dfd6495fef4e6d84adf264e65
Signed-off-by: Liam Fallon <liam.fallon@ericsson.com>
Issue-ID: POLICY-455
Signed-off-by: Liam Fallon <liam.fallon@ericsson.com>
Diffstat (limited to 'controlloop/common/simulators/src/test/java')
4 files changed, 18 insertions, 17 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 index 66c65ff82..86168e899 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 @@ -41,6 +41,7 @@ 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; +import org.onap.policy.rest.RESTManager; public class AaiSimulatorTest { @@ -62,11 +63,11 @@ public class AaiSimulatorTest { @Test public void testGet() { - final AAIGETVnfResponse response = AAIManager.getQueryByVnfID( + 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.relationshipList); + assertNotNull(response.getRelationshipList()); } @Test @@ -74,9 +75,9 @@ public class AaiSimulatorTest { 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; + 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<>(); @@ -85,16 +86,16 @@ public class AaiSimulatorTest { tempInstanceFilter.add(tempOuterMap); AAINQInstanceFilters tempInstanceFilters = new AAINQInstanceFilters(); tempInstanceFilters.setInstanceFilter(tempInstanceFilter); - request.instanceFilters = tempInstanceFilters; + request.setInstanceFilters(tempInstanceFilters); - AAINQResponse response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass", + AAINQResponse response = new AAIManager(new RESTManager()).postQuery("http://localhost:6666", "testUser", "testPass", request, UUID.randomUUID()); assertNotNull(response); assertNotNull(response.getInventoryResponseItems()); - tempNamedQuery.namedQueryUUID = UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087"); - tempQueryParameters.namedQuery = tempNamedQuery; - request.queryParameters = tempQueryParameters; + 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<>(); @@ -103,9 +104,9 @@ public class AaiSimulatorTest { tempInstanceFilter.add(tempOuterMap); tempInstanceFilters = new AAINQInstanceFilters(); tempInstanceFilters.setInstanceFilter(tempInstanceFilter); - request.instanceFilters = tempInstanceFilters; + request.setInstanceFilters(tempInstanceFilters); - response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass", request, + response = new AAIManager(new RESTManager()).postQuery("http://localhost:6666", "testUser", "testPass", request, UUID.randomUUID()); assertNotNull(response); assertNotNull(response.getInventoryResponseItems()); 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 index 86e2c8cf9..ea13ec445 100644 --- 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 @@ -54,14 +54,14 @@ public class GuardSimulatorTest { public void testGuard() { String request = makeRequest("test_actor_id", "test_op_id", "test_target", "test_clName"); String url = "http://localhost:" + Util.GUARDSIM_SERVER_PORT + "/pdp/api/getDecision"; - Pair<Integer, String> response = RESTManager.post(url, "testUname", "testPass", null, "application/json", request); + Pair<Integer, String> response = new RESTManager().post(url, "testUname", "testPass", null, "application/json", request); assertNotNull(response); assertNotNull(response.a); assertNotNull(response.b); assertEquals("{\"decision\": \"PERMIT\", \"details\": \"Decision Permit. OK!\"}", response.b); request = makeRequest("test_actor_id", "test_op_id", "test_target", "denyGuard"); - response = RESTManager.post(url, "testUname", "testPass", null, "application/json", request); + response = new RESTManager().post(url, "testUname", "testPass", null, "application/json", request); assertNotNull(response); assertNotNull(response.a); assertNotNull(response.b); 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 3aaf1dc55..8054d214a 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 @@ -138,7 +138,7 @@ public class SoSimulatorTest { @Test public void testResponse() { final String request = Serialization.gsonPretty.toJson(this.createTestRequest()); - final Pair<Integer, String> httpDetails = RESTManager.post( + final Pair<Integer, String> httpDetails = new RESTManager().post( "http://localhost:6667/serviceInstances/v5/12345/vnfs/12345/vfModules", "username", "password", new HashMap<>(), "application/json", request); assertNotNull(httpDetails); 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 a063277ed..4c29331bf 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 @@ -57,7 +57,7 @@ public class VfcSimulatorTest { @Test public void testPost() { final Pair<Integer, String> httpDetails = - RESTManager.post("http://localhost:6668/api/nslcm/v1/ns/1234567890/heal", "username", + new 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); @@ -69,7 +69,7 @@ public class VfcSimulatorTest { @Test public void testGet() { final Pair<Integer, String> httpDetails = - RESTManager.get("http://localhost:6668/api/nslcm/v1/jobs/1234", "username", "password", + new RESTManager().get("http://localhost:6668/api/nslcm/v1/jobs/1234", "username", "password", new HashMap<String, String>()); assertNotNull(httpDetails); final VFCResponse response = |