From c3619a82215b2277087f73741d57d3a3b75325f6 Mon Sep 17 00:00:00 2001 From: Liam Fallon Date: Wed, 6 Dec 2017 23:06:31 +0100 Subject: Technical Debt in AAI. Eliminate the technical debt identified in the drools-applications/controlloop/common/model-impl/aai module by Sonar Change-Id: I72125baacc217386a4984be04bfc023439eddd13 Signed-off-by: Liam Fallon Issue-ID: POLICY-455 Signed-off-by: Liam Fallon --- .../actor/appclcm/AppcLcmActorServiceProvider.java | 8 +- .../actor/so/SOActorServiceProvider.java | 46 +- .../eventmanager/ControlLoopEventManagerTest.java | 30 +- .../java/org/onap/policy/aai/AAIGETResponse.java | 4 - .../org/onap/policy/aai/AAIGETVnfResponse.java | 4 - .../org/onap/policy/aai/AAIGETVserverResponse.java | 4 - .../main/java/org/onap/policy/aai/AAIManager.java | 174 ++-- .../java/org/onap/policy/aai/AAINQCloudRegion.java | 3 - .../org/onap/policy/aai/AAINQExtraProperties.java | 12 +- .../java/org/onap/policy/aai/AAINQGenericVNF.java | 4 - .../org/onap/policy/aai/AAINQInstanceFilters.java | 10 +- .../policy/aai/AAINQInventoryResponseItem.java | 4 - .../policy/aai/AAINQInventoryResponseItems.java | 10 +- .../java/org/onap/policy/aai/AAINQNamedQuery.java | 4 - .../org/onap/policy/aai/AAINQQueryParameters.java | 4 - .../java/org/onap/policy/aai/AAINQRequest.java | 4 - .../java/org/onap/policy/aai/AAINQResponse.java | 18 +- .../org/onap/policy/aai/AAINQResponseWrapper.java | 21 +- .../org/onap/policy/aai/AAINQServiceInstance.java | 4 - .../main/java/org/onap/policy/aai/AAINQTenant.java | 3 - .../java/org/onap/policy/aai/AAINQVServer.java | 4 - .../java/org/onap/policy/aai/AAINQVfModule.java | 3 - .../aai/src/main/java/org/onap/policy/aai/PNF.java | 41 +- .../main/java/org/onap/policy/aai/PNFInstance.java | 83 +- .../org/onap/policy/aai/RelatedToProperty.java | 8 +- .../org/onap/policy/aai/RelatedToPropertyItem.java | 4 - .../java/org/onap/policy/aai/Relationship.java | 3 - .../java/org/onap/policy/aai/RelationshipData.java | 11 +- .../org/onap/policy/aai/RelationshipDataItem.java | 4 - .../java/org/onap/policy/aai/RelationshipItem.java | 10 +- .../java/org/onap/policy/aai/RelationshipList.java | 10 +- .../org/onap/policy/aai/AAIGETVnfResponseTest.java | 10 +- .../onap/policy/aai/AAIGETVserverResponseTest.java | 10 +- .../onap/policy/aai/AAINQExtraPropertiesTest.java | 10 +- .../policy/aai/AAINQInventoryResponseItemTest.java | 36 +- .../aai/AAINQInventoryResponseItemsTest.java | 50 +- .../org/onap/policy/aai/AAINQResponseTest.java | 50 +- .../onap/policy/aai/AAINQResponseWrapperTest.java | 54 +- .../java/org/onap/policy/aai/PNFInstanceTest.java | 6 +- .../src/test/java/org/onap/policy/aai/PNFTest.java | 4 +- .../org/onap/policy/aai/RelatedToPropertyTest.java | 4 +- .../org/onap/policy/aai/RelationshipDataTest.java | 4 +- .../org/onap/policy/aai/RelationshipItemTest.java | 2 +- .../org/onap/policy/aai/RelationshipListTest.java | 8 +- .../java/org/onap/policy/aai/RelationshipTest.java | 6 +- .../builder/impl/ControlLoopPolicyBuilderImpl.java | 936 ++++++++++----------- .../onap/policy/simulators/AaiSimulatorJaxRs.java | 6 +- .../onap/policy/simulators/AaiSimulatorTest.java | 8 +- 48 files changed, 890 insertions(+), 866 deletions(-) (limited to 'controlloop/common') 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 ed59aafc5..936dd0243 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 @@ -117,8 +117,8 @@ public class AppcLcmActorServiceProvider implements Actor { break; } else { - if((item.items != null) && (item.items.inventoryResponseItems != null)) { - vnfId = parseAAIResponse(item.items.inventoryResponseItems, resourceId); + if((item.items != null) && (item.items.getInventoryResponseItems() != null)) { + vnfId = parseAAIResponse(item.items.getInventoryResponseItems(), resourceId); } } } @@ -155,7 +155,7 @@ public class AppcLcmActorServiceProvider implements Actor { filter.put("generic-vnf", filterItem); aaiRequest.instanceFilters = new AAINQInstanceFilters(); - aaiRequest.instanceFilters.instanceFilter.add(filter); + aaiRequest.instanceFilters.getInstanceFilter().add(filter); /* * Obtain A&AI credentials from properties.environment file @@ -174,7 +174,7 @@ public class AppcLcmActorServiceProvider implements Actor { throw new AAIException("The named query response was null"); } - String targetVnfId = parseAAIResponse(aaiResponse.inventoryResponseItems, resourceId); + String targetVnfId = parseAAIResponse(aaiResponse.getInventoryResponseItems(), resourceId); if (targetVnfId == null) { throw new AAIException("Target vnf-id could not be found"); } diff --git a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java index 72119f639..de9c58500 100644 --- a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java +++ b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java @@ -159,7 +159,7 @@ public class SOActorServiceProvider implements Actor { Map aainqinstancefiltermapitem = new HashMap<>(); aainqinstancefiltermapitem.put("vserver-name", onset.AAI.get("vserver.vserver-name")); // TO DO: get vserver.vname from dcae onset.AAI.get("vserver.vserver-name") aainqinstancefiltermap.put("vserver", aainqinstancefiltermapitem); - aainqinstancefilter.instanceFilter.add(aainqinstancefiltermap); + aainqinstancefilter.getInstanceFilter().add(aainqinstancefiltermap); aainqrequest.instanceFilters = aainqinstancefilter; // // print aainqrequest for debug @@ -202,7 +202,7 @@ public class SOActorServiceProvider implements Actor { if (logger.isDebugEnabled()) { logger.debug("AAI Named Query Response: "); - logger.debug(Serialization.gsonPretty.toJson(aainqResponseWrapper.aainqresponse)); + logger.debug(Serialization.gsonPretty.toJson(aainqResponseWrapper.getAainqresponse())); } extractSOFieldsFromNamedQuery(aainqResponseWrapper, onset); @@ -220,27 +220,27 @@ public class SOActorServiceProvider implements Actor { try { // vnfItem - setVnfItemVnfId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID); - setVnfItemVnfType(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType); + setVnfItemVnfId(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).genericVNF.vnfID); + setVnfItemVnfType(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).genericVNF.vnfType); setVnfItemVnfType(vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf("/")+1)); - setVnfItemModelInvariantId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.modelInvariantId); - setVnfItemModelVersionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.modelVersionId); - setVnfItemModelName(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue); - setVnfItemModelNameVersionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue); - setVnfItemModelVersion(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue); + setVnfItemModelInvariantId(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).genericVNF.modelInvariantId); + setVnfItemModelVersionId(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).genericVNF.modelVersionId); + setVnfItemModelName(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).extraProperties.getExtraProperty().get(1).propertyValue); + setVnfItemModelNameVersionId(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).extraProperties.getExtraProperty().get(0).propertyValue); + setVnfItemModelVersion(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).extraProperties.getExtraProperty().get(4).propertyValue); // serviceItem - setServiceItemServiceInstanceId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID); - setServiceItemModelInvariantId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.modelInvariantId); - setServiceItemModelName(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue); - setServiceItemModelType(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue); - setServiceItemModelNameVersionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.modelVersionId); - setServiceItemModelVersion(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue); + setServiceItemServiceInstanceId(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).serviceInstance.serviceInstanceID); + setServiceItemModelInvariantId(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).serviceInstance.modelInvariantId); + setServiceItemModelName(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).extraProperties.getExtraProperty().get(1).propertyValue); + setServiceItemModelType(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).extraProperties.getExtraProperty().get(1).propertyValue); + setServiceItemModelNameVersionId(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).serviceInstance.modelVersionId); + setServiceItemModelVersion(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).extraProperties.getExtraProperty().get(4).propertyValue); // Find the index for base vf module and non-base vf module int baseIndex = -1; int nonBaseIndex = -1; - List inventoryItems = namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems; + List inventoryItems = namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).items.getInventoryResponseItems(); for (AAINQInventoryResponseItem m : inventoryItems) { if (m.vfModule != null) { if (m.vfModule.isBaseVfModule) { @@ -262,20 +262,20 @@ public class SOActorServiceProvider implements Actor { } // This comes from the base module - setVfModuleItemVfModuleName(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).vfModule.vfModuleName); + setVfModuleItemVfModuleName(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(baseIndex).vfModule.vfModuleName); setVfModuleItemVfModuleName(vfModuleItemVfModuleName.replace("Vfmodule", "vDNS")); // vfModuleItem - NOT the base module - setVfModuleItemModelInvariantId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.modelInvariantId); - setVfModuleItemModelNameVersionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.modelVersionId); - setVfModuleItemModelName(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(1).propertyValue); - setVfModuleItemModelVersionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(4).propertyValue); + setVfModuleItemModelInvariantId(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(nonBaseIndex).vfModule.modelInvariantId); + setVfModuleItemModelNameVersionId(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(nonBaseIndex).vfModule.modelVersionId); + setVfModuleItemModelName(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(nonBaseIndex).extraProperties.getExtraProperty().get(1).propertyValue); + setVfModuleItemModelVersionId(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(nonBaseIndex).extraProperties.getExtraProperty().get(4).propertyValue); // tenantItem - setTenantItemTenantId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId); + setTenantItemTenantId(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(1).tenant.tenantId); // cloudRegionItem - setCloudRegionItemCloudRegionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId); + setCloudRegionItemCloudRegionId(namedQueryResponseWrapper.getAainqresponse().getInventoryResponseItems().get(0).items.getInventoryResponseItems().get(1).items.getInventoryResponseItems().get(0).cloudRegion.cloudRegionId); } catch (Exception e) { logger.warn("Problem extracting SO data from AAI query response because of {}", e.getMessage(), e); diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java index be0eb2bc3..99a4c926d 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java @@ -288,28 +288,28 @@ public class ControlLoopEventManagerTest { relationshipDataItem.relationshipKey = "customer.global-customer-id"; relationshipDataItem.relationshipValue = "MSO_1610_ST"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); relationshipDataItem.relationshipKey = "service-subscription.service-type"; relationshipDataItem.relationshipValue = "MSO-dev-service-type"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); relationshipDataItem.relationshipKey = "service-instance.service-instance-id"; relationshipDataItem.relationshipValue = "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); RelatedToProperty relatedToProperty = new RelatedToProperty(); RelatedToPropertyItem item = new RelatedToPropertyItem(); item.propertyKey = "service-instance.service-instance-name"; item.propertyValue = "lll_svc_010317"; - relatedToProperty.relatedTo.add(item); + relatedToProperty.getRelatedTo().add(item); relationship.relatedTo = "service-instance"; relationship.relatedLink = "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; relationship.relationshipData = relationshipData; relationship.relatedToProperty = relatedToProperty; - relationshipList.relationshipList.add(relationship); + relationshipList.getRelationshipList().add(relationship); response.relationshipList = relationshipList; return response; @@ -335,28 +335,28 @@ public class ControlLoopEventManagerTest { relationshipDataItem.relationshipKey = "customer.global-customer-id"; relationshipDataItem.relationshipValue = "MSO_1610_ST"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); relationshipDataItem.relationshipKey = "service-subscription.service-type"; relationshipDataItem.relationshipValue = "MSO-dev-service-type"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); relationshipDataItem.relationshipKey = "service-instance.service-instance-id"; relationshipDataItem.relationshipValue = "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); RelatedToProperty relatedToProperty = new RelatedToProperty(); RelatedToPropertyItem item = new RelatedToPropertyItem(); item.propertyKey = "service-instance.service-instance-name"; item.propertyValue = "lll_svc_010317"; - relatedToProperty.relatedTo.add(item); + relatedToProperty.getRelatedTo().add(item); relationship.relatedTo = "service-instance"; relationship.relatedLink = "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; relationship.relationshipData = relationshipData; relationship.relatedToProperty = relatedToProperty; - relationshipList.relationshipList.add(relationship); + relationshipList.getRelationshipList().add(relationship); response.relationshipList = relationshipList; return response; @@ -380,28 +380,28 @@ public class ControlLoopEventManagerTest { relationshipDataItem.relationshipKey = "customer.global-customer-id"; relationshipDataItem.relationshipValue = "MSO_1610_ST"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); relationshipDataItem.relationshipKey = "service-subscription.service-type"; relationshipDataItem.relationshipValue = "MSO-dev-service-type"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); relationshipDataItem.relationshipKey = "service-instance.service-instance-id"; relationshipDataItem.relationshipValue = "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); RelatedToProperty relatedToProperty = new RelatedToProperty(); RelatedToPropertyItem item = new RelatedToPropertyItem(); item.propertyKey = "service-instance.service-instance-name"; item.propertyValue = "lll_svc_010317"; - relatedToProperty.relatedTo.add(item); + relatedToProperty.getRelatedTo().add(item); relationship.relatedTo = "service-instance"; relationship.relatedLink = "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; relationship.relationshipData = relationshipData; relationship.relatedToProperty = relatedToProperty; - relationshipList.relationshipList.add(relationship); + relationshipList.getRelationshipList().add(relationship); response.relationshipList = relationshipList; return response; diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponse.java index caba0596f..ac6e38deb 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponse.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponse.java @@ -48,8 +48,4 @@ public class AAIGETResponse implements Serializable { @SerializedName("requestError") public AAINQRequestError requestError; - - public AAIGETResponse() { - } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVnfResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVnfResponse.java index a95502cca..c89083b18 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVnfResponse.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVnfResponse.java @@ -45,8 +45,4 @@ public class AAIGETVnfResponse extends AAIGETResponse implements Serializable { @SerializedName("orchestration-status") public String orchestrationStatus; - - public AAIGETVnfResponse() { - } - } \ No newline at end of file diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVserverResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVserverResponse.java index 527bbe528..162df0d93 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVserverResponse.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVserverResponse.java @@ -42,8 +42,4 @@ public class AAIGETVserverResponse extends AAIGETResponse implements Serializabl @SerializedName("vserver-selflink") public String vserverSelflink; - - public AAIGETVserverResponse() { - } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIManager.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIManager.java index c92ea775b..621398282 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIManager.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIManager.java @@ -33,117 +33,109 @@ import org.slf4j.LoggerFactory; import com.google.gson.JsonSyntaxException; public final class AAIManager { + private static final String LINE_SEPARATOR = System.lineSeparator(); + + /** + * Private constructor added to avoid instantiation of static class + */ + private AAIManager() { + } + private static final Logger logger = LoggerFactory.getLogger(AAIManager.class); private static final Logger netLogger = LoggerFactory.getLogger(org.onap.policy.drools.event.comm.Topic.NETWORK_LOGGER); - + public static AAINQResponse postQuery(String url, String username, String password, AAINQRequest request, UUID requestID) { - - Map headers = new HashMap<>(); - headers.put("X-FromAppId", "POLICY"); - headers.put("X-TransactionId", requestID.toString()); - headers.put("Accept", "application/json"); - + + Map headers = createHeaders(requestID); + url = url + "/aai/search/named-query"; logger.debug("RESTManager.post before"); String requestJson = Serialization.gsonPretty.toJson(request); - netLogger.info("[OUT|{}|{}|]{}{}", "AAI", url, System.lineSeparator(), requestJson); + netLogger.info("[OUT|{}|{}|]{}{}", "AAI", url, LINE_SEPARATOR, requestJson); Pair httpDetails = RESTManager.post(url, username, password, headers, "application/json", requestJson); logger.debug("RESTManager.post after"); - + if (httpDetails == null) { - logger.info("AAI POST Null Response to " + url); + logger.info("AAI POST Null Response to {}", url); return null; } + + int httpResponseCode = httpDetails.a; logger.info(url); - logger.info(httpDetails.a.toString()); + logger.info("{}", httpResponseCode); logger.info(httpDetails.b); + if (httpDetails.b != null) { - try { - AAINQResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, AAINQResponse.class); - netLogger.info("[IN|{}|{}|]{}{}", "AAI", url, System.lineSeparator(), httpDetails.b); - return response; - } catch (JsonSyntaxException e) { - logger.error("postQuery threw: ", e); - } + return composeResponse(httpDetails, url, AAINQResponse.class); } return null; } - + public static AAIGETVserverResponse getQueryByVserverName(String urlGet, String username, String password, UUID requestID, String key) { - - Map headers = new HashMap<>(); - headers.put("X-FromAppId", "POLICY"); - headers.put("X-TransactionId", requestID.toString()); - headers.put("Accept", "application/json"); - + + Map headers = createHeaders(requestID); + urlGet = urlGet + key; - + int attemptsLeft = 3; - AAIGETVserverResponse responseGet = null; - + while(attemptsLeft-- > 0){ netLogger.info("[OUT|{}|{}|]", "AAI", urlGet); Pair httpDetailsGet = RESTManager.get(urlGet, username, password, headers); if (httpDetailsGet == null) { - logger.info("AAI GET Null Response to " + urlGet); + logger.info("AAI GET Null Response to {}", urlGet); return null; } + + int httpResponseCode = httpDetailsGet.a; logger.info(urlGet); - logger.info(httpDetailsGet.a.toString()); + logger.info("{}", httpResponseCode); logger.info(httpDetailsGet.b); - - if (httpDetailsGet.a == 200) { - try { - responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, AAIGETVserverResponse.class); - netLogger.info("[IN|{}|{}|]{}{}", "AAI", urlGet, System.lineSeparator(), httpDetailsGet.b); + + if (httpResponseCode == 200) { + AAIGETVserverResponse responseGet = composeResponse(httpDetailsGet, urlGet, AAIGETVserverResponse.class); + if (responseGet != null) { return responseGet; - } catch (JsonSyntaxException e) { - logger.error("postQuery threw: ", e); } } try { Thread.sleep(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } - } - + } + return null; } - + public static AAIGETVnfResponse getQueryByVnfID(String urlGet, String username, String password, UUID requestID, String key) { - - Map headers = new HashMap<>(); - headers.put("X-FromAppId", "POLICY"); - headers.put("X-TransactionId", requestID.toString()); - headers.put("Accept", "application/json"); - + + Map headers = createHeaders(requestID); + urlGet = urlGet + key; - + int attemptsLeft = 3; - AAIGETVnfResponse responseGet = null; - + while(attemptsLeft-- > 0){ netLogger.info("[OUT|{}|{}|]", "AAI", urlGet); Pair httpDetailsGet = RESTManager.get(urlGet, username, password, headers); if (httpDetailsGet == null) { - logger.info("AAI GET Null Response to " + urlGet); + logger.info("AAI GET Null Response to {}", urlGet); return null; } + + int httpResponseCode = httpDetailsGet.a; logger.info(urlGet); - logger.info(httpDetailsGet.a.toString()); + logger.info("{}", httpResponseCode); logger.info(httpDetailsGet.b); - - if (httpDetailsGet.a == 200) { - try { - responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, AAIGETVnfResponse.class); - netLogger.info("[IN|{}|{}|]{}{}", "AAI", urlGet, System.lineSeparator(), httpDetailsGet.b); + + if (httpResponseCode == 200) { + AAIGETVnfResponse responseGet = composeResponse(httpDetailsGet, urlGet, AAIGETVnfResponse.class); + if (responseGet != null) { return responseGet; - } catch (JsonSyntaxException e) { - logger.error("postQuery threw: ", e); } } try { @@ -151,49 +143,45 @@ public final class AAIManager { } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } - + return null; } - + public static AAIGETVnfResponse getQueryByVnfName(String urlGet, String username, String password, UUID requestID, String key) { - + return getQueryByVnfID(urlGet, username, password, requestID, key); + } + + /** + * Create the headers for the HTTP request + * @param requestID the request ID to insert in the headers + * @return the HTTP headers + */ + private static Map createHeaders(final UUID requestID) { Map headers = new HashMap<>(); + headers.put("X-FromAppId", "POLICY"); headers.put("X-TransactionId", requestID.toString()); headers.put("Accept", "application/json"); - - urlGet = urlGet + key; - - int attemptsLeft = 3; - AAIGETVnfResponse responseGet = null; - - while(attemptsLeft-- > 0){ - netLogger.info("[OUT|{}|{}|]", "AAI", urlGet); - Pair httpDetailsGet = RESTManager.get(urlGet, username, password, headers); - if (httpDetailsGet == null) { - logger.info("AAI GET Null Response to " + urlGet); - return null; - } - - logger.info(urlGet); - logger.info(httpDetailsGet.a.toString()); - logger.info(httpDetailsGet.b); - - if (httpDetailsGet.a == 200) { - try { - responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, AAIGETVnfResponse.class); - netLogger.info("[IN|{}|{}|]{}{}", "AAI", urlGet, System.lineSeparator(), httpDetailsGet.b); - return responseGet; - } catch (JsonSyntaxException e) { - logger.error("postQuery threw: ", e); - } - } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { Thread.currentThread().interrupt(); } + return headers; + } + + /** + * This method uses Google's GSON to create a response object from a JSON string + * @param httpDetails the HTTP response + * @param url the URL from which the response came + * @param classOfT The response class + * @return an instance of the response class + * @throws JsonSyntaxException on GSON errors instantiating the response + */ + private static T composeResponse(final Pair httpDetails, final String url, final Class classOfT) { + try { + T response = Serialization.gsonPretty.fromJson(httpDetails.b, classOfT); + netLogger.info("[IN|{}|{}|]{}{}", "AAI", url, LINE_SEPARATOR, httpDetails.b); + return response; + } catch (JsonSyntaxException e) { + logger.error("postQuery threw: ", e); + return null; } - - return null; } } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQCloudRegion.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQCloudRegion.java index cbe2b9730..bfeb1e56c 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQCloudRegion.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQCloudRegion.java @@ -45,7 +45,4 @@ public class AAINQCloudRegion implements Serializable { @SerializedName("resource-version") public String resourceVersion; - - public AAINQCloudRegion() { - } } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQExtraProperties.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQExtraProperties.java index 6f451ce8d..b11859aeb 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQExtraProperties.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQExtraProperties.java @@ -34,9 +34,13 @@ public class AAINQExtraProperties implements Serializable { private static final long serialVersionUID = 4109625574744702319L; @SerializedName("extra-property") - public List extraProperty = new LinkedList(); - - public AAINQExtraProperties() { + private List extraProperty = new LinkedList<>(); + + public List getExtraProperty() { + return extraProperty; + } + + public void setExtraProperty(List extraProperty) { + this.extraProperty = extraProperty; } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQGenericVNF.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQGenericVNF.java index d2bff6b7b..12b8fc42a 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQGenericVNF.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQGenericVNF.java @@ -81,8 +81,4 @@ public class AAINQGenericVNF implements Serializable { @SerializedName("model-version-id") public String modelVersionId; - - public AAINQGenericVNF() { - } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInstanceFilters.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInstanceFilters.java index b122279d6..24b833f25 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInstanceFilters.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInstanceFilters.java @@ -35,9 +35,13 @@ public class AAINQInstanceFilters implements Serializable { private static final long serialVersionUID = 8993824591338121185L; @SerializedName("instance-filter") - public List>> instanceFilter = new LinkedList<>(); - - public AAINQInstanceFilters() { + private List>> instanceFilter = new LinkedList<>(); + + public List>> getInstanceFilter() { + return instanceFilter; } + public void setInstanceFilter(List>> instanceFilter) { + this.instanceFilter = instanceFilter; + } } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItem.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItem.java index 1dece7da0..b4f1767e4 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItem.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItem.java @@ -57,8 +57,4 @@ public class AAINQInventoryResponseItem implements Serializable { @SerializedName("inventory-response-items") public AAINQInventoryResponseItems items; - - public AAINQInventoryResponseItem() { - } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItems.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItems.java index f4ee0fa3e..8e9728ab3 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItems.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItems.java @@ -34,9 +34,13 @@ public class AAINQInventoryResponseItems implements Serializable { private static final long serialVersionUID = 7602807659381179004L; @SerializedName("inventory-response-item") - public List inventoryResponseItems = new LinkedList<>(); - - public AAINQInventoryResponseItems() { + private List inventoryResponseItems = new LinkedList<>(); + + public List getInventoryResponseItems() { + return inventoryResponseItems; } + public void setInventoryResponseItems(List inventoryResponseItems) { + this.inventoryResponseItems = inventoryResponseItems; + } } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQNamedQuery.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQNamedQuery.java index 7ed82e1e9..423c98090 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQNamedQuery.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQNamedQuery.java @@ -34,8 +34,4 @@ public class AAINQNamedQuery implements Serializable { @SerializedName("named-query-uuid") public UUID namedQueryUUID; - - public AAINQNamedQuery() { - } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQQueryParameters.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQQueryParameters.java index eca372bf6..ddff71043 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQQueryParameters.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQQueryParameters.java @@ -33,8 +33,4 @@ public class AAINQQueryParameters implements Serializable { @SerializedName("named-query") public AAINQNamedQuery namedQuery; - - public AAINQQueryParameters() { - } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQRequest.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQRequest.java index 91d9f1a6e..d8d600075 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQRequest.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQRequest.java @@ -35,8 +35,4 @@ public class AAINQRequest implements Serializable { public AAINQQueryParameters queryParameters; @SerializedName("instance-filters") public AAINQInstanceFilters instanceFilters; - - public AAINQRequest() { - } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponse.java index 527a12089..2e6776fc6 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponse.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponse.java @@ -35,12 +35,24 @@ public class AAINQResponse implements Serializable { private static final long serialVersionUID = 8411407444051746101L; @SerializedName("inventory-response-item") - public List inventoryResponseItems = new LinkedList<>(); + private List inventoryResponseItems = new LinkedList<>(); @SerializedName("requestError") - public AAINQRequestError requestError; + private AAINQRequestError requestError; - public AAINQResponse() { + public List getInventoryResponseItems() { + return inventoryResponseItems; } + public void setInventoryResponseItems(List inventoryResponseItems) { + this.inventoryResponseItems = inventoryResponseItems; + } + + public AAINQRequestError getRequestError() { + return requestError; + } + + public void setRequestError(AAINQRequestError requestError) { + this.requestError = requestError; + } } \ No newline at end of file diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponseWrapper.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponseWrapper.java index 7bb58eb7d..e8d1620de 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponseWrapper.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponseWrapper.java @@ -26,15 +26,30 @@ import org.onap.policy.aai.AAINQResponse; public class AAINQResponseWrapper { - public UUID requestID; - public AAINQResponse aainqresponse; + private UUID requestID; + private AAINQResponse aainqresponse; public AAINQResponseWrapper() { - } public AAINQResponseWrapper(UUID requestID, AAINQResponse aainqresponse){ this.requestID = requestID; this.aainqresponse = aainqresponse; } + + public UUID getRequestID() { + return requestID; + } + + public void setRequestID(UUID requestID) { + this.requestID = requestID; + } + + public AAINQResponse getAainqresponse() { + return aainqresponse; + } + + public void setAainqresponse(AAINQResponse aainqresponse) { + this.aainqresponse = aainqresponse; + } } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQServiceInstance.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQServiceInstance.java index ed7d9225a..256a057a4 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQServiceInstance.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQServiceInstance.java @@ -54,8 +54,4 @@ public class AAINQServiceInstance implements Serializable { @SerializedName("model-version-id") public String modelVersionId; - - public AAINQServiceInstance() { - } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQTenant.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQTenant.java index 98ea83b1f..afd55fd45 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQTenant.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQTenant.java @@ -39,7 +39,4 @@ public class AAINQTenant implements Serializable { @SerializedName("resource-version") public String resourceVersion; - - public AAINQTenant() { - } } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVServer.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVServer.java index 5a9834fee..f6130e95b 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVServer.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVServer.java @@ -54,8 +54,4 @@ public class AAINQVServer implements Serializable { @SerializedName("resource-version") public String resourceVersion; - - public AAINQVServer() { - } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVfModule.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVfModule.java index 07c4303c2..b20681d7f 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVfModule.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVfModule.java @@ -69,7 +69,4 @@ public class AAINQVfModule implements Serializable { @SerializedName("model-version-id") public String modelVersionId; - - public AAINQVfModule() { - } } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNF.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNF.java index d8074e0a8..56fb77362 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNF.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNF.java @@ -29,28 +29,44 @@ public class PNF implements Serializable { */ private static final long serialVersionUID = -3535108358668248501L; - public String PNFName; - public PNFType PNFType; + private String pnfName; + private PNFType pnfType; public PNF() { } public PNF(PNF pnf) { - this.PNFName = pnf.PNFName; - this.PNFType = pnf.PNFType; + this.pnfName = pnf.pnfName; + this.pnfType = pnf.pnfType; } + public String getPNFName() { + return pnfName; + } + + public void setPNFName(String pNFName) { + pnfName = pNFName; + } + + public PNFType getPNFType() { + return pnfType; + } + + public void setPNFType(PNFType pNFType) { + pnfType = pNFType; + } + @Override public String toString() { - return "PNF [PNFName=" + PNFName + ", PNFType=" + PNFType + "]"; + return "PNF [PNFName=" + pnfName + ", PNFType=" + pnfType + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((PNFName == null) ? 0 : PNFName.hashCode()); - result = prime * result + ((PNFType == null) ? 0 : PNFType.hashCode()); + result = prime * result + ((pnfName == null) ? 0 : pnfName.hashCode()); + result = prime * result + ((pnfType == null) ? 0 : pnfType.hashCode()); return result; } @Override @@ -62,14 +78,11 @@ public class PNF implements Serializable { if (getClass() != obj.getClass()) return false; PNF other = (PNF) obj; - if (PNFName == null) { - if (other.PNFName != null) + if (pnfName == null) { + if (other.pnfName != null) return false; - } else if (!PNFName.equals(other.PNFName)) + } else if (!pnfName.equals(other.pnfName)) return false; - if (PNFType != other.PNFType) - return false; - return true; + return pnfType == other.pnfType; } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNFInstance.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNFInstance.java index 21d1d50ac..159e5cb28 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNFInstance.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNFInstance.java @@ -29,10 +29,10 @@ public class PNFInstance implements Serializable { */ private static final long serialVersionUID = -3694152433472165034L; - public String PNFName; - public String PNFInstanceName; - public PNFType PNFType; - public String PNFSerial; + private String pnfName; + private String pnfInstanceName; + private PNFType pnfType; + private String pnfSerial; public PNFInstance() { @@ -42,26 +42,58 @@ public class PNFInstance implements Serializable { if (instance == null) { return; } - this.PNFName = instance.PNFName; - this.PNFInstanceName = instance.PNFInstanceName; - this.PNFType = instance.PNFType; - this.PNFSerial = instance.PNFSerial; + this.pnfName = instance.pnfName; + this.pnfInstanceName = instance.pnfInstanceName; + this.pnfType = instance.pnfType; + this.pnfSerial = instance.pnfSerial; + } + + public String getPNFName() { + return pnfName; + } + + public void setPNFName(String pNFName) { + pnfName = pNFName; + } + + public String getPNFInstanceName() { + return pnfInstanceName; + } + + public void setPNFInstanceName(String pNFInstanceName) { + pnfInstanceName = pNFInstanceName; + } + + public PNFType getPNFType() { + return pnfType; + } + + public void setPNFType(PNFType pNFType) { + pnfType = pNFType; + } + + public String getPNFSerial() { + return pnfSerial; + } + + public void setPNFSerial(String pNFSerial) { + pnfSerial = pNFSerial; } @Override public String toString() { - return "PNFInstance [PNFName=" + PNFName + ", PNFInstanceName=" + PNFInstanceName + ", PNFType=" + PNFType - + ", PNFSerial=" + PNFSerial + "]"; + return "PNFInstance [PNFName=" + pnfName + ", PNFInstanceName=" + pnfInstanceName + ", PNFType=" + pnfType + + ", PNFSerial=" + pnfSerial + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((PNFInstanceName == null) ? 0 : PNFInstanceName.hashCode()); - result = prime * result + ((PNFName == null) ? 0 : PNFName.hashCode()); - result = prime * result + ((PNFSerial == null) ? 0 : PNFSerial.hashCode()); - result = prime * result + ((PNFType == null) ? 0 : PNFType.hashCode()); + result = prime * result + ((pnfInstanceName == null) ? 0 : pnfInstanceName.hashCode()); + result = prime * result + ((pnfName == null) ? 0 : pnfName.hashCode()); + result = prime * result + ((pnfSerial == null) ? 0 : pnfSerial.hashCode()); + result = prime * result + ((pnfType == null) ? 0 : pnfType.hashCode()); return result; } @@ -74,24 +106,21 @@ public class PNFInstance implements Serializable { if (getClass() != obj.getClass()) return false; PNFInstance other = (PNFInstance) obj; - if (PNFInstanceName == null) { - if (other.PNFInstanceName != null) + if (pnfInstanceName == null) { + if (other.pnfInstanceName != null) return false; - } else if (!PNFInstanceName.equals(other.PNFInstanceName)) + } else if (!pnfInstanceName.equals(other.pnfInstanceName)) return false; - if (PNFName == null) { - if (other.PNFName != null) + if (pnfName == null) { + if (other.pnfName != null) return false; - } else if (!PNFName.equals(other.PNFName)) + } else if (!pnfName.equals(other.pnfName)) return false; - if (PNFSerial == null) { - if (other.PNFSerial != null) + if (pnfSerial == null) { + if (other.pnfSerial != null) return false; - } else if (!PNFSerial.equals(other.PNFSerial)) + } else if (!pnfSerial.equals(other.pnfSerial)) return false; - if (PNFType != other.PNFType) - return false; - return true; + return pnfType == other.pnfType; } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java index 2f8acf697..bb3a95f30 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java @@ -33,9 +33,13 @@ public class RelatedToProperty implements Serializable { */ private static final long serialVersionUID = 2088088164920423658L; @SerializedName("related-to-property") - public List relatedTo = new LinkedList(); + private List relatedTo = new LinkedList<>(); - public RelatedToProperty() { + public List getRelatedTo() { + return relatedTo; + } + public void setRelatedTo(List relatedTo) { + this.relatedTo = relatedTo; } } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToPropertyItem.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToPropertyItem.java index d455bcf48..24466d6dc 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToPropertyItem.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToPropertyItem.java @@ -35,8 +35,4 @@ public class RelatedToPropertyItem implements Serializable { public String propertyKey; @SerializedName("property-value") public String propertyValue; - - public RelatedToPropertyItem() { - } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java index 029a4b823..07169c9ec 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java @@ -41,7 +41,4 @@ public class Relationship implements Serializable { @SerializedName("related-to-property") public RelatedToProperty relatedToProperty = new RelatedToProperty(); - - public Relationship() { - } } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java index 2ad373104..08e41a912 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java @@ -33,8 +33,13 @@ public class RelationshipData implements Serializable { */ private static final long serialVersionUID = 6809180843309562121L; @SerializedName("relationship-data") - public List relationshipData = new LinkedList<>(); - - public RelationshipData() { + private List relationshipDataList = new LinkedList<>(); + + public List getRelationshipData() { + return relationshipDataList; + } + + public void setRelationshipData(List relationshipData) { + this.relationshipDataList = relationshipData; } } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipDataItem.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipDataItem.java index a040f0d61..39efdcd4b 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipDataItem.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipDataItem.java @@ -35,8 +35,4 @@ public class RelationshipDataItem implements Serializable { public String relationshipKey; @SerializedName("relationship-value") public String relationshipValue; - - public RelationshipDataItem() { - } - } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java index 8451998eb..939950561 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java @@ -34,9 +34,13 @@ public class RelationshipItem implements Serializable { private static final long serialVersionUID = 1543404460741069628L; @SerializedName("related-to-property") - public List relatedToProperty = new LinkedList(); - - public RelationshipItem() { + private List relatedToProperty = new LinkedList<>(); + + public List getRelatedToProperty() { + return relatedToProperty; } + public void setRelatedToProperty(List relatedToProperty) { + this.relatedToProperty = relatedToProperty; + } } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java index b31b3a6dc..46e04c8fd 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java @@ -32,8 +32,14 @@ public class RelationshipList implements Serializable { */ private static final long serialVersionUID = 6115655704973981989L; @SerializedName("relationship-list") - public List relationshipList = new LinkedList<>(); + private List relationships = new LinkedList<>(); - public RelationshipList() { + public List getRelationshipList() { + return relationships; } + public void setRelationshipList(List relationshipList) { + this.relationships = relationshipList; + } + + } diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVnfResponseTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVnfResponseTest.java index e668ca372..534dd4791 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVnfResponseTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVnfResponseTest.java @@ -49,28 +49,28 @@ public class AAIGETVnfResponseTest { relationshipDataItem.relationshipKey = "customer.global-customer-id"; relationshipDataItem.relationshipValue = "MSO_1610_ST"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); relationshipDataItem.relationshipKey = "service-subscription.service-type"; relationshipDataItem.relationshipValue = "MSO-dev-service-type"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); relationshipDataItem.relationshipKey = "service-instance.service-instance-id"; relationshipDataItem.relationshipValue = "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); RelatedToProperty relatedToProperty = new RelatedToProperty(); RelatedToPropertyItem item = new RelatedToPropertyItem(); item.propertyKey = "service-instance.service-instance-name"; item.propertyValue = "lll_svc_010317"; - relatedToProperty.relatedTo.add(item); + relatedToProperty.getRelatedTo().add(item); relationship.relatedTo = "service-instance"; relationship.relatedLink = "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; relationship.relationshipData = relationshipData; relationship.relatedToProperty = relatedToProperty; - relationshipList.relationshipList.add(relationship); + relationshipList.getRelationshipList().add(relationship); response.relationshipList = relationshipList; logger.info(Serialization.gsonPretty.toJson(response)); diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVserverResponseTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVserverResponseTest.java index 83d2a2682..1221557dd 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVserverResponseTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVserverResponseTest.java @@ -47,28 +47,28 @@ public class AAIGETVserverResponseTest { relationshipDataItem.relationshipKey = "customer.global-customer-id"; relationshipDataItem.relationshipValue = "MSO_1610_ST"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); relationshipDataItem.relationshipKey = "service-subscription.service-type"; relationshipDataItem.relationshipValue = "MSO-dev-service-type"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); relationshipDataItem.relationshipKey = "service-instance.service-instance-id"; relationshipDataItem.relationshipValue = "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); RelatedToProperty relatedToProperty = new RelatedToProperty(); RelatedToPropertyItem item = new RelatedToPropertyItem(); item.propertyKey = "service-instance.service-instance-name"; item.propertyValue = "lll_svc_010317"; - relatedToProperty.relatedTo.add(item); + relatedToProperty.getRelatedTo().add(item); relationship.relatedTo = "service-instance"; relationship.relatedLink = "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; relationship.relationshipData = relationshipData; relationship.relatedToProperty = relatedToProperty; - relationshipList.relationshipList.add(relationship); + relationshipList.getRelationshipList().add(relationship); response.relationshipList = relationshipList; logger.info(Serialization.gsonPretty.toJson(response)); diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQExtraPropertiesTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQExtraPropertiesTest.java index d67f3dd11..148f5df4b 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQExtraPropertiesTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQExtraPropertiesTest.java @@ -38,11 +38,11 @@ public class AAINQExtraPropertiesTest { @Test public void test() { AAINQExtraProperties aaiNQExtraProperties = new AAINQExtraProperties(); - aaiNQExtraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "service-instance")); - aaiNQExtraProperties.extraProperty.add(new AAINQExtraProperty("model.model-type", "widget")); - aaiNQExtraProperties.extraProperty.add(new AAINQExtraProperty("model.model-version", "1.0")); - aaiNQExtraProperties.extraProperty.add(new AAINQExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - aaiNQExtraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); + aaiNQExtraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "service-instance")); + aaiNQExtraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-type", "widget")); + aaiNQExtraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-version", "1.0")); + aaiNQExtraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); + aaiNQExtraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); assertNotNull(aaiNQExtraProperties); } diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQInventoryResponseItemTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQInventoryResponseItemTest.java index ac21a81d8..9dd686409 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQInventoryResponseItemTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQInventoryResponseItemTest.java @@ -52,12 +52,12 @@ public class AAINQInventoryResponseItemTest { aaiNQCloudRegion.resourceVersion = "1485365988"; aaiNQInventoryResponseItem.cloudRegion = aaiNQCloudRegion; AAINQExtraProperties aaiNQExtraProperties = new AAINQExtraProperties(); - aaiNQExtraProperties.extraProperty = new LinkedList<>(); - aaiNQExtraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "generic-vnf")); - aaiNQExtraProperties.extraProperty.add(new AAINQExtraProperty("model.model-type", "widget")); - aaiNQExtraProperties.extraProperty.add(new AAINQExtraProperty("model.model-version", "1.0")); - aaiNQExtraProperties.extraProperty.add(new AAINQExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); - aaiNQExtraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); + aaiNQExtraProperties.setExtraProperty(new LinkedList<>()); + aaiNQExtraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "generic-vnf")); + aaiNQExtraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-type", "widget")); + aaiNQExtraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-version", "1.0")); + aaiNQExtraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); + aaiNQExtraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); aaiNQInventoryResponseItem.extraProperties = aaiNQExtraProperties; AAINQGenericVNF aaiNQGenericVNF = new AAINQGenericVNF(); aaiNQGenericVNF.vnfID = "dhv-test-gvnf"; @@ -87,11 +87,11 @@ public class AAINQInventoryResponseItemTest { serviceItem.serviceInstance.serviceInstanceLocationId = "dhv-test-service-instance-location-id1"; serviceItem.serviceInstance.resourceVersion = "1485366092"; serviceItem.extraProperties = new AAINQExtraProperties(); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "service-instance")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-type", "widget")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-version", "1.0")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "service-instance")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-type", "widget")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-version", "1.0")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); AAINQInventoryResponseItem vfModuleItem = new AAINQInventoryResponseItem(); vfModuleItem.modelName = "vf-module"; @@ -108,14 +108,14 @@ public class AAINQInventoryResponseItemTest { vfModuleItem.vfModule.widgetModelVersion = "example-widget-model-version-val-83317"; vfModuleItem.vfModule.contrailServiceInstanceFqdn = "example-contrail-service-instance-fqdn-val-86796"; vfModuleItem.extraProperties = new AAINQExtraProperties(); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "vf-module")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-type", "widget")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-version", "1.0")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "vf-module")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-type", "widget")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-version", "1.0")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); - aaiNQInventoryResponseItems.inventoryResponseItems.add(serviceItem); - aaiNQInventoryResponseItems.inventoryResponseItems.add(vfModuleItem); + aaiNQInventoryResponseItems.getInventoryResponseItems().add(serviceItem); + aaiNQInventoryResponseItems.getInventoryResponseItems().add(vfModuleItem); aaiNQInventoryResponseItem.items = aaiNQInventoryResponseItems; aaiNQInventoryResponseItem.modelName = "model-name"; AAINQServiceInstance serviceInstance = new AAINQServiceInstance(); diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQInventoryResponseItemsTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQInventoryResponseItemsTest.java index 89ce586b6..df6b19959 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQInventoryResponseItemsTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQInventoryResponseItemsTest.java @@ -54,11 +54,11 @@ public class AAINQInventoryResponseItemsTest { serviceItem.serviceInstance.serviceInstanceLocationId = "dhv-test-service-instance-location-id1"; serviceItem.serviceInstance.resourceVersion = "1485366092"; serviceItem.extraProperties = new AAINQExtraProperties(); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "service-instance")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-type", "widget")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-version", "1.0")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "service-instance")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-type", "widget")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-version", "1.0")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); AAINQInventoryResponseItem vfModuleItem = new AAINQInventoryResponseItem(); vfModuleItem.modelName = "vf-module"; @@ -75,11 +75,11 @@ public class AAINQInventoryResponseItemsTest { vfModuleItem.vfModule.widgetModelVersion = "example-widget-model-version-val-83317"; vfModuleItem.vfModule.contrailServiceInstanceFqdn = "example-contrail-service-instance-fqdn-val-86796"; vfModuleItem.extraProperties = new AAINQExtraProperties(); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "vf-module")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-type", "widget")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-version", "1.0")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "vf-module")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-type", "widget")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-version", "1.0")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); AAINQInventoryResponseItem genericVNFItem = new AAINQInventoryResponseItem(); genericVNFItem.modelName = "generic-vnf"; @@ -100,16 +100,16 @@ public class AAINQInventoryResponseItemsTest { genericVNFItem.genericVNF.personaModelId = "acc6edd8-a8d4-4b93-afaa-0994068be14c"; genericVNFItem.genericVNF.personaModelVersion = "1.0"; genericVNFItem.extraProperties = new AAINQExtraProperties(); - genericVNFItem.extraProperties.extraProperty = new LinkedList<>(); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "generic-vnf")); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-type", "widget")); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-version", "1.0")); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); + genericVNFItem.extraProperties.setExtraProperty(new LinkedList<>()); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "generic-vnf")); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-type", "widget")); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-version", "1.0")); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); genericVNFItem.items = new AAINQInventoryResponseItems(); - genericVNFItem.items.inventoryResponseItems = new LinkedList<>(); - genericVNFItem.items.inventoryResponseItems.add(serviceItem); - genericVNFItem.items.inventoryResponseItems.add(vfModuleItem); + genericVNFItem.items.setInventoryResponseItems(new LinkedList<>()); + genericVNFItem.items.getInventoryResponseItems().add(serviceItem); + genericVNFItem.items.getInventoryResponseItems().add(vfModuleItem); AAINQInventoryResponseItem cloudItem = new AAINQInventoryResponseItem(); cloudItem.cloudRegion = new AAINQCloudRegion(); @@ -125,8 +125,8 @@ public class AAINQInventoryResponseItemsTest { tenantItem.tenant.tenantName = "dhv-test-tenant-name"; tenantItem.tenant.resourceVersion = "1485366334"; tenantItem.items = new AAINQInventoryResponseItems(); - tenantItem.items.inventoryResponseItems = new LinkedList<>(); - tenantItem.items.inventoryResponseItems.add(cloudItem); + tenantItem.items.setInventoryResponseItems(new LinkedList<>()); + tenantItem.items.getInventoryResponseItems().add(cloudItem); AAINQInventoryResponseItem vserverItem = new AAINQInventoryResponseItem(); vserverItem.vserver = new AAINQVServer(); vserverItem.vserver.vserverId = "dhv-test-vserver"; @@ -138,10 +138,10 @@ public class AAINQInventoryResponseItemsTest { vserverItem.vserver.isClosedLoopDisabled = false; vserverItem.vserver.resourceVersion = "1485366417"; vserverItem.items = new AAINQInventoryResponseItems(); - vserverItem.items.inventoryResponseItems = new LinkedList<>(); - vserverItem.items.inventoryResponseItems.add(genericVNFItem); - vserverItem.items.inventoryResponseItems.add(tenantItem); - aaiNQInventoryResponseItems.inventoryResponseItems.add(vserverItem); + vserverItem.items.setInventoryResponseItems(new LinkedList<>()); + vserverItem.items.getInventoryResponseItems().add(genericVNFItem); + vserverItem.items.getInventoryResponseItems().add(tenantItem); + aaiNQInventoryResponseItems.getInventoryResponseItems().add(vserverItem); assertNotNull(aaiNQInventoryResponseItems); logger.info(Serialization.gsonPretty.toJson(aaiNQInventoryResponseItems)); } diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQResponseTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQResponseTest.java index 6b1b624ef..5e59429c2 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQResponseTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQResponseTest.java @@ -41,11 +41,11 @@ public class AAINQResponseTest { serviceItem.serviceInstance.serviceInstanceLocationId = "dhv-test-service-instance-location-id1"; serviceItem.serviceInstance.resourceVersion = "1485366092"; serviceItem.extraProperties = new AAINQExtraProperties(); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "service-instance")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-type", "widget")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-version", "1.0")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "service-instance")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-type", "widget")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-version", "1.0")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); AAINQInventoryResponseItem vfModuleItem = new AAINQInventoryResponseItem(); vfModuleItem.modelName = "vf-module"; @@ -62,11 +62,11 @@ public class AAINQResponseTest { vfModuleItem.vfModule.widgetModelVersion = "example-widget-model-version-val-83317"; vfModuleItem.vfModule.contrailServiceInstanceFqdn = "example-contrail-service-instance-fqdn-val-86796"; vfModuleItem.extraProperties = new AAINQExtraProperties(); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "vf-module")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-type", "widget")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-version", "1.0")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "vf-module")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-type", "widget")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-version", "1.0")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); AAINQInventoryResponseItem genericVNFItem = new AAINQInventoryResponseItem(); genericVNFItem.modelName = "generic-vnf"; @@ -87,16 +87,16 @@ public class AAINQResponseTest { genericVNFItem.genericVNF.personaModelId = "acc6edd8-a8d4-4b93-afaa-0994068be14c"; genericVNFItem.genericVNF.personaModelVersion = "1.0"; genericVNFItem.extraProperties = new AAINQExtraProperties(); - genericVNFItem.extraProperties.extraProperty = new LinkedList<>(); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "generic-vnf")); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-type", "widget")); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-version", "1.0")); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); + genericVNFItem.extraProperties.setExtraProperty(new LinkedList<>()); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "generic-vnf")); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-type", "widget")); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-version", "1.0")); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); genericVNFItem.items = new AAINQInventoryResponseItems(); - genericVNFItem.items.inventoryResponseItems = new LinkedList<>(); - genericVNFItem.items.inventoryResponseItems.add(serviceItem); - genericVNFItem.items.inventoryResponseItems.add(vfModuleItem); + genericVNFItem.items.setInventoryResponseItems(new LinkedList<>()); + genericVNFItem.items.getInventoryResponseItems().add(serviceItem); + genericVNFItem.items.getInventoryResponseItems().add(vfModuleItem); AAINQInventoryResponseItem cloudItem = new AAINQInventoryResponseItem(); cloudItem.cloudRegion = new AAINQCloudRegion(); @@ -112,8 +112,8 @@ public class AAINQResponseTest { tenantItem.tenant.tenantName = "dhv-test-tenant-name"; tenantItem.tenant.resourceVersion = "1485366334"; tenantItem.items = new AAINQInventoryResponseItems(); - tenantItem.items.inventoryResponseItems = new LinkedList<>(); - tenantItem.items.inventoryResponseItems.add(cloudItem); + tenantItem.items.setInventoryResponseItems(new LinkedList<>()); + tenantItem.items.getInventoryResponseItems().add(cloudItem); AAINQInventoryResponseItem vserverItem = new AAINQInventoryResponseItem(); vserverItem.vserver = new AAINQVServer(); @@ -126,12 +126,12 @@ public class AAINQResponseTest { vserverItem.vserver.isClosedLoopDisabled = false; vserverItem.vserver.resourceVersion = "1485366417"; vserverItem.items = new AAINQInventoryResponseItems(); - vserverItem.items.inventoryResponseItems = new LinkedList<>(); - vserverItem.items.inventoryResponseItems.add(genericVNFItem); - vserverItem.items.inventoryResponseItems.add(tenantItem); + vserverItem.items.setInventoryResponseItems(new LinkedList<>()); + vserverItem.items.getInventoryResponseItems().add(genericVNFItem); + vserverItem.items.getInventoryResponseItems().add(tenantItem); AAINQResponse aaiResponse = new AAINQResponse(); - aaiResponse.inventoryResponseItems.add(vserverItem); + aaiResponse.getInventoryResponseItems().add(vserverItem); logger.info(Serialization.gsonPretty.toJson(aaiResponse)); } } diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQResponseWrapperTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQResponseWrapperTest.java index ae578f00c..9c4bfafa8 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQResponseWrapperTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAINQResponseWrapperTest.java @@ -55,11 +55,11 @@ public class AAINQResponseWrapperTest { serviceItem.serviceInstance.serviceInstanceLocationId = "dhv-test-service-instance-location-id1"; serviceItem.serviceInstance.resourceVersion = "1485366092"; serviceItem.extraProperties = new AAINQExtraProperties(); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "service-instance")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-type", "widget")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-version", "1.0")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - serviceItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "service-instance")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-type", "widget")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-version", "1.0")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); + serviceItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); AAINQInventoryResponseItem vfModuleItem = new AAINQInventoryResponseItem(); vfModuleItem.modelName = "vf-module"; @@ -76,11 +76,11 @@ public class AAINQResponseWrapperTest { vfModuleItem.vfModule.widgetModelVersion = "example-widget-model-version-val-83317"; vfModuleItem.vfModule.contrailServiceInstanceFqdn = "example-contrail-service-instance-fqdn-val-86796"; vfModuleItem.extraProperties = new AAINQExtraProperties(); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "vf-module")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-type", "widget")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-version", "1.0")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); - vfModuleItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "vf-module")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-type", "widget")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-version", "1.0")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); + vfModuleItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); AAINQInventoryResponseItem genericVNFItem = new AAINQInventoryResponseItem(); genericVNFItem.modelName = "generic-vnf"; @@ -101,16 +101,16 @@ public class AAINQResponseWrapperTest { genericVNFItem.genericVNF.personaModelId = "acc6edd8-a8d4-4b93-afaa-0994068be14c"; genericVNFItem.genericVNF.personaModelVersion = "1.0"; genericVNFItem.extraProperties = new AAINQExtraProperties(); - genericVNFItem.extraProperties.extraProperty = new LinkedList<>(); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name", "generic-vnf")); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-type", "widget")); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-version", "1.0")); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); - genericVNFItem.extraProperties.extraProperty.add(new AAINQExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); + genericVNFItem.extraProperties.setExtraProperty(new LinkedList<>()); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name", "generic-vnf")); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-type", "widget")); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-version", "1.0")); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); + genericVNFItem.extraProperties.getExtraProperty().add(new AAINQExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); genericVNFItem.items = new AAINQInventoryResponseItems(); - genericVNFItem.items.inventoryResponseItems = new LinkedList<>(); - genericVNFItem.items.inventoryResponseItems.add(serviceItem); - genericVNFItem.items.inventoryResponseItems.add(vfModuleItem); + genericVNFItem.items.setInventoryResponseItems(new LinkedList<>()); + genericVNFItem.items.getInventoryResponseItems().add(serviceItem); + genericVNFItem.items.getInventoryResponseItems().add(vfModuleItem); AAINQInventoryResponseItem cloudItem = new AAINQInventoryResponseItem(); cloudItem.cloudRegion = new AAINQCloudRegion(); @@ -126,8 +126,8 @@ public class AAINQResponseWrapperTest { tenantItem.tenant.tenantName = "dhv-test-tenant-name"; tenantItem.tenant.resourceVersion = "1485366334"; tenantItem.items = new AAINQInventoryResponseItems(); - tenantItem.items.inventoryResponseItems = new LinkedList<>(); - tenantItem.items.inventoryResponseItems.add(cloudItem); + tenantItem.items.setInventoryResponseItems(new LinkedList<>()); + tenantItem.items.getInventoryResponseItems().add(cloudItem); AAINQInventoryResponseItem vserverItem = new AAINQInventoryResponseItem(); vserverItem.vserver = new AAINQVServer(); @@ -140,15 +140,15 @@ public class AAINQResponseWrapperTest { vserverItem.vserver.isClosedLoopDisabled = false; vserverItem.vserver.resourceVersion = "1485366417"; vserverItem.items = new AAINQInventoryResponseItems(); - vserverItem.items.inventoryResponseItems = new LinkedList<>(); - vserverItem.items.inventoryResponseItems.add(genericVNFItem); - vserverItem.items.inventoryResponseItems.add(tenantItem); + vserverItem.items.setInventoryResponseItems(new LinkedList<>()); + vserverItem.items.getInventoryResponseItems().add(genericVNFItem); + vserverItem.items.getInventoryResponseItems().add(tenantItem); AAINQResponse aaiResponse = new AAINQResponse(); - aaiResponse.inventoryResponseItems.add(vserverItem); + aaiResponse.getInventoryResponseItems().add(vserverItem); AAINQResponseWrapper aaiNQResponseWarapper = new AAINQResponseWrapper(); - aaiNQResponseWarapper.aainqresponse = aaiResponse; - aaiNQResponseWarapper.requestID = UUID.randomUUID(); + aaiNQResponseWarapper.setAainqresponse(aaiResponse); + aaiNQResponseWarapper.setRequestID(UUID.randomUUID()); assertNotNull(aaiNQResponseWarapper); logger.info(Serialization.gsonPretty.toJson(aaiNQResponseWarapper)); } diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PNFInstanceTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PNFInstanceTest.java index 4dccca852..31243b8d9 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PNFInstanceTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PNFInstanceTest.java @@ -42,9 +42,9 @@ public class PNFInstanceTest { @Test public void test() { PNFInstance pnfInstance = new PNFInstance(); - pnfInstance.PNFInstanceName = "pnf-instance-name-test"; - pnfInstance.PNFName = "pnf-name-test"; - pnfInstance.PNFSerial = "pnf-serial-test"; + pnfInstance.setPNFInstanceName("pnf-instance-name-test"); + pnfInstance.setPNFName("pnf-name-test"); + pnfInstance.setPNFSerial("pnf-serial-test"); assertNotNull(pnfInstance); logger.info(Serialization.gsonPretty.toJson(pnfInstance)); } diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PNFTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PNFTest.java index e63250f3f..da3593f01 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PNFTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PNFTest.java @@ -42,8 +42,8 @@ public class PNFTest { @Test public void test() { PNF pnf = new PNF(); - pnf.PNFName = "pnf-name-test"; - pnf.PNFType = PNFType.ENODEB; + pnf.setPNFName("pnf-name-test"); + pnf.setPNFType(PNFType.ENODEB); assertNotNull(pnf); logger.info(Serialization.gsonPretty.toJson(pnf)); } diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java index 9ead0cffa..1b0692944 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java @@ -45,11 +45,11 @@ public class RelatedToPropertyTest { RelatedToPropertyItem relatedToPropertyItem = new RelatedToPropertyItem(); relatedToPropertyItem.propertyKey = "model.model-name"; relatedToPropertyItem.propertyValue = "service-instance"; - relatedToProperty.relatedTo.add(relatedToPropertyItem); + relatedToProperty.getRelatedTo().add(relatedToPropertyItem); RelatedToPropertyItem relatedToPropertyItem2 = new RelatedToPropertyItem(); relatedToPropertyItem2.propertyKey = "model.model-name2"; relatedToPropertyItem2.propertyValue = "service-instance2"; - relatedToProperty.relatedTo.add(relatedToPropertyItem2); + relatedToProperty.getRelatedTo().add(relatedToPropertyItem2); assertNotNull(relatedToProperty); logger.info(Serialization.gsonPretty.toJson(relatedToProperty)); } diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java index 4a3d947c0..5498caeac 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java @@ -46,11 +46,11 @@ public class RelationshipDataTest { relationshipDataItem.relationshipKey = "relationship-key"; relationshipDataItem.relationshipValue = "relationship-value"; assertNotNull(relationshipDataItem); - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); RelationshipDataItem relationshipDataItem2 = new RelationshipDataItem(); relationshipDataItem2.relationshipKey = "relationship-key2"; relationshipDataItem2.relationshipValue = "relationship-value2"; - relationshipData.relationshipData.add(relationshipDataItem2); + relationshipData.getRelationshipData().add(relationshipDataItem2); assertNotNull(relationshipData); logger.info(Serialization.gsonPretty.toJson(relationshipData)); } diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipItemTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipItemTest.java index 2102ebe04..4313e0605 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipItemTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipItemTest.java @@ -45,7 +45,7 @@ public class RelationshipItemTest { RelatedToPropertyItem relatedToPropertyItem = new RelatedToPropertyItem(); relatedToPropertyItem.propertyKey = "model.model-name"; relatedToPropertyItem.propertyValue = "service-instance"; - relationshipItem.relatedToProperty.add(relatedToPropertyItem); + relationshipItem.getRelatedToProperty().add(relatedToPropertyItem); assertNotNull(relationshipItem); logger.info(Serialization.gsonPretty.toJson(relationshipItem)); } diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java index 3eccb0bdb..3d06b0e6b 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java @@ -49,19 +49,19 @@ public class RelationshipListTest { RelatedToPropertyItem relatedToPropertyItem = new RelatedToPropertyItem(); relatedToPropertyItem.propertyKey = "model.model-name"; relatedToPropertyItem.propertyValue = "service-instance"; - relatedToProperty.relatedTo.add(relatedToPropertyItem); + relatedToProperty.getRelatedTo().add(relatedToPropertyItem); RelatedToPropertyItem relatedToPropertyItem2 = new RelatedToPropertyItem(); relatedToPropertyItem2.propertyKey = "model.model-name2"; relatedToPropertyItem2.propertyValue = "service-instance2"; - relatedToProperty.relatedTo.add(relatedToPropertyItem2); + relatedToProperty.getRelatedTo().add(relatedToPropertyItem2); relationship.relatedToProperty = relatedToProperty; RelationshipDataItem relationshipDataItem = new RelationshipDataItem(); relationshipDataItem.relationshipKey = "relationship-key"; relationshipDataItem.relationshipValue = "relationship-value"; RelationshipData relationshipData = new RelationshipData(); - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); relationship.relationshipData = relationshipData; - relationshipList.relationshipList.add(relationship); + relationshipList.getRelationshipList().add(relationship); assertNotNull(relationshipList); logger.info(Serialization.gsonPretty.toJson(relationshipList)); diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java index 76d3f306b..ec55069ca 100644 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java @@ -48,17 +48,17 @@ public class RelationshipTest { RelatedToPropertyItem relatedToPropertyItem = new RelatedToPropertyItem(); relatedToPropertyItem.propertyKey = "model.model-name"; relatedToPropertyItem.propertyValue = "service-instance"; - relatedToProperty.relatedTo.add(relatedToPropertyItem); + relatedToProperty.getRelatedTo().add(relatedToPropertyItem); RelatedToPropertyItem relatedToPropertyItem2 = new RelatedToPropertyItem(); relatedToPropertyItem2.propertyKey = "model.model-name2"; relatedToPropertyItem2.propertyValue = "service-instance2"; - relatedToProperty.relatedTo.add(relatedToPropertyItem2); + relatedToProperty.getRelatedTo().add(relatedToPropertyItem2); relationship.relatedToProperty = relatedToProperty; RelationshipDataItem relationshipDataItem = new RelationshipDataItem(); relationshipDataItem.relationshipKey = "relationship-key"; relationshipDataItem.relationshipValue = "relationship-value"; RelationshipData relationshipData = new RelationshipData(); - relationshipData.relationshipData.add(relationshipDataItem); + relationshipData.getRelationshipData().add(relationshipDataItem); relationship.relationshipData = relationshipData; assertNotNull(relationship); logger.info(Serialization.gsonPretty.toJson(relationship)); diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java index 18c80eed3..5f5baf0bd 100644 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java +++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java @@ -48,475 +48,471 @@ import org.yaml.snakeyaml.DumperOptions.FlowStyle; import org.yaml.snakeyaml.Yaml; public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { - private static Logger logger = LoggerFactory.getLogger(ControlLoopPolicyBuilderImpl.class.getName()); - private ControlLoopPolicy policy; - - public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout) throws BuilderException { - policy = new ControlLoopPolicy(); - ControlLoop controlLoop = new ControlLoop(); - controlLoop.setControlLoopName(controlLoopName); - controlLoop.setTimeout(timeout); - policy.setControlLoop(controlLoop); - } - - public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout, Resource resource, Service... services) throws BuilderException { - this(controlLoopName, timeout); - this.addResource(resource); - this.addService(services); - } - - public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout, PNF pnf) throws BuilderException { - this(controlLoopName, timeout); - this.setPNF(pnf); - } - - public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout, Service service, Resource[] resources) throws BuilderException { - this(controlLoopName, timeout); - this.addService(service); - this.addResource(resources); - } - - @Override - public ControlLoopPolicyBuilder removePNF() throws BuilderException { - policy.getControlLoop().setPnf(null); - return this; - } - - @Override - public ControlLoopPolicyBuilder addService(Service... services) throws BuilderException { - if (services == null) { - throw new BuilderException("Service must not be null"); - } - for (Service service : services) { - if (service.getServiceUUID() == null) { - if (service.getServiceName() == null || service.getServiceName().length() < 1) { - throw new BuilderException("Invalid service - need either a serviceUUID or serviceName"); - } - if(policy.getControlLoop().getServices()==null){ - policy.getControlLoop().setServices(new LinkedList<>()); - } - policy.getControlLoop().getServices().add(service); - } - } - return this; - } - - @Override - public ControlLoopPolicyBuilder removeService(Service... services) throws BuilderException { - if (services == null) { - throw new BuilderException("Service must not be null"); - } - if (policy.getControlLoop().getServices() == null) { - throw new BuilderException("No existing services to remove"); - } - for (Service service : services) { - if (service.getServiceUUID() == null) { - if (service.getServiceName() == null || service.getServiceName().length() < 1) { - throw new BuilderException("Invalid service - need either a serviceUUID or serviceName"); - } - } - boolean removed = policy.getControlLoop().getServices().remove(service); - if (!removed) { - throw new BuilderException("Unknown service " + service.getServiceName()); - } - } - return this; - } - - @Override - public ControlLoopPolicyBuilder removeAllServices() throws BuilderException { - policy.getControlLoop().getServices().clear(); - return this; - } - - - @Override - public ControlLoopPolicyBuilder addResource(Resource... resources) throws BuilderException { - if (resources == null) { - throw new BuilderException("resources must not be null"); - } - for (Resource resource : resources) { - if (resource.getResourceUUID() == null) { - if (resource.getResourceName() == null || resource.getResourceName().length() <= 0) { - throw new BuilderException("Invalid resource - need either resourceUUID or resourceName"); - } - } - if(policy.getControlLoop().getResources()==null){ - policy.getControlLoop().setResources(new LinkedList<>()); - } - policy.getControlLoop().getResources().add(resource); - } - return this; - } - - @Override - public ControlLoopPolicyBuilder setPNF(PNF pnf) throws BuilderException { - if (pnf == null) { - throw new BuilderException("PNF must not be null"); - } - if (pnf.PNFName == null) { - if (pnf.PNFType == null) { - throw new BuilderException("Invalid PNF - need either pnfName or pnfType"); - } - } - policy.getControlLoop().setPnf(pnf); - return this; - } - - @Override - public ControlLoopPolicyBuilder setAbatement(Boolean abatement) throws BuilderException{ - if (abatement == null) { - throw new BuilderException("abatement must not be null"); - } - policy.getControlLoop().setAbatement(abatement); - return this; - } - - @Override - public ControlLoopPolicyBuilder setTimeout(Integer timeout) { - policy.getControlLoop().setTimeout(timeout); - return this; - } - - @Override - public Policy setTriggerPolicy(String name, String description, String actor, Target target, String recipe, - Map payload, Integer retries, Integer timeout) throws BuilderException { - - Policy trigger = new Policy(UUID.randomUUID().toString(), name, description, actor, payload, target, recipe, retries, timeout); - - policy.getControlLoop().setTrigger_policy(trigger.getId()); - - this.addNewPolicy(trigger); - // - // Return a copy of the policy - // - return new Policy(trigger); - } - - @Override - public Policy setPolicyForPolicyResult(String name, String description, String actor, - Target target, String recipe, Map payload, Integer retries, Integer timeout, String policyID, PolicyResult... results) throws BuilderException { - // - // Find the existing policy - // - Policy existingPolicy = this.findPolicy(policyID); - if (existingPolicy == null) { - throw new BuilderException("Unknown policy " + policyID); - } - // - // Create the new Policy - // - Policy newPolicy = new Policy(UUID.randomUUID().toString(), name, description, actor, payload, target, recipe, retries, timeout); - // - // Connect the results - // - for (PolicyResult result : results) { - switch (result) { - case FAILURE: - existingPolicy.setFailure(newPolicy.getId()); - break; - case FAILURE_EXCEPTION: - existingPolicy.setFailure_exception(newPolicy.getId()); - break; - case FAILURE_RETRIES: - existingPolicy.setFailure_retries(newPolicy.getId()); - break; - case FAILURE_TIMEOUT: - existingPolicy.setFailure_timeout(newPolicy.getId()); - break; - case FAILURE_GUARD: - existingPolicy.setFailure_guard(newPolicy.getId()); - break; - case SUCCESS: - existingPolicy.setSuccess(newPolicy.getId()); - break; - default: - throw new BuilderException("Invalid PolicyResult " + result); - } - } - // - // Add it to our list - // - this.policy.getPolicies().add(newPolicy); - // - // Return a policy to them - // - return new Policy(newPolicy); - } - - private class BuilderCompilerCallback implements ControlLoopCompilerCallback { - - private ResultsImpl results = new ResultsImpl(); - - @Override - public boolean onWarning(String message) { - results.addMessage(new MessageImpl(message, MessageLevel.WARNING)); - return false; - } - - @Override - public boolean onError(String message) { - results.addMessage(new MessageImpl(message, MessageLevel.ERROR)); - return false; - } - } - - @Override - public Results buildSpecification() { - // - // Dump the specification - // - DumperOptions options = new DumperOptions(); - options.setDefaultFlowStyle(FlowStyle.BLOCK); - options.setPrettyFlow(true); - Yaml yaml = new Yaml(options); - String dumpedYaml = yaml.dump(policy); - // - // This is our callback class for our compiler - // - BuilderCompilerCallback callback = new BuilderCompilerCallback(); - // - // Compile it - // - try { - ControlLoopCompiler.compile(policy, callback); - } catch (CompilerException e) { - logger.error(e.getMessage() + e); - callback.results.addMessage(new MessageImpl(e.getMessage(), MessageLevel.EXCEPTION)); - } - // - // Save the spec - // - callback.results.setSpecification(dumpedYaml); - return callback.results; - } - - private void addNewPolicy(Policy policy) { - if (this.policy.getPolicies() == null) { - this.policy.setPolicies(new LinkedList<>()); - } - this.policy.getPolicies().add(policy); - } - - private Policy findPolicy(String id) { - for (Policy policy : this.policy.getPolicies()) { - if (policy.getId().equals(id)) { - return policy; - } - } - return null; - } - - @Override - public ControlLoopPolicyBuilder removeResource(Resource... resources) throws BuilderException { - if (resources == null) { - throw new BuilderException("Resource must not be null"); - } - if (policy.getControlLoop().getResources() == null) { - throw new BuilderException("No existing resources to remove"); - } - for (Resource resource : resources) { - if (resource.getResourceUUID() == null) { - if (resource.getResourceName() == null || resource.getResourceName().length() < 1) { - throw new BuilderException("Invalid resource - need either a resourceUUID or resourceName"); - } - } - boolean removed = policy.getControlLoop().getResources().remove(resource); - if (!removed) { - throw new BuilderException("Unknown resource " + resource.getResourceName()); - } - } - return this; - } - - @Override - public ControlLoopPolicyBuilder removeAllResources() throws BuilderException { - policy.getControlLoop().getResources().clear(); - return this; - } - - @Override - public Integer calculateTimeout() { - int sum = 0; - for (Policy policy : this.policy.getPolicies()) { - sum += policy.getTimeout().intValue(); - } - return new Integer(sum); - } - - @Override - public ControlLoop setTriggerPolicy(String id) throws BuilderException { - if (id == null) { - throw new BuilderException("Id must not be null"); - } - Policy trigger = this.findPolicy(id); - if (trigger == null) { - throw new BuilderException("Unknown policy " + id); - } - else { - this.policy.getControlLoop().setTrigger_policy(id); - } - return new ControlLoop(this.policy.getControlLoop()); - } - - @Override - public boolean isOpenLoop() { - if (this.policy.getControlLoop().getTrigger_policy().equals(FinalResult.FINAL_OPENLOOP.toString())) { - return true; - } - else { - return false; - } - } - - @Override - public Policy getTriggerPolicy() throws BuilderException { - if (this.policy.getControlLoop().getTrigger_policy().equals(FinalResult.FINAL_OPENLOOP.toString())) { - return null; - } - else { - Policy trigger = new Policy(this.findPolicy(this.policy.getControlLoop().getTrigger_policy())); - return trigger; - } - } - - @Override - public ControlLoop getControlLoop() { - ControlLoop loop = new ControlLoop(this.policy.getControlLoop()); - return loop; - } - - @Override - public Policy setPolicyForPolicyResult(String policyResultID, String policyID, PolicyResult... results) - throws BuilderException { - // - // Find the existing policy - // - Policy existingPolicy = this.findPolicy(policyID); - if (existingPolicy == null) { - throw new BuilderException(policyID + " does not exist"); - } - if (this.findPolicy(policyResultID) == null) { - throw new BuilderException("Operational policy " + policyResultID + " does not exist"); - } - // - // Connect the results - // - for (PolicyResult result : results) { - switch (result) { - case FAILURE: - existingPolicy.setFailure(policyResultID); - break; - case FAILURE_EXCEPTION: - existingPolicy.setFailure_exception(policyResultID); - break; - case FAILURE_RETRIES: - existingPolicy.setFailure_retries(policyResultID); - break; - case FAILURE_TIMEOUT: - existingPolicy.setFailure_timeout(policyResultID); - break; - case FAILURE_GUARD: - existingPolicy.setFailure_guard(policyResultID); - break; - case SUCCESS: - existingPolicy.setSuccess(policyResultID); - break; - default: - throw new BuilderException("Invalid PolicyResult " + result); - } - } - return new Policy(this.findPolicy(policyResultID)); - } - - @Override - public boolean removePolicy(String policyID) throws BuilderException { - Policy existingPolicy = this.findPolicy(policyID); - if (existingPolicy == null) { - throw new BuilderException("Unknown policy " + policyID); - } - // - // Check if the policy to remove is trigger_policy - // - if (this.policy.getControlLoop().getTrigger_policy().equals(policyID)) { - this.policy.getControlLoop().setTrigger_policy(FinalResult.FINAL_OPENLOOP.toString()); - } - else { - // - // Update policies - // - for (Policy policy : this.policy.getPolicies()) { - int index = this.policy.getPolicies().indexOf(policy); - if (policy.getSuccess().equals(policyID)) { - policy.setSuccess(FinalResult.FINAL_SUCCESS.toString()); - } - if (policy.getFailure().equals(policyID)) { - policy.setFailure(FinalResult.FINAL_FAILURE.toString()); - } - if (policy.getFailure_retries().equals(policyID)) { - policy.setFailure_retries(FinalResult.FINAL_FAILURE_RETRIES.toString()); - } - if (policy.getFailure_timeout().equals(policyID)) { - policy.setFailure_timeout(FinalResult.FINAL_FAILURE_TIMEOUT.toString()); - } - if (policy.getFailure_exception().equals(policyID)) { - policy.setFailure_exception(FinalResult.FINAL_FAILURE_EXCEPTION.toString()); - } - if (policy.getFailure_guard().equals(policyID)) { - policy.setFailure_guard(FinalResult.FINAL_FAILURE_GUARD.toString()); - } - this.policy.getPolicies().set(index, policy); - } - } - // - // remove the policy - // - boolean removed = this.policy.getPolicies().remove(existingPolicy); - return removed; - } - - @Override - public Policy resetPolicyResults(String policyID) throws BuilderException { - Policy existingPolicy = this.findPolicy(policyID); - if (existingPolicy == null) { - throw new BuilderException("Unknown policy " + policyID); - } - // - // reset policy results - // - existingPolicy.setSuccess(FinalResult.FINAL_SUCCESS.toString()); - existingPolicy.setFailure(FinalResult.FINAL_FAILURE.toString()); - existingPolicy.setFailure_retries(FinalResult.FINAL_FAILURE_RETRIES.toString()); - existingPolicy.setFailure_timeout(FinalResult.FINAL_FAILURE_TIMEOUT.toString()); - existingPolicy.setFailure_exception(FinalResult.FINAL_FAILURE_EXCEPTION.toString()); - existingPolicy.setFailure_guard(FinalResult.FINAL_FAILURE_GUARD.toString()); - return new Policy(existingPolicy); - } - - @Override - public ControlLoopPolicyBuilder removeAllPolicies() { - // - // Remove all existing operational policies - // - this.policy.getPolicies().clear(); - // - // Revert controlLoop back to an open loop - // - this.policy.getControlLoop().setTrigger_policy(FinalResult.FINAL_OPENLOOP.toString()); - return this; - } - - @Override - public Policy addOperationsAccumulateParams(String policyID, OperationsAccumulateParams operationsAccumulateParams) throws BuilderException { - Policy existingPolicy = this.findPolicy(policyID); - if (existingPolicy == null) { - throw new BuilderException("Unknown policy " + policyID); - } - // - // Add operationsAccumulateParams to existingPolicy - // - existingPolicy.setOperationsAccumulateParams(operationsAccumulateParams); - return new Policy(existingPolicy); - } + private static Logger logger = LoggerFactory.getLogger(ControlLoopPolicyBuilderImpl.class.getName()); + private ControlLoopPolicy policy; + + public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout) throws BuilderException { + policy = new ControlLoopPolicy(); + ControlLoop controlLoop = new ControlLoop(); + controlLoop.setControlLoopName(controlLoopName); + controlLoop.setTimeout(timeout); + policy.setControlLoop(controlLoop); + } + + public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout, Resource resource, Service... services) throws BuilderException { + this(controlLoopName, timeout); + this.addResource(resource); + this.addService(services); + } + + public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout, PNF pnf) throws BuilderException { + this(controlLoopName, timeout); + this.setPNF(pnf); + } + + public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout, Service service, Resource[] resources) throws BuilderException { + this(controlLoopName, timeout); + this.addService(service); + this.addResource(resources); + } + + @Override + public ControlLoopPolicyBuilder removePNF() throws BuilderException { + policy.getControlLoop().setPnf(null); + return this; + } + + @Override + public ControlLoopPolicyBuilder addService(Service... services) throws BuilderException { + if (services == null) { + throw new BuilderException("Service must not be null"); + } + for (Service service : services) { + if (service.getServiceUUID() == null) { + if (service.getServiceName() == null || service.getServiceName().length() < 1) { + throw new BuilderException("Invalid service - need either a serviceUUID or serviceName"); + } + if(policy.getControlLoop().getServices()==null){ + policy.getControlLoop().setServices(new LinkedList<>()); + } + policy.getControlLoop().getServices().add(service); + } + } + return this; + } + + @Override + public ControlLoopPolicyBuilder removeService(Service... services) throws BuilderException { + if (services == null) { + throw new BuilderException("Service must not be null"); + } + if (policy.getControlLoop().getServices() == null) { + throw new BuilderException("No existing services to remove"); + } + for (Service service : services) { + if (service.getServiceUUID() == null) { + if (service.getServiceName() == null || service.getServiceName().length() < 1) { + throw new BuilderException("Invalid service - need either a serviceUUID or serviceName"); + } + } + boolean removed = policy.getControlLoop().getServices().remove(service); + if (!removed) { + throw new BuilderException("Unknown service " + service.getServiceName()); + } + } + return this; + } + + @Override + public ControlLoopPolicyBuilder removeAllServices() throws BuilderException { + policy.getControlLoop().getServices().clear(); + return this; + } + + + @Override + public ControlLoopPolicyBuilder addResource(Resource... resources) throws BuilderException { + if (resources == null) { + throw new BuilderException("resources must not be null"); + } + for (Resource resource : resources) { + if (resource.getResourceUUID() == null) { + if (resource.getResourceName() == null || resource.getResourceName().length() <= 0) { + throw new BuilderException("Invalid resource - need either resourceUUID or resourceName"); + } + } + if(policy.getControlLoop().getResources()==null){ + policy.getControlLoop().setResources(new LinkedList<>()); + } + policy.getControlLoop().getResources().add(resource); + } + return this; + } + + @Override + public ControlLoopPolicyBuilder setPNF(PNF pnf) throws BuilderException { + if (pnf == null) { + throw new BuilderException("PNF must not be null"); + } + if (pnf.getPNFName() == null && pnf.getPNFType() == null) { + throw new BuilderException("Invalid PNF - need either pnfName or pnfType"); + } + policy.getControlLoop().setPnf(pnf); + return this; + } + + @Override + public ControlLoopPolicyBuilder setAbatement(Boolean abatement) throws BuilderException{ + if (abatement == null) { + throw new BuilderException("abatement must not be null"); + } + policy.getControlLoop().setAbatement(abatement); + return this; + } + + @Override + public ControlLoopPolicyBuilder setTimeout(Integer timeout) { + policy.getControlLoop().setTimeout(timeout); + return this; + } + + @Override + public Policy setTriggerPolicy(String name, String description, String actor, Target target, String recipe, + Map payload, Integer retries, Integer timeout) throws BuilderException { + + Policy trigger = new Policy(UUID.randomUUID().toString(), name, description, actor, payload, target, recipe, retries, timeout); + + policy.getControlLoop().setTrigger_policy(trigger.getId()); + + this.addNewPolicy(trigger); + // + // Return a copy of the policy + // + return new Policy(trigger); + } + + @Override + public Policy setPolicyForPolicyResult(String name, String description, String actor, + Target target, String recipe, Map payload, Integer retries, Integer timeout, String policyID, PolicyResult... results) throws BuilderException { + // + // Find the existing policy + // + Policy existingPolicy = this.findPolicy(policyID); + if (existingPolicy == null) { + throw new BuilderException("Unknown policy " + policyID); + } + // + // Create the new Policy + // + Policy newPolicy = new Policy(UUID.randomUUID().toString(), name, description, actor, payload, target, recipe, retries, timeout); + // + // Connect the results + // + for (PolicyResult result : results) { + switch (result) { + case FAILURE: + existingPolicy.setFailure(newPolicy.getId()); + break; + case FAILURE_EXCEPTION: + existingPolicy.setFailure_exception(newPolicy.getId()); + break; + case FAILURE_RETRIES: + existingPolicy.setFailure_retries(newPolicy.getId()); + break; + case FAILURE_TIMEOUT: + existingPolicy.setFailure_timeout(newPolicy.getId()); + break; + case FAILURE_GUARD: + existingPolicy.setFailure_guard(newPolicy.getId()); + break; + case SUCCESS: + existingPolicy.setSuccess(newPolicy.getId()); + break; + default: + throw new BuilderException("Invalid PolicyResult " + result); + } + } + // + // Add it to our list + // + this.policy.getPolicies().add(newPolicy); + // + // Return a policy to them + // + return new Policy(newPolicy); + } + + private class BuilderCompilerCallback implements ControlLoopCompilerCallback { + + private ResultsImpl results = new ResultsImpl(); + + @Override + public boolean onWarning(String message) { + results.addMessage(new MessageImpl(message, MessageLevel.WARNING)); + return false; + } + + @Override + public boolean onError(String message) { + results.addMessage(new MessageImpl(message, MessageLevel.ERROR)); + return false; + } + } + + @Override + public Results buildSpecification() { + // + // Dump the specification + // + DumperOptions options = new DumperOptions(); + options.setDefaultFlowStyle(FlowStyle.BLOCK); + options.setPrettyFlow(true); + Yaml yaml = new Yaml(options); + String dumpedYaml = yaml.dump(policy); + // + // This is our callback class for our compiler + // + BuilderCompilerCallback callback = new BuilderCompilerCallback(); + // + // Compile it + // + try { + ControlLoopCompiler.compile(policy, callback); + } catch (CompilerException e) { + logger.error(e.getMessage() + e); + callback.results.addMessage(new MessageImpl(e.getMessage(), MessageLevel.EXCEPTION)); + } + // + // Save the spec + // + callback.results.setSpecification(dumpedYaml); + return callback.results; + } + + private void addNewPolicy(Policy policy) { + if (this.policy.getPolicies() == null) { + this.policy.setPolicies(new LinkedList<>()); + } + this.policy.getPolicies().add(policy); + } + + private Policy findPolicy(String id) { + for (Policy policy : this.policy.getPolicies()) { + if (policy.getId().equals(id)) { + return policy; + } + } + return null; + } + + @Override + public ControlLoopPolicyBuilder removeResource(Resource... resources) throws BuilderException { + if (resources == null) { + throw new BuilderException("Resource must not be null"); + } + if (policy.getControlLoop().getResources() == null) { + throw new BuilderException("No existing resources to remove"); + } + for (Resource resource : resources) { + if (resource.getResourceUUID() == null) { + if (resource.getResourceName() == null || resource.getResourceName().length() < 1) { + throw new BuilderException("Invalid resource - need either a resourceUUID or resourceName"); + } + } + boolean removed = policy.getControlLoop().getResources().remove(resource); + if (!removed) { + throw new BuilderException("Unknown resource " + resource.getResourceName()); + } + } + return this; + } + + @Override + public ControlLoopPolicyBuilder removeAllResources() throws BuilderException { + policy.getControlLoop().getResources().clear(); + return this; + } + + @Override + public Integer calculateTimeout() { + int sum = 0; + for (Policy policy : this.policy.getPolicies()) { + sum += policy.getTimeout().intValue(); + } + return new Integer(sum); + } + + @Override + public ControlLoop setTriggerPolicy(String id) throws BuilderException { + if (id == null) { + throw new BuilderException("Id must not be null"); + } + Policy trigger = this.findPolicy(id); + if (trigger == null) { + throw new BuilderException("Unknown policy " + id); + } + else { + this.policy.getControlLoop().setTrigger_policy(id); + } + return new ControlLoop(this.policy.getControlLoop()); + } + + @Override + public boolean isOpenLoop() { + if (this.policy.getControlLoop().getTrigger_policy().equals(FinalResult.FINAL_OPENLOOP.toString())) { + return true; + } + else { + return false; + } + } + + @Override + public Policy getTriggerPolicy() throws BuilderException { + if (this.policy.getControlLoop().getTrigger_policy().equals(FinalResult.FINAL_OPENLOOP.toString())) { + return null; + } + else { + return new Policy(this.findPolicy(this.policy.getControlLoop().getTrigger_policy())); + } + } + + @Override + public ControlLoop getControlLoop() { + return new ControlLoop(this.policy.getControlLoop()); + } + + @Override + public Policy setPolicyForPolicyResult(String policyResultID, String policyID, PolicyResult... results) + throws BuilderException { + // + // Find the existing policy + // + Policy existingPolicy = this.findPolicy(policyID); + if (existingPolicy == null) { + throw new BuilderException(policyID + " does not exist"); + } + if (this.findPolicy(policyResultID) == null) { + throw new BuilderException("Operational policy " + policyResultID + " does not exist"); + } + // + // Connect the results + // + for (PolicyResult result : results) { + switch (result) { + case FAILURE: + existingPolicy.setFailure(policyResultID); + break; + case FAILURE_EXCEPTION: + existingPolicy.setFailure_exception(policyResultID); + break; + case FAILURE_RETRIES: + existingPolicy.setFailure_retries(policyResultID); + break; + case FAILURE_TIMEOUT: + existingPolicy.setFailure_timeout(policyResultID); + break; + case FAILURE_GUARD: + existingPolicy.setFailure_guard(policyResultID); + break; + case SUCCESS: + existingPolicy.setSuccess(policyResultID); + break; + default: + throw new BuilderException("Invalid PolicyResult " + result); + } + } + return new Policy(this.findPolicy(policyResultID)); + } + + @Override + public boolean removePolicy(String policyID) throws BuilderException { + Policy existingPolicy = this.findPolicy(policyID); + if (existingPolicy == null) { + throw new BuilderException("Unknown policy " + policyID); + } + // + // Check if the policy to remove is trigger_policy + // + if (this.policy.getControlLoop().getTrigger_policy().equals(policyID)) { + this.policy.getControlLoop().setTrigger_policy(FinalResult.FINAL_OPENLOOP.toString()); + } + else { + // + // Update policies + // + for (Policy policy : this.policy.getPolicies()) { + int index = this.policy.getPolicies().indexOf(policy); + if (policy.getSuccess().equals(policyID)) { + policy.setSuccess(FinalResult.FINAL_SUCCESS.toString()); + } + if (policy.getFailure().equals(policyID)) { + policy.setFailure(FinalResult.FINAL_FAILURE.toString()); + } + if (policy.getFailure_retries().equals(policyID)) { + policy.setFailure_retries(FinalResult.FINAL_FAILURE_RETRIES.toString()); + } + if (policy.getFailure_timeout().equals(policyID)) { + policy.setFailure_timeout(FinalResult.FINAL_FAILURE_TIMEOUT.toString()); + } + if (policy.getFailure_exception().equals(policyID)) { + policy.setFailure_exception(FinalResult.FINAL_FAILURE_EXCEPTION.toString()); + } + if (policy.getFailure_guard().equals(policyID)) { + policy.setFailure_guard(FinalResult.FINAL_FAILURE_GUARD.toString()); + } + this.policy.getPolicies().set(index, policy); + } + } + // + // remove the policy + // + boolean removed = this.policy.getPolicies().remove(existingPolicy); + return removed; + } + + @Override + public Policy resetPolicyResults(String policyID) throws BuilderException { + Policy existingPolicy = this.findPolicy(policyID); + if (existingPolicy == null) { + throw new BuilderException("Unknown policy " + policyID); + } + // + // reset policy results + // + existingPolicy.setSuccess(FinalResult.FINAL_SUCCESS.toString()); + existingPolicy.setFailure(FinalResult.FINAL_FAILURE.toString()); + existingPolicy.setFailure_retries(FinalResult.FINAL_FAILURE_RETRIES.toString()); + existingPolicy.setFailure_timeout(FinalResult.FINAL_FAILURE_TIMEOUT.toString()); + existingPolicy.setFailure_exception(FinalResult.FINAL_FAILURE_EXCEPTION.toString()); + existingPolicy.setFailure_guard(FinalResult.FINAL_FAILURE_GUARD.toString()); + return new Policy(existingPolicy); + } + + @Override + public ControlLoopPolicyBuilder removeAllPolicies() { + // + // Remove all existing operational policies + // + this.policy.getPolicies().clear(); + // + // Revert controlLoop back to an open loop + // + this.policy.getControlLoop().setTrigger_policy(FinalResult.FINAL_OPENLOOP.toString()); + return this; + } + + @Override + public Policy addOperationsAccumulateParams(String policyID, OperationsAccumulateParams operationsAccumulateParams) throws BuilderException { + Policy existingPolicy = this.findPolicy(policyID); + if (existingPolicy == null) { + throw new BuilderException("Unknown policy " + policyID); + } + // + // Add operationsAccumulateParams to existingPolicy + // + existingPolicy.setOperationsAccumulateParams(operationsAccumulateParams); + return new Policy(existingPolicy); + } } diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java index 8c13db079..2f511f4bc 100644 --- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java +++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java @@ -52,9 +52,9 @@ public class AaiSimulatorJaxRs { { AAINQRequest request = Serialization.gsonPretty.fromJson(req, AAINQRequest.class); - if (request.instanceFilters.instanceFilter.get(0).containsKey("vserver")) + if (request.instanceFilters.getInstanceFilter().get(0).containsKey("vserver")) { - String vserverName = request.instanceFilters.instanceFilter.get(0).get("vserver").get("vserver-name"); + String vserverName = request.instanceFilters.getInstanceFilter().get(0).get("vserver").get("vserver-name"); if ("error".equals(vserverName)) { return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"POST Search\",\"getNamedQueryResponse\",\"Node Not Found:No Node of type vserver found for properties\",\"ERR.5.4.6114\"]}}}"; } @@ -66,7 +66,7 @@ public class AaiSimulatorJaxRs { } else { - String vnfID = request.instanceFilters.instanceFilter.get(0).get("generic-vnf").get("vnf-id"); + String vnfID = request.instanceFilters.getInstanceFilter().get(0).get("generic-vnf").get("vnf-id"); if ("error".equals(vnfID)) { return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"POST Search\",\"getNamedQueryResponse\",\"Node Not Found:No Node of type generic-vnf found for properties\",\"ERR.5.4.6114\"]}}}"; } 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 121a889f7..66c65ff82 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 @@ -84,13 +84,13 @@ public class AaiSimulatorTest { List>> tempInstanceFilter = new LinkedList<>(); tempInstanceFilter.add(tempOuterMap); AAINQInstanceFilters tempInstanceFilters = new AAINQInstanceFilters(); - tempInstanceFilters.instanceFilter = tempInstanceFilter; + tempInstanceFilters.setInstanceFilter(tempInstanceFilter); request.instanceFilters = tempInstanceFilters; AAINQResponse response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass", request, UUID.randomUUID()); assertNotNull(response); - assertNotNull(response.inventoryResponseItems); + assertNotNull(response.getInventoryResponseItems()); tempNamedQuery.namedQueryUUID = UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087"); tempQueryParameters.namedQuery = tempNamedQuery; @@ -102,12 +102,12 @@ public class AaiSimulatorTest { tempInstanceFilter = new LinkedList<>(); tempInstanceFilter.add(tempOuterMap); tempInstanceFilters = new AAINQInstanceFilters(); - tempInstanceFilters.instanceFilter = tempInstanceFilter; + tempInstanceFilters.setInstanceFilter(tempInstanceFilter); request.instanceFilters = tempInstanceFilters; response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass", request, UUID.randomUUID()); assertNotNull(response); - assertNotNull(response.inventoryResponseItems); + assertNotNull(response.getInventoryResponseItems()); } } -- cgit 1.2.3-korg