From fe4cd8e4c08a19ac543ca93c577b8b3a12a1524f Mon Sep 17 00:00:00 2001 From: Liam Fallon Date: Thu, 14 Dec 2017 07:40:18 -0800 Subject: 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 Issue-ID: POLICY-455 Signed-off-by: Liam Fallon --- .../actor/appclcm/AppcLcmActorServiceProvider.java | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'controlloop/common/actors/actor.appclcm/src') diff --git a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java index 936dd0243..0f4a00423 100644 --- a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java +++ b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java @@ -51,6 +51,7 @@ import org.onap.policy.controlloop.actorServiceProvider.spi.Actor; import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.drools.system.PolicyEngine; +import org.onap.policy.rest.RESTManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -110,15 +111,15 @@ public class AppcLcmActorServiceProvider implements Actor { private static String parseAAIResponse(List items, String resourceId) { String vnfId = null; for (AAINQInventoryResponseItem item: items) { - if ((item.genericVNF != null) - && (item.genericVNF.modelInvariantId != null) - && (resourceId.equals(item.genericVNF.modelInvariantId))) { - vnfId = item.genericVNF.vnfID; + if ((item.getGenericVNF() != null) + && (item.getGenericVNF().getModelInvariantId() != null) + && (resourceId.equals(item.getGenericVNF().getModelInvariantId()))) { + vnfId = item.getGenericVNF().getVnfID(); break; } else { - if((item.items != null) && (item.items.getInventoryResponseItems() != null)) { - vnfId = parseAAIResponse(item.items.getInventoryResponseItems(), resourceId); + if((item.getItems() != null) && (item.getItems().getInventoryResponseItems() != null)) { + vnfId = parseAAIResponse(item.getItems().getInventoryResponseItems(), resourceId); } } } @@ -144,9 +145,9 @@ public class AppcLcmActorServiceProvider implements Actor { UUID requestId = UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087"); AAINQRequest aaiRequest = new AAINQRequest(); - aaiRequest.queryParameters = new AAINQQueryParameters(); - aaiRequest.queryParameters.namedQuery = new AAINQNamedQuery(); - aaiRequest.queryParameters.namedQuery.namedQueryUUID = requestId; + aaiRequest.setQueryParameters(new AAINQQueryParameters()); + aaiRequest.getQueryParameters().setNamedQuery(new AAINQNamedQuery()); + aaiRequest.getQueryParameters().getNamedQuery().setNamedQueryUUID(requestId); Map> filter = new HashMap<>(); Map filterItem = new HashMap<>(); @@ -154,8 +155,8 @@ public class AppcLcmActorServiceProvider implements Actor { filterItem.put("vnf-id", sourceVnfId); filter.put("generic-vnf", filterItem); - aaiRequest.instanceFilters = new AAINQInstanceFilters(); - aaiRequest.instanceFilters.getInstanceFilter().add(filter); + aaiRequest.setInstanceFilters(new AAINQInstanceFilters()); + aaiRequest.getInstanceFilters().getInstanceFilter().add(filter); /* * Obtain A&AI credentials from properties.environment file @@ -165,7 +166,7 @@ public class AppcLcmActorServiceProvider implements Actor { String aaiUsername = PolicyEngine.manager.getEnvironmentProperty("aai.username"); String aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password"); - AAINQResponse aaiResponse = AAIManager.postQuery( + AAINQResponse aaiResponse = new AAIManager(new RESTManager()).postQuery( aaiUrl, aaiUsername, aaiPassword, aaiRequest, requestId); -- cgit 1.2.3-korg