diff options
Diffstat (limited to 'models-interactions/model-impl/aai/src')
72 files changed, 6047 insertions, 0 deletions
diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetResponse.java new file mode 100644 index 000000000..89b15b9cb --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetResponse.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; + +public class AaiGetResponse implements Serializable { + private static final long serialVersionUID = 7311418432051756162L; + + @SerializedName("requestError") + private AaiNqRequestError requestError; + + public AaiNqRequestError getRequestError() { + return requestError; + } + + public void setRequestError(AaiNqRequestError requestError) { + this.requestError = requestError; + } + +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVnfResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVnfResponse.java new file mode 100644 index 000000000..666f68d64 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVnfResponse.java @@ -0,0 +1,151 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file excthe License at + * ept in compliance with the License. + * You may obtain a copy of + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; + +public class AaiGetVnfResponse extends AaiGetResponse implements Serializable { + + private static final long serialVersionUID = -6247505944905898871L; + + @SerializedName("vnf-id") + private String vnfId; + + @SerializedName("vnf-name") + private String vnfName; + + @SerializedName("vnf-type") + private String vnfType; + + @SerializedName("service-id") + private String serviceId; + + @SerializedName("orchestration-status") + private String orchestrationStatus; + + @SerializedName("in-maint") + private boolean inMaint; + + @SerializedName("is-closed-loop-disabled") + private boolean isClosedLoopDisabled; + + @SerializedName("model-invariant-id") + private String modelInvariantId; + + @SerializedName("prov-status") + private String provStatus; + + @SerializedName("resource-version") + private String resourceVersion; + + @SerializedName("relationship-list") + private RelationshipList relationshipList; + + public String getVnfId() { + return vnfId; + } + + public String getVnfName() { + return vnfName; + } + + public String getVnfType() { + return vnfType; + } + + public String getServiceId() { + return serviceId; + } + + public String getOrchestrationStatus() { + return orchestrationStatus; + } + + public boolean getInMaint() { + return inMaint; + } + + public boolean getIsClosedLoopDisabled() { + return isClosedLoopDisabled; + } + + public String getModelInvariantId() { + return modelInvariantId; + } + + public String getProvStatus() { + return provStatus; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public RelationshipList getRelationshipList() { + return relationshipList; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + + public void setOrchestrationStatus(String orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + + public void setInMaint(boolean inMaint) { + this.inMaint = inMaint; + } + + public void setIsClosedLoopDisabled(boolean isClosedLoopDisabled) { + this.isClosedLoopDisabled = isClosedLoopDisabled; + } + + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + public void setProvStatus(String provStatus) { + this.provStatus = provStatus; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + public void setRelationshipList(RelationshipList relationshipList) { + this.relationshipList = relationshipList; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVserverResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVserverResponse.java new file mode 100644 index 000000000..72adb9d02 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVserverResponse.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +public class AaiGetVserverResponse extends AaiGetResponse implements Serializable { + + private static final long serialVersionUID = -6247505944905898871L; + + @SerializedName("vserver") + private List<AaiNqVServer> vserver = new LinkedList<>(); + + public List<AaiNqVServer> getVserver() { + return vserver; + } + + public void setVserver(List<AaiNqVServer> vserver) { + this.vserver = vserver; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java new file mode 100644 index 000000000..bb772e6ca --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java @@ -0,0 +1,235 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.JsonSyntaxException; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.onap.policy.aai.util.Serialization; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.utils.NetLoggerUtil; +import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; +import org.onap.policy.rest.RestManager; +import org.onap.policy.rest.RestManager.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class handles communication towards and responses from A&AI for this module. + */ +public final class AaiManager { + + /** The Constant logger. */ + private static final Logger logger = LoggerFactory.getLogger(AaiManager.class); + + /** The rest manager. */ + // The REST manager used for processing REST calls for this AAI manager + private final RestManager restManager; + + /** + * Constructor, create the AAI manager with the specified REST manager. + * + * @param restManager the rest manager to use for REST calls + */ + public AaiManager(final RestManager restManager) { + this.restManager = restManager; + } + + /** + * Post a query to A&AI. + * + * @param url the A&AI URL + * @param username the user name for authentication + * @param password the password for authentication + * @param request the request to issue towards A&AI + * @param requestId the UUID of the request + * @return the response from A&AI + */ + public AaiNqResponse postQuery(String url, String username, String password, AaiNqRequest request, UUID requestId) { + + final Map<String, String> headers = createHeaders(requestId); + + url = url + "/aai/search/named-query"; + + logger.debug("RestManager.post before"); + String requestJson = Serialization.gsonPretty.toJson(request); + NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, requestJson); + Pair<Integer, String> 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); + return null; + } + + int httpResponseCode = httpDetails.first; + + logger.info(url); + logger.info("{}", httpResponseCode); + logger.info(httpDetails.second); + + if (httpDetails.second != null) { + return composeResponse(httpDetails, url, AaiNqResponse.class); + } + return null; + } + + /** + * Perform a GET request for a particular virtual server towards A&AI. + * + * @param urlGet the A&AI URL + * @param username the user name for authentication + * @param password the password for authentication + * @param requestId the UUID of the request + * @param key the key of the virtual server + * @return the response for the virtual server from A&AI + */ + public AaiGetVserverResponse getQueryByVserverName(String urlGet, String username, String password, UUID requestId, + String key) { + return getQuery(urlGet, username, password, requestId, key, AaiGetVserverResponse.class); + } + + /** + * Perform a GET request for a particular VNF by VNF ID towards A&AI. + * + * @param urlGet the A&AI URL + * @param username the user name for authentication + * @param password the password for authentication + * @param requestId the UUID of the request + * @param key the ID of the VNF + * @return the response for the virtual server from A&AI + */ + public AaiGetVnfResponse getQueryByVnfId(String urlGet, String username, String password, UUID requestId, + String key) { + return getQuery(urlGet, username, password, requestId, key, AaiGetVnfResponse.class); + } + + /** + * Perform a GET request for a particular VNF by VNF name towards A&AI. + * + * @param urlGet the A&AI URL + * @param username the user name for authentication + * @param password the password for authentication + * @param requestId the UUID of the request + * @param key the name of the VNF + * @return the response for the virtual server from A&AI + */ + public AaiGetVnfResponse getQueryByVnfName(String urlGet, String username, String password, UUID requestId, + String key) { + return getQuery(urlGet, username, password, requestId, key, AaiGetVnfResponse.class); + } + + /** + * Perform a GET query for a particular entity towards A&AI. + * + * @param <T> the generic type for the response + * @param urlGet the A&AI URL + * @param username the user name for authentication + * @param password the password for authentication + * @param requestId the UUID of the request + * @param key the name of the VNF + * @param classOfT the class of the response to return + * @return the response for the virtual server from A&AI + */ + private <T> T getQuery(final String url, final String username, final String password, final UUID requestId, + final String key, final Class<T> classOfResponse) { + + Map<String, String> headers = createHeaders(requestId); + + String urlGet = url + key; + + int attemptsLeft = 3; + + while (attemptsLeft-- > 0) { + NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|]", CommInfrastructure.REST, urlGet); + Pair<Integer, String> httpDetailsGet = restManager.get(urlGet, username, password, headers); + if (httpDetailsGet == null) { + logger.info("AAI GET Null Response to {}", urlGet); + return null; + } + + int httpResponseCode = httpDetailsGet.first; + + logger.info(urlGet); + logger.info("{}", httpResponseCode); + logger.info(httpDetailsGet.second); + + if (httpResponseCode == 200) { + T responseGet = composeResponse(httpDetailsGet, urlGet, classOfResponse); + if (responseGet != null) { + return responseGet; + } + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + + } + + return null; + } + + /** + * Create the headers for the HTTP request. + * + * @param requestId the request ID to insert in the headers + * @return the HTTP headers + */ + private Map<String, String> createHeaders(final UUID requestId) { + Map<String, String> headers = new HashMap<>(); + + headers.put("X-FromAppId", "POLICY"); + headers.put("X-TransactionId", requestId.toString()); + headers.put("Accept", "application/json"); + + return headers; + } + + /** + * This method uses Google's GSON to create a response object from a JSON string. + * + * @param <T> the generic type + * @param httpDetails the HTTP response + * @param url the URL from which the response came + * @param classOfResponse The response class + * @return an instance of the response class + * @throws JsonSyntaxException on GSON errors instantiating the response + */ + private <T> T composeResponse(final Pair<Integer, String> httpDetails, final String url, + final Class<T> classOfResponse) { + try { + T response = Serialization.gsonPretty.fromJson(httpDetails.second, classOfResponse); + NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, url, httpDetails.second); + return response; + } catch (JsonSyntaxException e) { + logger.error("postQuery threw: ", e); + return null; + } + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqCloudRegion.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqCloudRegion.java new file mode 100644 index 000000000..ad910dcf3 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqCloudRegion.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class AaiNqCloudRegion implements Serializable { + + private static final long serialVersionUID = -897231529157222683L; + + @SerializedName("cloud-owner") + private String cloudOwner; + + @SerializedName("cloud-region-id") + private String cloudRegionId; + + @SerializedName("cloud-region-version") + private String cloudRegionVersion; + + @SerializedName("complex-name") + private String complexName; + + @SerializedName("resource-version") + private String resourceVersion; + + public String getCloudOwner() { + return cloudOwner; + } + + public String getCloudRegionId() { + return cloudRegionId; + } + + public String getCloudRegionVersion() { + return cloudRegionVersion; + } + + public String getComplexName() { + return complexName; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public void setCloudOwner(String cloudOwner) { + this.cloudOwner = cloudOwner; + } + + public void setCloudRegionId(String cloudRegionId) { + this.cloudRegionId = cloudRegionId; + } + + public void setCloudRegionVersion(String cloudRegionVersion) { + this.cloudRegionVersion = cloudRegionVersion; + } + + public void setComplexName(String complexName) { + this.complexName = complexName; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperties.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperties.java new file mode 100644 index 000000000..c3139a342 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperties.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +public class AaiNqExtraProperties implements Serializable { + private static final long serialVersionUID = 4109625574744702319L; + + @SerializedName("extra-property") + private List<AaiNqExtraProperty> extraProperty = new LinkedList<>(); + + public List<AaiNqExtraProperty> getExtraProperty() { + return extraProperty; + } + + public void setExtraProperty(List<AaiNqExtraProperty> extraProperty) { + this.extraProperty = extraProperty; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperty.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperty.java new file mode 100644 index 000000000..045e8fac9 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperty.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class AaiNqExtraProperty implements Serializable { + + private static final long serialVersionUID = -3861240617222397736L; + + @SerializedName("property-name") + private String propertyName; + + @SerializedName("property-value") + private String propertyValue; + + public AaiNqExtraProperty() {} + + public AaiNqExtraProperty(String propertyName, String propertyValue) { + this.propertyName = propertyName; + this.propertyValue = propertyValue; + } + + public String getPropertyName() { + return propertyName; + } + + public String getPropertyValue() { + return propertyValue; + } + + public void setPropertyName(String propertyName) { + this.propertyName = propertyName; + } + + public void setPropertyValue(String propertyValue) { + this.propertyValue = propertyValue; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqGenericVnf.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqGenericVnf.java new file mode 100644 index 000000000..d67d02443 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqGenericVnf.java @@ -0,0 +1,228 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; + +public class AaiNqGenericVnf implements Serializable { + + private static final long serialVersionUID = 834322706248060560L; + + @SerializedName("vnf-id") + private String vnfId; + + @SerializedName("vnf-name") + private String vnfName; + + @SerializedName("vnf-name2") + private String vnfName2; + + @SerializedName("vnf-type") + private String vnfType; + + @SerializedName("service-id") + private String serviceId; + + @SerializedName("prov-status") + private String provStatus; + + @SerializedName("operational-state") + private String operationalState; + + @SerializedName("ipv4-oam-address") + private String ipv4OamAddress; + + @SerializedName("ipv4-loopback0-address") + private String ipv4Loopback0Address; + + @SerializedName("in-maint") + private Boolean inMaint; + + @SerializedName("is-closed-loop-disabled") + private Boolean isClosedLoopDisabled; + + @SerializedName("resource-version") + private String resourceVersion; + + @SerializedName("encrypted-access-flag") + private Boolean encrypedAccessFlag; + + @SerializedName("persona-model-id") + private String personaModelId; + + @SerializedName("persona-model-version") + private String personaModelVersion; + + @SerializedName("model-invariant-id") + private String modelInvariantId; + + @SerializedName("model-version-id") + private String modelVersionId; + + @SerializedName("model-customization-id") + private String modelCustomizationId = null; + + public String getVnfId() { + return vnfId; + } + + public String getVnfName() { + return vnfName; + } + + public String getVnfName2() { + return vnfName2; + } + + public String getVnfType() { + return vnfType; + } + + public String getServiceId() { + return serviceId; + } + + public String getProvStatus() { + return provStatus; + } + + public String getOperationalState() { + return operationalState; + } + + public String getIpv4OamAddress() { + return ipv4OamAddress; + } + + public String getIpv4Loopback0Address() { + return ipv4Loopback0Address; + } + + public Boolean getInMaint() { + return inMaint; + } + + public Boolean getIsClosedLoopDisabled() { + return isClosedLoopDisabled; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public Boolean getEncrypedAccessFlag() { + return encrypedAccessFlag; + } + + public String getPersonaModelId() { + return personaModelId; + } + + public String getPersonaModelVersion() { + return personaModelVersion; + } + + public String getModelInvariantId() { + return modelInvariantId; + } + + public String getModelVersionId() { + return modelVersionId; + } + + public String getModelCustomizationId() { + return modelCustomizationId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public void setVnfName2(String vnfName2) { + this.vnfName2 = vnfName2; + } + + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + + public void setProvStatus(String provStatus) { + this.provStatus = provStatus; + } + + public void setOperationalState(String operationalState) { + this.operationalState = operationalState; + } + + public void setIpv4OamAddress(String ipv4OamAddress) { + this.ipv4OamAddress = ipv4OamAddress; + } + + public void setIpv4Loopback0Address(String ipv4Loopback0Address) { + this.ipv4Loopback0Address = ipv4Loopback0Address; + } + + public void setInMaint(Boolean inMaint) { + this.inMaint = inMaint; + } + + public void setIsClosedLoopDisabled(Boolean isClosedLoopDisabled) { + this.isClosedLoopDisabled = isClosedLoopDisabled; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + public void setEncrypedAccessFlag(Boolean encrypedAccessFlag) { + this.encrypedAccessFlag = encrypedAccessFlag; + } + + public void setPersonaModelId(String personaModelId) { + this.personaModelId = personaModelId; + } + + public void setPersonaModelVersion(String personaModelVersion) { + this.personaModelVersion = personaModelVersion; + } + + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + + public void setModelCustomizationId(String modelCustomizationId) { + this.modelCustomizationId = modelCustomizationId; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInstanceFilters.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInstanceFilters.java new file mode 100644 index 000000000..8719f6ff2 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInstanceFilters.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +public class AaiNqInstanceFilters implements Serializable { + + private static final long serialVersionUID = 8993824591338121185L; + + @SerializedName("instance-filter") + private List<Map<String, Map<String, String>>> instanceFilter = new LinkedList<>(); + + public List<Map<String, Map<String, String>>> getInstanceFilter() { + return instanceFilter; + } + + public void setInstanceFilter(List<Map<String, Map<String, String>>> instanceFilter) { + this.instanceFilter = instanceFilter; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItem.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItem.java new file mode 100644 index 000000000..4ba9091fb --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItem.java @@ -0,0 +1,130 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class AaiNqInventoryResponseItem implements Serializable { + + private static final long serialVersionUID = 7142072567154675183L; + + @SerializedName("model-name") + private String modelName; + + @SerializedName("vf-module") + private AaiNqVfModule vfModule; + + @SerializedName("service-instance") + private AaiNqServiceInstance serviceInstance; + + @SerializedName("vserver") + private AaiNqVServer vserver; + + @SerializedName("tenant") + private AaiNqTenant tenant; + + @SerializedName("cloud-region") + private AaiNqCloudRegion cloudRegion; + + @SerializedName("generic-vnf") + private AaiNqGenericVnf genericVnf; + + @SerializedName("extra-properties") + private AaiNqExtraProperties extraProperties; + + @SerializedName("inventory-response-items") + private AaiNqInventoryResponseItems items; + + public String getModelName() { + return modelName; + } + + public AaiNqVfModule getVfModule() { + return vfModule; + } + + public AaiNqServiceInstance getServiceInstance() { + return serviceInstance; + } + + public AaiNqVServer getVserver() { + return vserver; + } + + public AaiNqTenant getTenant() { + return tenant; + } + + public AaiNqCloudRegion getCloudRegion() { + return cloudRegion; + } + + public AaiNqGenericVnf getGenericVnf() { + return genericVnf; + } + + public AaiNqExtraProperties getExtraProperties() { + return extraProperties; + } + + public AaiNqInventoryResponseItems getItems() { + return items; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public void setVfModule(AaiNqVfModule vfModule) { + this.vfModule = vfModule; + } + + public void setServiceInstance(AaiNqServiceInstance serviceInstance) { + this.serviceInstance = serviceInstance; + } + + public void setVserver(AaiNqVServer vserver) { + this.vserver = vserver; + } + + public void setTenant(AaiNqTenant tenant) { + this.tenant = tenant; + } + + public void setCloudRegion(AaiNqCloudRegion cloudRegion) { + this.cloudRegion = cloudRegion; + } + + public void setGenericVnf(AaiNqGenericVnf genericVnf) { + this.genericVnf = genericVnf; + } + + public void setExtraProperties(AaiNqExtraProperties extraProperties) { + this.extraProperties = extraProperties; + } + + public void setItems(AaiNqInventoryResponseItems items) { + this.items = items; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItems.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItems.java new file mode 100644 index 000000000..7d2a07787 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItems.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +public class AaiNqInventoryResponseItems implements Serializable { + private static final long serialVersionUID = 7602807659381179004L; + + @SerializedName("inventory-response-item") + private List<AaiNqInventoryResponseItem> inventoryResponseItems = new LinkedList<>(); + + public List<AaiNqInventoryResponseItem> getInventoryResponseItems() { + return inventoryResponseItems; + } + + public void setInventoryResponseItems(List<AaiNqInventoryResponseItem> inventoryResponseItems) { + this.inventoryResponseItems = inventoryResponseItems; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqNamedQuery.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqNamedQuery.java new file mode 100644 index 000000000..fc6442847 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqNamedQuery.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.UUID; + +public class AaiNqNamedQuery implements Serializable { + private static final long serialVersionUID = -3277980060302645333L; + + @SerializedName("named-query-uuid") + private UUID namedQueryUuid; + + public UUID getNamedQueryUuid() { + return namedQueryUuid; + } + + public void setNamedQueryUuid(UUID namedQueryUuid) { + this.namedQueryUuid = namedQueryUuid; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqQueryParameters.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqQueryParameters.java new file mode 100644 index 000000000..9173fcdd5 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqQueryParameters.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class AaiNqQueryParameters implements Serializable { + private static final long serialVersionUID = -4291227193197126982L; + + @SerializedName("named-query") + private AaiNqNamedQuery namedQuery; + + public AaiNqNamedQuery getNamedQuery() { + return namedQuery; + } + + public void setNamedQuery(AaiNqNamedQuery namedQuery) { + this.namedQuery = namedQuery; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequest.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequest.java new file mode 100644 index 000000000..643754f9d --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequest.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class AaiNqRequest implements Serializable { + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("query-parameters") + private AaiNqQueryParameters queryParameters; + + @SerializedName("instance-filters") + private AaiNqInstanceFilters instanceFilters; + + public AaiNqQueryParameters getQueryParameters() { + return queryParameters; + } + + public AaiNqInstanceFilters getInstanceFilters() { + return instanceFilters; + } + + public void setQueryParameters(AaiNqQueryParameters queryParameters) { + this.queryParameters = queryParameters; + } + + public void setInstanceFilters(AaiNqInstanceFilters instanceFilters) { + this.instanceFilters = instanceFilters; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequestError.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequestError.java new file mode 100644 index 000000000..6ae437232 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequestError.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class AaiNqRequestError implements Serializable { + private static final long serialVersionUID = -7742674155387022932L; + + @SerializedName("serviceException") + private AaiNqServiceExcept serviceExcept; + + public AaiNqServiceExcept getServiceExcept() { + return serviceExcept; + } + + public void setServiceExcept(AaiNqServiceExcept serviceExcept) { + this.serviceExcept = serviceExcept; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponse.java new file mode 100644 index 000000000..b823ceafb --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponse.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +public class AaiNqResponse implements Serializable { + private static final long serialVersionUID = 8411407444051746101L; + + @SerializedName("inventory-response-item") + private List<AaiNqInventoryResponseItem> inventoryResponseItems = new LinkedList<>(); + + @SerializedName("requestError") + private AaiNqRequestError requestError; + + public List<AaiNqInventoryResponseItem> getInventoryResponseItems() { + return inventoryResponseItems; + } + + public AaiNqRequestError getRequestError() { + return requestError; + } + + public void setRequestError(AaiNqRequestError requestError) { + this.requestError = requestError; + } + + public void setInventoryResponseItems(List<AaiNqInventoryResponseItem> inventoryResponseItems) { + this.inventoryResponseItems = inventoryResponseItems; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java new file mode 100644 index 000000000..68d07270a --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java @@ -0,0 +1,153 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AaiNqResponseWrapper implements Serializable { + private static final long serialVersionUID = 8411407444051746101L; + + private static final Logger logger = LoggerFactory.getLogger(AaiNqResponseWrapper.class); + + private static final Pattern VF_MODULE_NAME_PAT = Pattern.compile("(.*_)(\\d+)"); + + 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; + } + + /** + * Counts the number of VF modules, if any, in the response. + * + * @return the number of VF modules, or {@code 0} if there are none + */ + public int countVfModules() { + return getVfModuleItems(false).size(); + } + + /** + * Generates the name for the next VF module. + * + * @return the name of the next VF module, or {@code null} if the name could not be + * generated (i.e., because the response has no matching VF module names on + * which to model it) + */ + public String genVfModuleName() { + /* + * Loop through the VF modules, extracting the name prefix and the largest number + * suffix + */ + String prefix = null; + int maxSuffix = -1; + + for (AaiNqInventoryResponseItem item : getVfModuleItems(false)) { + String name = item.getVfModule().getVfModuleName(); + Matcher matcher = VF_MODULE_NAME_PAT.matcher(name); + if (matcher.matches()) { + int suffix = Integer.parseInt(matcher.group(2)); + if (suffix > maxSuffix) { + maxSuffix = suffix; + prefix = matcher.group(1); + } + } + } + + ++maxSuffix; + + return (prefix == null ? null : prefix + maxSuffix); + } + + /** + * Gets a list of VF modules. If the non-base VF modules are requested, then only + * those whose names match the name pattern, {@link #VF_MODULE_NAME_PAT}, are + * returned. + * + * @param wantBaseModule {@code true} if the the base VF module(s) is desired, + * {@code false} otherwise + * @return the list of VF module items + */ + public List<AaiNqInventoryResponseItem> getVfModuleItems(boolean wantBaseModule) { + // get the list of items + List<AaiNqInventoryResponseItem> itemList; + try { + itemList = aaiNqResponse.getInventoryResponseItems().get(0).getItems().getInventoryResponseItems().get(0) + .getItems().getInventoryResponseItems(); + + } catch (NullPointerException | IndexOutOfBoundsException e) { + logger.debug("no VF modules in AAI response", e); + return Collections.emptyList(); + } + + if (itemList == null) { + return Collections.emptyList(); + } + + /* + * Walk the items looking for VF modules, allocating the list only when an item is + * found. + */ + List<AaiNqInventoryResponseItem> vfModuleItems = new ArrayList<>(itemList.size()); + + for (AaiNqInventoryResponseItem inventoryResponseItem : itemList) { + AaiNqVfModule vfmod = inventoryResponseItem.getVfModule(); + if (vfmod == null) { + continue; + } + + if (vfmod.getIsBaseVfModule() == wantBaseModule + && (wantBaseModule || VF_MODULE_NAME_PAT.matcher(vfmod.getVfModuleName()).matches())) { + vfModuleItems.add(inventoryResponseItem); + } + } + + return vfModuleItems; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceExcept.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceExcept.java new file mode 100644 index 000000000..7b6c50257 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceExcept.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class AaiNqServiceExcept implements Serializable { + private static final long serialVersionUID = 2858343404484338546L; + + @SerializedName("messageId") + private String messageId; + + @SerializedName("text") + private String text; + + @SerializedName("variables") + private String[] variables; + + public String getMessageId() { + return messageId; + } + + public String getText() { + return text; + } + + public String[] getVariables() { + return variables; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceInstance.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceInstance.java new file mode 100644 index 000000000..2f48ad85d --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceInstance.java @@ -0,0 +1,118 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class AaiNqServiceInstance implements Serializable { + private static final long serialVersionUID = -8000944396593889586L; + + @SerializedName("service-instance-id") + private String serviceInstanceId; + + @SerializedName("service-instance-name") + private String serviceInstanceName; + + @SerializedName("persona-model-id") + private String personaModelId; + + @SerializedName("persona-model-version") + private String personaModelVersion; + + @SerializedName("service-instance-location-id") + private String serviceInstanceLocationId; + + @SerializedName("resource-version") + private String resourceVersion; + + @SerializedName("model-invariant-id") + private String modelInvariantId; + + @SerializedName("model-version-id") + private String modelVersionId; + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public String getServiceInstanceName() { + return serviceInstanceName; + } + + public String getPersonaModelId() { + return personaModelId; + } + + public String getPersonaModelVersion() { + return personaModelVersion; + } + + public String getServiceInstanceLocationId() { + return serviceInstanceLocationId; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public String getModelInvariantId() { + return modelInvariantId; + } + + public String getModelVersionId() { + return modelVersionId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public void setServiceInstanceName(String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + } + + public void setPersonaModelId(String personaModelId) { + this.personaModelId = personaModelId; + } + + public void setPersonaModelVersion(String personaModelVersion) { + this.personaModelVersion = personaModelVersion; + } + + public void setServiceInstanceLocationId(String serviceInstanceLocationId) { + this.serviceInstanceLocationId = serviceInstanceLocationId; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqTenant.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqTenant.java new file mode 100644 index 000000000..129c05933 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqTenant.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class AaiNqTenant implements Serializable { + private static final long serialVersionUID = 4702784101671984364L; + + @SerializedName("tenant-id") + private String tenantId; + + @SerializedName("tenant-name") + private String tenantName; + + @SerializedName("resource-version") + private String resourceVersion; + + public String getTenantId() { + return tenantId; + } + + public String getTenantName() { + return tenantName; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVServer.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVServer.java new file mode 100644 index 000000000..a7286ce8a --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVServer.java @@ -0,0 +1,130 @@ +/* + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class AaiNqVServer implements Serializable { + private static final long serialVersionUID = -6718526692734215643L; + + @SerializedName("vserver-id") + private String vserverId; + + @SerializedName("vserver-name") + private String vserverName; + + @SerializedName("vserver-name2") + private String vserverName2; + + @SerializedName("prov-status") + private String provStatus; + + @SerializedName("vserver-selflink") + private String vserverSelflink; + + @SerializedName("in-maint") + private Boolean inMaint; + + @SerializedName("is-closed-loop-disabled") + private Boolean isClosedLoopDisabled; + + @SerializedName("resource-version") + private String resourceVersion; + + @SerializedName("relationship-list") + private RelationshipList relationshipList; + + public String getVserverId() { + return vserverId; + } + + public String getVserverName() { + return vserverName; + } + + public String getVserverName2() { + return vserverName2; + } + + public String getProvStatus() { + return provStatus; + } + + public String getVserverSelflink() { + return vserverSelflink; + } + + public Boolean getInMaint() { + return inMaint; + } + + public Boolean getIsClosedLoopDisabled() { + return isClosedLoopDisabled; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public RelationshipList getRelationshipList() { + return relationshipList; + } + + public void setVserverId(String vserverId) { + this.vserverId = vserverId; + } + + public void setVserverName(String vserverName) { + this.vserverName = vserverName; + } + + public void setVserverName2(String vserverName2) { + this.vserverName2 = vserverName2; + } + + public void setProvStatus(String provStatus) { + this.provStatus = provStatus; + } + + public void setVserverSelflink(String vserverSelflink) { + this.vserverSelflink = vserverSelflink; + } + + public void setInMaint(Boolean inMaint) { + this.inMaint = inMaint; + } + + public void setIsClosedLoopDisabled(Boolean isClosedLoopDisabled) { + this.isClosedLoopDisabled = isClosedLoopDisabled; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + public void setRelationshipList(RelationshipList relationshipList) { + this.relationshipList = relationshipList; + } + +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVfModule.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVfModule.java new file mode 100644 index 000000000..9080c486e --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVfModule.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; + +public class AaiNqVfModule implements Serializable { + private static final long serialVersionUID = 8019133081429638232L; + + @SerializedName("vf-module-id") + private String vfModuleId; + + @SerializedName("vf-module-name") + private String vfModuleName; + + @SerializedName("heat-stack-id") + private String heatStackId; + + @SerializedName("orchestration-status") + private String orchestrationStatus; + + @SerializedName("is-base-vf-module") + private Boolean isBaseVfModule; + + @SerializedName("resource-version") + private String resourceVersion; + + @SerializedName("persona-model-id") + private String personaModelId; + + @SerializedName("persona-model-version") + private String personaModelVersion; + + @SerializedName("widget-model-id") + private String widgetModelId; + + @SerializedName("widget-model-version") + private String widgetModelVersion; + + @SerializedName("contrail-service-instance-fqdn") + private String contrailServiceInstanceFqdn; + + @SerializedName("model-invariant-id") + private String modelInvariantId; + + @SerializedName("model-version-id") + private String modelVersionId; + + @SerializedName("model-customization-id") + private String modelCustomizationId = null; + + public String getVfModuleId() { + return vfModuleId; + } + + public String getVfModuleName() { + return vfModuleName; + } + + public String getHeatStackId() { + return heatStackId; + } + + public String getOrchestrationStatus() { + return orchestrationStatus; + } + + public Boolean getIsBaseVfModule() { + return isBaseVfModule; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public String getPersonaModelId() { + return personaModelId; + } + + public String getPersonaModelVersion() { + return personaModelVersion; + } + + public String getWidgetModelId() { + return widgetModelId; + } + + public String getWidgetModelVersion() { + return widgetModelVersion; + } + + public String getContrailServiceInstanceFqdn() { + return contrailServiceInstanceFqdn; + } + + public String getModelInvariantId() { + return modelInvariantId; + } + + public String getModelVersionId() { + return modelVersionId; + } + + public String getModelCustomizationId() { + return modelCustomizationId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public void setVfModuleName(String vfModuleName) { + this.vfModuleName = vfModuleName; + } + + public void setHeatStackId(String heatStackId) { + this.heatStackId = heatStackId; + } + + public void setOrchestrationStatus(String orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + + public void setIsBaseVfModule(Boolean isBaseVfModule) { + this.isBaseVfModule = isBaseVfModule; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + public void setPersonaModelId(String personaModelId) { + this.personaModelId = personaModelId; + } + + public void setPersonaModelVersion(String personaModelVersion) { + this.personaModelVersion = personaModelVersion; + } + + public void setWidgetModelId(String widgetModelId) { + this.widgetModelId = widgetModelId; + } + + public void setWidgetModelVersion(String widgetModelVersion) { + this.widgetModelVersion = widgetModelVersion; + } + + public void setContrailServiceInstanceFqdn(String contrailServiceInstanceFqdn) { + this.contrailServiceInstanceFqdn = contrailServiceInstanceFqdn; + } + + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + + public void setModelCustomizationId(String modelCustomizationId) { + this.modelCustomizationId = modelCustomizationId; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/Pnf.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/Pnf.java new file mode 100644 index 000000000..f992d886d --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/Pnf.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; + +public class Pnf implements Serializable { + private static final long serialVersionUID = -3535108358668248501L; + + private String pnfName; + private PnfType pnfType; + + public Pnf() { + + } + + public Pnf(Pnf pnf) { + this.pnfName = pnf.pnfName; + this.pnfType = pnf.pnfType; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + public PnfType getPnfType() { + return pnfType; + } + + public void setPnfType(PnfType pnfType) { + this.pnfType = pnfType; + } + + @Override + public String toString() { + 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()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Pnf other = (Pnf) obj; + if (pnfName == null) { + if (other.pnfName != null) { + return false; + } + } else if (!pnfName.equals(other.pnfName)) { + return false; + } + return pnfType == other.pnfType; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/PnfInstance.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/PnfInstance.java new file mode 100644 index 000000000..1a9d75efa --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/PnfInstance.java @@ -0,0 +1,138 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; + +public class PnfInstance implements Serializable { + + private static final long serialVersionUID = -3694152433472165034L; + + private String pnfName; + private String pnfInstanceName; + private PnfType pnfType; + private String pnfSerial; + + public PnfInstance() { + + } + + /** + * Create an instance from a given instance. + * + * @param instance the instance + */ + public PnfInstance(PnfInstance instance) { + if (instance == null) { + return; + } + 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) { + this.pnfName = pnfName; + } + + public String getPnfInstanceName() { + return pnfInstanceName; + } + + public void setPnfInstanceName(String pnfInstanceName) { + this.pnfInstanceName = pnfInstanceName; + } + + public PnfType getPnfType() { + return pnfType; + } + + public void setPnfType(PnfType pnfType) { + this.pnfType = pnfType; + } + + public String getPnfSerial() { + return pnfSerial; + } + + public void setPnfSerial(String pnfSerial) { + this.pnfSerial = pnfSerial; + } + + @Override + public String toString() { + 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()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + PnfInstance other = (PnfInstance) obj; + if (pnfInstanceName == null) { + if (other.pnfInstanceName != null) { + return false; + } + } else if (!pnfInstanceName.equals(other.pnfInstanceName)) { + return false; + } + if (pnfName == null) { + if (other.pnfName != null) { + return false; + } + } else if (!pnfName.equals(other.pnfName)) { + return false; + } + if (pnfSerial == null) { + if (other.pnfSerial != null) { + return false; + } + } else if (!pnfSerial.equals(other.pnfSerial)) { + return false; + } + return pnfType == other.pnfType; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/PnfType.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/PnfType.java new file mode 100644 index 000000000..1e2484441 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/PnfType.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +public enum PnfType { + ENODEB("eNodeB"), PSERVER("pserver"); + + private String type; + + private PnfType(String type) { + this.type = type; + } + + @Override + public String toString() { + return this.type; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java new file mode 100644 index 000000000..34f82e803 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java @@ -0,0 +1,51 @@ +/* + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class RelatedToProperty implements Serializable { + private static final long serialVersionUID = 5644372985092588638L; + + @SerializedName("property-key") + private String propertyKey; + @SerializedName("property-value") + private String propertyValue; + + public String getPropertyKey() { + return propertyKey; + } + + public String getPropertyValue() { + return propertyValue; + } + + public void setPropertyKey(String propertyKey) { + this.propertyKey = propertyKey; + } + + public void setPropertyValue(String propertyValue) { + this.propertyValue = propertyValue; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java new file mode 100644 index 000000000..d9c55cc30 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java @@ -0,0 +1,76 @@ +/* + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +public class Relationship implements Serializable { + private static final long serialVersionUID = -68508443869003055L; + + @SerializedName("related-to") + private String relatedTo; + + @SerializedName("related-link") + private String relatedLink; + + @SerializedName("relationship-data") + private List<RelationshipData> relationshipData = new LinkedList<>(); + + @SerializedName("related-to-property") + private List<RelatedToProperty> relatedToProperty = new LinkedList<>(); + + public String getRelatedTo() { + return relatedTo; + } + + public String getRelatedLink() { + return relatedLink; + } + + public List<RelationshipData> getRelationshipData() { + return relationshipData; + } + + public List<RelatedToProperty> getRelatedToProperty() { + return relatedToProperty; + } + + public void setRelatedTo(String relatedTo) { + this.relatedTo = relatedTo; + } + + public void setRelatedLink(String relatedLink) { + this.relatedLink = relatedLink; + } + + public void setRelationshipData(List<RelationshipData> relationshipData) { + this.relationshipData = relationshipData; + } + + public void setRelatedToProperty(List<RelatedToProperty> relatedToProperty) { + this.relatedToProperty = relatedToProperty; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java new file mode 100644 index 000000000..fc6b65f6c --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java @@ -0,0 +1,51 @@ +/* + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class RelationshipData implements Serializable { + private static final long serialVersionUID = 550450041634939768L; + + @SerializedName("relationship-key") + private String relationshipKey; + @SerializedName("relationship-value") + private String relationshipValue; + + public String getRelationshipKey() { + return relationshipKey; + } + + public String getRelationshipValue() { + return relationshipValue; + } + + public void setRelationshipKey(String relationshipKey) { + this.relationshipKey = relationshipKey; + } + + public void setRelationshipValue(String relationshipValue) { + this.relationshipValue = relationshipValue; + } +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java new file mode 100644 index 000000000..0215e1601 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java @@ -0,0 +1,45 @@ +/* + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +public class RelationshipList implements Serializable { + private static final long serialVersionUID = 6115655704973981990L; + + @SerializedName("relationship") + private List<Relationship> relationships = new LinkedList<>(); + + public List<Relationship> getRelationships() { + return relationships; + } + + public void setRelationships(List<Relationship> relationships) { + this.relationships = relationships; + } + + +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/AaiException.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/AaiException.java new file mode 100644 index 000000000..ef7c017df --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/AaiException.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai.util; + +public class AaiException extends Exception { + + private static final long serialVersionUID = 9220983727706207465L; + + public AaiException() { + super(); + } + + public AaiException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public AaiException(String message, Throwable cause) { + super(message, cause); + } + + public AaiException(String message) { + super(message); + } + + public AaiException(Throwable cause) { + super(cause); + } + +} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java new file mode 100644 index 000000000..0ca0bb033 --- /dev/null +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai.util; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +public final class Serialization { + + public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() + .create(); + + private Serialization() {} + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetResponseTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetResponseTest.java new file mode 100644 index 000000000..ab31f5c27 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetResponseTest.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.io.File; +import java.nio.file.Files; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AaiGetResponseTest { + private static final Logger logger = LoggerFactory.getLogger(AaiGetResponseTest.class); + + @Test + public void test() throws Exception { + // deserialize json and verify fields are populated properly + String json = new String(Files.readAllBytes( + new File("src/test/resources/org/onap/policy/aai/AaiGetResponseError.json").toPath())); + + AaiGetResponse resp = Serialization.gsonPretty.fromJson(json, AaiGetResponse.class); + + // don't need to verify this in depth, as it has its own tests that do that + assertNotNull(resp.getRequestError()); + assertNotNull(resp.getRequestError().getServiceExcept()); + assertEquals("SVC3001", resp.getRequestError().getServiceExcept().getMessageId()); + + logger.info(Serialization.gsonPretty.toJson(resp)); + + // verify that setXxx methods work + resp.setRequestError(null); + assertNull(resp.getRequestError()); + + AaiNqRequestError err = new AaiNqRequestError(); + resp.setRequestError(err); + assertEquals(err, resp.getRequestError()); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java new file mode 100644 index 000000000..eb05be3cd --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.File; +import java.nio.file.Files; +import java.util.List; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AaiGetVnfResponseTest { + private static final Logger logger = LoggerFactory.getLogger(AaiGetVnfResponseTest.class); + + @Test + public void test() throws Exception { + // deserialize json and verify fields are populated properly + String json = new String(Files.readAllBytes( + new File("src/test/resources/org/onap/policy/aai/AaiGetVnfResponse.json").toPath())); + + AaiGetVnfResponse resp = Serialization.gsonPretty.fromJson(json, AaiGetVnfResponse.class); + + assertEquals("807a3f02-f878-436b-870c-f0e91e81570d", resp.getVnfId()); + assertEquals("vLoadBalancerMS-Vnf-0809-2", resp.getVnfName()); + assertEquals("vLoadBalancerMS/vLoadBalancerMS 0", resp.getVnfType()); + assertEquals("1533850960381", resp.getResourceVersion()); + assertEquals(false, resp.getInMaint()); + assertEquals(true, resp.getIsClosedLoopDisabled()); + assertEquals("53638a85-361a-437d-8830-4b0d5329225e", resp.getModelInvariantId()); + assertEquals("PROV", resp.getProvStatus()); + assertEquals("Active", resp.getOrchestrationStatus()); + assertEquals("50e1b0be-e0c9-48e2-9f42-15279a783ee8", resp.getServiceId()); + + // don't need to verify this in depth, as it has its own tests that do that + RelationshipList relationshipList = resp.getRelationshipList(); + assertNotNull(relationshipList); + + List<Relationship> lst = relationshipList.getRelationships(); + assertNotNull(lst); + + assertEquals(5, lst.size()); + assertEquals("service-instance", lst.get(0).getRelatedTo()); + assertEquals("line-of-business", lst.get(1).getRelatedTo()); + + logger.info(Serialization.gsonPretty.toJson(resp)); + + // verify that setXxx methods work + relationshipList = new RelationshipList(); + + resp.setInMaint(true); + resp.setIsClosedLoopDisabled(false); + resp.setModelInvariantId("modiv"); + resp.setOrchestrationStatus("orch"); + resp.setProvStatus("mystatus"); + resp.setRelationshipList(relationshipList); + resp.setResourceVersion("vers"); + resp.setServiceId("svc"); + resp.setVnfId("vnfid"); + resp.setVnfName("vnfname"); + resp.setVnfType("vnftype"); + + assertEquals("vnfid", resp.getVnfId()); + assertEquals("vnfname", resp.getVnfName()); + assertEquals("vnftype", resp.getVnfType()); + assertEquals("vers", resp.getResourceVersion()); + assertEquals(true, resp.getInMaint()); + assertEquals(false, resp.getIsClosedLoopDisabled()); + assertEquals("modiv", resp.getModelInvariantId()); + assertEquals("mystatus", resp.getProvStatus()); + assertEquals("orch", resp.getOrchestrationStatus()); + assertEquals("svc", resp.getServiceId()); + assertEquals(relationshipList, resp.getRelationshipList()); + + + // test error case + json = new String(Files.readAllBytes( + new File("src/test/resources/org/onap/policy/aai/AaiGetResponseError.json").toPath())); + resp = Serialization.gsonPretty.fromJson(json, AaiGetVnfResponse.class); + + // don't need to verify this in depth, as it has its own tests that do that + assertNotNull(resp.getRequestError()); + assertNotNull(resp.getRequestError().getServiceExcept()); + assertEquals("SVC3001", resp.getRequestError().getServiceExcept().getMessageId()); + } +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java new file mode 100644 index 000000000..ed68aeba0 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java @@ -0,0 +1,78 @@ +/* + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.File; +import java.nio.file.Files; +import java.util.LinkedList; +import java.util.List; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AaiGetVserverResponseTest { + private static final Logger logger = LoggerFactory.getLogger(AaiGetVserverResponseTest.class); + + @Test + public void test() throws Exception { + // deserialize json and verify fields are populated properly + String json = new String(Files.readAllBytes( + new File("src/test/resources/org/onap/policy/aai/AaiGetVserverResponse.json").toPath())); + + AaiGetVserverResponse resp = Serialization.gsonPretty.fromJson(json, AaiGetVserverResponse.class); + + // don't need to verify this in depth, as it has its own tests that do that + List<AaiNqVServer> lst = resp.getVserver(); + assertEquals(1, lst.size()); + + AaiNqVServer svr = lst.get(0); + assertNotNull(svr); + assertEquals("1c94da3f-16f1-4fc7-9ed1-e018dfa62774", svr.getVserverId()); + + logger.info(Serialization.gsonPretty.toJson(resp)); + + // verify that setXxx methods work + lst = new LinkedList<>(); + lst.add(new AaiNqVServer()); + lst.add(new AaiNqVServer()); + + resp.setVserver(lst); + + assertEquals(lst, resp.getVserver()); + + + // test error case + json = new String(Files.readAllBytes( + new File("src/test/resources/org/onap/policy/aai/AaiGetResponseError.json").toPath())); + resp = Serialization.gsonPretty.fromJson(json, AaiGetVserverResponse.class); + + // don't need to verify this in depth, as it has its own tests that do that + assertNotNull(resp.getRequestError()); + assertNotNull(resp.getRequestError().getServiceExcept()); + assertEquals("SVC3001", resp.getRequestError().getServiceExcept().getMessageId()); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java new file mode 100644 index 000000000..20aac23f6 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java @@ -0,0 +1,170 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.ArgumentMatchers.startsWith; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.onap.policy.rest.RestManager; +import org.onap.policy.rest.RestManager.Pair; + +public class AaiManagerTest { + RestManager restManagerMock; + UUID aaiNqRequestUuid = UUID.randomUUID(); + Pair<Integer, String> httpResponseOk; + Pair<Integer, String> httpResponseErr0; + Pair<Integer, String> httpResponseErr1; + Pair<Integer, String> httpResponseWait; + + /** + * Set up test cases. + */ + @Before + public void beforeTestAaiManager() { + restManagerMock = mock(RestManager.class); + + Map<String, String> expectedHeaders = new HashMap<>(); + expectedHeaders.put("X-FromAppId", "POLICY"); + expectedHeaders.put("X-TransactionId", aaiNqRequestUuid.toString()); + expectedHeaders.put("Accept", "application/json"); + + AaiNqResponse aaiNqResponse = new AaiNqResponseTest().getAaiNqResponse(); + httpResponseOk = restManagerMock.new Pair<>(200, Serialization.gsonPretty.toJson(aaiNqResponse)); + httpResponseErr0 = restManagerMock.new Pair<>(200, null); + httpResponseErr1 = restManagerMock.new Pair<>(200, "{"); + httpResponseWait = restManagerMock.new Pair<>(503, null); + } + + @Test + public void testAaiManagerAaiNqRequest() { + + AaiManager aaiManager = new AaiManager(restManagerMock); + assertNotNull(aaiManager); + + UUID aaiNqUuid = UUID.randomUUID(); + + AaiNqQueryParameters aaiNqQueryParameters = new AaiNqQueryParameters(); + AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); + aaiNqNamedQuery.setNamedQueryUuid(aaiNqUuid); + aaiNqQueryParameters.setNamedQuery(aaiNqNamedQuery); + + AaiNqRequest aaiNqRequest = new AaiNqRequest(); + aaiNqRequest.setQueryParameters(aaiNqQueryParameters); + + when(restManagerMock.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Gale"), anyMap(), + anyString(), anyString())).thenReturn(httpResponseOk); + + AaiNqResponse aaiNqOkResponse = aaiManager.postQuery("http://somewhere.over.the.rainbow", "Dorothy", "Gale", + aaiNqRequest, aaiNqRequestUuid); + assertNotNull(aaiNqOkResponse); + + when(restManagerMock.post(isNull(), eq("Dorothy"), anyString(), anyMap(), anyString(), anyString())) + .thenReturn(null); + + AaiNqResponse aaiNqNullResponse = aaiManager.postQuery(null, "Dorothy", "Gale", null, aaiNqRequestUuid); + assertNull(aaiNqNullResponse); + + when(restManagerMock.post(startsWith("http://somewhere.over.the.rainbow"), eq("Witch"), eq("West"), anyMap(), + anyString(), anyString())).thenReturn(httpResponseErr0); + + AaiNqResponse aaiNqNotOkResponse0 = aaiManager.postQuery("http://somewhere.over.the.rainbow", "Witch", "West", + aaiNqRequest, aaiNqRequestUuid); + assertNull(aaiNqNotOkResponse0); + + when(restManagerMock.post(startsWith("http://somewhere.under.the.rainbow"), eq("Witch"), eq("West"), anyMap(), + anyString(), anyString())).thenReturn(httpResponseErr1); + + AaiNqResponse aaiNqNotOkResponse1 = aaiManager.postQuery("http://somewhere.under.the.rainbow", "Witch", "West", + aaiNqRequest, aaiNqRequestUuid); + assertNull(aaiNqNotOkResponse1); + } + + @Test + public void testAaiManagerQueryByVserverName() { + AaiManager aaiManager = new AaiManager(restManagerMock); + assertNotNull(aaiManager); + + UUID vserverNameRequestId = UUID.randomUUID(); + + when(restManagerMock.get(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Gale"), anyMap())) + .thenReturn(httpResponseOk); + + AaiGetVserverResponse vserverResponse = aaiManager.getQueryByVserverName("http://somewhere.over.the.rainbow", + "Dorothy", "Gale", vserverNameRequestId, "vserverName"); + assertNotNull(vserverResponse); + + AaiGetVserverResponse vserverNullResponse = + aaiManager.getQueryByVserverName(null, "Dorothy", "Gale", vserverNameRequestId, "vserverName"); + assertNull(vserverNullResponse); + + when(restManagerMock.get(startsWith("http://somewhere.under.the.rainbow"), eq("Witch"), eq("West"), anyMap())) + .thenReturn(httpResponseErr0); + + AaiGetVserverResponse vserverNotOkResponse0 = aaiManager.getQueryByVserverName( + "http://somewhere.under.the.rainbow", "Witch", "West", vserverNameRequestId, "vserverName"); + assertNull(vserverNotOkResponse0); + } + + @Test + public void testAaiManagerQueryByVnfId() { + AaiManager aaiManager = new AaiManager(restManagerMock); + assertNotNull(aaiManager); + + UUID vserverNameRequestId = UUID.randomUUID(); + + when(restManagerMock.get(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Gale"), anyMap())) + .thenReturn(httpResponseOk); + + AaiGetVnfResponse vnfResponse = aaiManager.getQueryByVnfId("http://somewhere.over.the.rainbow", "Dorothy", + "Gale", vserverNameRequestId, "vnfID"); + assertNotNull(vnfResponse); + } + + @Test + public void testAaiManagerQueryByVnfName() { + AaiManager aaiManager = new AaiManager(restManagerMock); + assertNotNull(aaiManager); + + UUID vserverNameRequestId = UUID.randomUUID(); + + when(restManagerMock.get(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Gale"), anyMap())) + .thenReturn(httpResponseOk); + + AaiGetVnfResponse vnfResponse = aaiManager.getQueryByVnfId("http://somewhere.over.the.rainbow", "Dorothy", + "Gale", vserverNameRequestId, "vnfName"); + assertNotNull(vnfResponse); + } +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java new file mode 100644 index 000000000..70f04dfee --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class AaiNqCloudRegionTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + AaiNqCloudRegion aaiNqCloudRegion = new AaiNqCloudRegion(); + aaiNqCloudRegion.setCloudOwner("Rackspace"); + aaiNqCloudRegion.setCloudRegionId("DFW"); + aaiNqCloudRegion.setCloudRegionVersion("v1"); + aaiNqCloudRegion.setComplexName("SharedNode"); + aaiNqCloudRegion.setResourceVersion("1504789196021"); + assertNotNull(aaiNqCloudRegion); + assertEquals("Rackspace", aaiNqCloudRegion.getCloudOwner()); + assertEquals("DFW", aaiNqCloudRegion.getCloudRegionId()); + assertEquals("v1", aaiNqCloudRegion.getCloudRegionVersion()); + assertEquals("SharedNode", aaiNqCloudRegion.getComplexName()); + assertEquals("1504789196021", aaiNqCloudRegion.getResourceVersion()); + } +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java new file mode 100644 index 000000000..a4410c9c0 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertNotNull; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class AaiNqExtraPropertiesTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + AaiNqExtraProperties aaiNqExtraProperties = new AaiNqExtraProperties(); + 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/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java new file mode 100644 index 000000000..09c8cc310 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class AaiNqExtraPropertyTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + AaiNqExtraProperty aaiNqExtraProperty = new AaiNqExtraProperty(); + aaiNqExtraProperty.setPropertyName("model.model-name"); + aaiNqExtraProperty.setPropertyValue("service-instance"); + assertNotNull(aaiNqExtraProperty); + + assertEquals("model.model-name", aaiNqExtraProperty.getPropertyName()); + assertEquals("service-instance", aaiNqExtraProperty.getPropertyValue()); + } +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java new file mode 100644 index 000000000..e30bcaf86 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class AaiNqGenericVnfTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + AaiNqGenericVnf aaiNqGenericVnf = new AaiNqGenericVnf(); + aaiNqGenericVnf.setEncrypedAccessFlag(true); + aaiNqGenericVnf.setInMaint(false); + aaiNqGenericVnf.setIpv4Loopback0Address("aa"); + aaiNqGenericVnf.setIpv4OamAddress("oamAddress"); + aaiNqGenericVnf.setIsClosedLoopDisabled(false); + aaiNqGenericVnf.setModelInvariantId("653d2caa-7e47-4614-95b3-26c8d82755b8"); + aaiNqGenericVnf.setModelVersionId("98f410f6-4c63-447b-97d2-42508437cec0"); + aaiNqGenericVnf.setModelCustomizationId("SomeCustomizationId"); + aaiNqGenericVnf.setOperationalState("active"); + aaiNqGenericVnf.setPersonaModelId("653d2caa-7e47-4614-95b3-26c8d82755b8"); + aaiNqGenericVnf.setPersonaModelVersion("98f410f6-4c63-447b-97d2-42508437cec0"); + aaiNqGenericVnf.setProvStatus("complete"); + aaiNqGenericVnf.setResourceVersion("1505056714553"); + aaiNqGenericVnf.setServiceId("e8cb8968-5411-478b-906a-f28747de72cd"); + aaiNqGenericVnf.setVnfId("ed8b2bce-6b27-4089-992c-4a2c66024bcd"); + aaiNqGenericVnf.setVnfName("vCPEInfraVNF14a"); + aaiNqGenericVnf.setVnfName2("malumabb12"); + aaiNqGenericVnf.setVnfType("vCPEInfraService10/vCPEInfraService10 0"); + assertNotNull(aaiNqGenericVnf); + + assertEquals(true, aaiNqGenericVnf.getEncrypedAccessFlag()); + assertEquals(false, aaiNqGenericVnf.getInMaint()); + assertEquals("aa", aaiNqGenericVnf.getIpv4Loopback0Address()); + assertEquals("oamAddress", aaiNqGenericVnf.getIpv4OamAddress()); + assertEquals(false, aaiNqGenericVnf.getIsClosedLoopDisabled()); + assertEquals("653d2caa-7e47-4614-95b3-26c8d82755b8", aaiNqGenericVnf.getModelInvariantId()); + assertEquals("98f410f6-4c63-447b-97d2-42508437cec0", aaiNqGenericVnf.getModelVersionId()); + assertEquals("SomeCustomizationId", aaiNqGenericVnf.getModelCustomizationId()); + assertEquals("active", aaiNqGenericVnf.getOperationalState()); + assertEquals("653d2caa-7e47-4614-95b3-26c8d82755b8", aaiNqGenericVnf.getPersonaModelId()); + assertEquals("98f410f6-4c63-447b-97d2-42508437cec0", aaiNqGenericVnf.getPersonaModelVersion()); + assertEquals("complete", aaiNqGenericVnf.getProvStatus()); + assertEquals("1505056714553", aaiNqGenericVnf.getResourceVersion()); + assertEquals("e8cb8968-5411-478b-906a-f28747de72cd", aaiNqGenericVnf.getServiceId()); + assertEquals("ed8b2bce-6b27-4089-992c-4a2c66024bcd", aaiNqGenericVnf.getVnfId()); + assertEquals("vCPEInfraVNF14a", aaiNqGenericVnf.getVnfName()); + assertEquals("malumabb12", aaiNqGenericVnf.getVnfName2()); + assertEquals("vCPEInfraService10/vCPEInfraService10 0", aaiNqGenericVnf.getVnfType()); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java new file mode 100644 index 000000000..adafa1b5f --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertNotNull; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class AaiNqInstanceFiltersTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + AaiNqInstanceFilters aaiNqInstanceFilters = new AaiNqInstanceFilters(); + assertNotNull(aaiNqInstanceFilters); + + aaiNqInstanceFilters.setInstanceFilter(aaiNqInstanceFilters.getInstanceFilter());; + assertNotNull(aaiNqInstanceFilters); + assertNotNull(aaiNqInstanceFilters.getInstanceFilter()); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java new file mode 100644 index 000000000..eefe80703 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java @@ -0,0 +1,171 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertNotNull; + +import java.util.LinkedList; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AaiNqInventoryResponseItemTest { + private static final Logger logger = LoggerFactory.getLogger(AaiNqInventoryResponseItemTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + AaiNqInventoryResponseItem aaiNqInventoryResponseItem = new AaiNqInventoryResponseItem(); + aaiNqInventoryResponseItem.setModelName("service-instance"); + AaiNqCloudRegion aaiNqCloudRegion = new AaiNqCloudRegion(); + aaiNqCloudRegion.setCloudOwner("OWNER"); + aaiNqCloudRegion.setCloudRegionId("REGIONID"); + aaiNqCloudRegion.setCloudRegionVersion("2.5"); + aaiNqCloudRegion.setComplexName("COMPLEXNAME"); + aaiNqCloudRegion.setResourceVersion("1485365988"); + aaiNqInventoryResponseItem.setCloudRegion(aaiNqCloudRegion); + AaiNqExtraProperties aaiNqExtraProperties = new AaiNqExtraProperties(); + 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.setExtraProperties(aaiNqExtraProperties); + AaiNqGenericVnf aaiNqGenericVnf = new AaiNqGenericVnf(); + aaiNqGenericVnf.setVnfId("dhv-test-gvnf"); + aaiNqGenericVnf.setVnfName("dhv-test-gvnf-name"); + aaiNqGenericVnf.setVnfName2("dhv-test-gvnf-name2"); + aaiNqGenericVnf.setVnfType("SW"); + aaiNqGenericVnf.setServiceId("d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4"); + aaiNqGenericVnf.setProvStatus("PREPROV"); + aaiNqGenericVnf.setOperationalState("dhv-test-operational-state"); + aaiNqGenericVnf.setIpv4OamAddress("dhv-test-gvnf-ipv4-oam-address"); + aaiNqGenericVnf.setIpv4Loopback0Address("dhv-test-gvnfipv4-loopback0-address"); + aaiNqGenericVnf.setInMaint(false); + aaiNqGenericVnf.setIsClosedLoopDisabled(false); + aaiNqGenericVnf.setResourceVersion("1485366450"); + aaiNqGenericVnf.setEncrypedAccessFlag(true); + aaiNqGenericVnf.setPersonaModelId("acc6edd8-a8d4-4b93-afaa-0994068be14c"); + aaiNqGenericVnf.setPersonaModelVersion("1.0"); + aaiNqInventoryResponseItem.setGenericVnf(aaiNqGenericVnf); + AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); + serviceItem.setModelName("service-instance"); + serviceItem.setServiceInstance(new AaiNqServiceInstance()); + serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); + serviceItem.getServiceInstance().setServiceInstanceName("dhv-test-service-instance-name1"); + serviceItem.getServiceInstance().setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); + serviceItem.getServiceInstance().setPersonaModelVersion("1.0"); + serviceItem.getServiceInstance().setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); + serviceItem.getServiceInstance().setResourceVersion("1485366092"); + serviceItem.setExtraProperties(new AaiNqExtraProperties()); + serviceItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "service-instance")); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + serviceItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); + serviceItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); + + AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); + vfModuleItem.setModelName("vf-module"); + vfModuleItem.setVfModule(new AaiNqVfModule()); + vfModuleItem.getVfModule().setVfModuleId("example-vf-module-id-val-49261"); + vfModuleItem.getVfModule().setVfModuleName("example-vf-module-name-val-73074"); + vfModuleItem.getVfModule().setHeatStackId("example-heat-stack-id-val-86300"); + vfModuleItem.getVfModule().setOrchestrationStatus("example-orchestration-status-val-56523"); + vfModuleItem.getVfModule().setIsBaseVfModule(true); + vfModuleItem.getVfModule().setResourceVersion("1485366450"); + vfModuleItem.getVfModule().setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); + vfModuleItem.getVfModule().setPersonaModelVersion("1.0"); + vfModuleItem.getVfModule().setWidgetModelId("example-widget-model-id-val-92571"); + vfModuleItem.getVfModule().setWidgetModelVersion("example-widget-model-version-val-83317"); + vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); + vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); + vfModuleItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "vf-module")); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + vfModuleItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); + vfModuleItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); + + AaiNqInventoryResponseItems aaiNqInventoryResponseItems = new AaiNqInventoryResponseItems(); + aaiNqInventoryResponseItems.getInventoryResponseItems().add(serviceItem); + aaiNqInventoryResponseItems.getInventoryResponseItems().add(vfModuleItem); + aaiNqInventoryResponseItem.setItems(aaiNqInventoryResponseItems); + aaiNqInventoryResponseItem.setModelName("model-name"); + AaiNqServiceInstance serviceInstance = new AaiNqServiceInstance(); + serviceInstance.setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); + serviceInstance.setServiceInstanceName("dhv-test-service-instance-name1"); + serviceInstance.setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); + serviceInstance.setPersonaModelVersion("1.0"); + serviceInstance.setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); + serviceInstance.setResourceVersion("1485366092"); + aaiNqInventoryResponseItem.setServiceInstance(serviceInstance); + AaiNqTenant aaiNqTenant = new AaiNqTenant(); + aaiNqTenant.setTenantId("dhv-test-tenant"); + aaiNqTenant.setTenantName("dhv-test-tenant-name"); + aaiNqTenant.setResourceVersion("1485366334"); + aaiNqInventoryResponseItem.setTenant(aaiNqTenant); + AaiNqVfModule aaiNqVfModule = new AaiNqVfModule(); + aaiNqVfModule.setVfModuleId("example-vf-module-id-val-49261"); + aaiNqVfModule.setVfModuleName("example-vf-module-name-val-73074"); + aaiNqVfModule.setHeatStackId("example-heat-stack-id-val-86300"); + aaiNqVfModule.setOrchestrationStatus("example-orchestration-status-val-56523"); + aaiNqVfModule.setIsBaseVfModule(true); + aaiNqVfModule.setResourceVersion("1485366450"); + aaiNqVfModule.setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); + aaiNqVfModule.setPersonaModelVersion("1.0"); + aaiNqVfModule.setWidgetModelId("example-widget-model-id-val-92571"); + aaiNqVfModule.setWidgetModelVersion("example-widget-model-version-val-83317"); + aaiNqVfModule.setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); + aaiNqInventoryResponseItem.setVfModule(aaiNqVfModule); + AaiNqVServer aaiNqVServer = new AaiNqVServer(); + aaiNqVServer.setVserverId("dhv-test-vserver"); + aaiNqVServer.setVserverName("dhv-test-vserver-name"); + aaiNqVServer.setVserverName2("dhv-test-vserver-name2"); + aaiNqVServer.setProvStatus("PREPROV"); + aaiNqVServer.setVserverSelflink("dhv-test-vserver-selflink"); + aaiNqVServer.setInMaint(false); + aaiNqVServer.setIsClosedLoopDisabled(false); + aaiNqVServer.setResourceVersion("1485366417"); + aaiNqInventoryResponseItem.setVserver(aaiNqVServer); + assertNotNull(aaiNqInventoryResponseItem); + + logger.info(Serialization.gsonPretty.toJson(aaiNqInventoryResponseItem)); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java new file mode 100644 index 000000000..796e69226 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java @@ -0,0 +1,164 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.LinkedList; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AaiNqInventoryResponseItemsTest { + private static final Logger logger = LoggerFactory.getLogger(AaiNqInventoryResponseItemsTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); + serviceItem.setModelName("service-instance"); + assertEquals("service-instance", serviceItem.getModelName()); + + serviceItem.setServiceInstance(new AaiNqServiceInstance()); + serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); + serviceItem.getServiceInstance().setServiceInstanceName("dhv-test-service-instance-name1"); + serviceItem.getServiceInstance().setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); + serviceItem.getServiceInstance().setPersonaModelVersion("1.0"); + serviceItem.getServiceInstance().setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); + serviceItem.getServiceInstance().setResourceVersion("1485366092"); + serviceItem.setExtraProperties(new AaiNqExtraProperties()); + serviceItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "service-instance")); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + serviceItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); + serviceItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); + + AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); + vfModuleItem.setModelName("vf-module"); + vfModuleItem.setVfModule(new AaiNqVfModule()); + vfModuleItem.getVfModule().setVfModuleId("example-vf-module-id-val-49261"); + vfModuleItem.getVfModule().setVfModuleName("example-vf-module-name-val-73074"); + vfModuleItem.getVfModule().setHeatStackId("example-heat-stack-id-val-86300"); + vfModuleItem.getVfModule().setOrchestrationStatus("example-orchestration-status-val-56523"); + vfModuleItem.getVfModule().setIsBaseVfModule(true); + vfModuleItem.getVfModule().setResourceVersion("1485366450"); + vfModuleItem.getVfModule().setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); + vfModuleItem.getVfModule().setPersonaModelVersion("1.0"); + vfModuleItem.getVfModule().setWidgetModelId("example-widget-model-id-val-92571"); + vfModuleItem.getVfModule().setWidgetModelVersion("example-widget-model-version-val-83317"); + vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); + vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); + vfModuleItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "vf-module")); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + vfModuleItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); + vfModuleItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); + + AaiNqInventoryResponseItem genericVnfItem = new AaiNqInventoryResponseItem(); + genericVnfItem.setModelName("generic-vnf"); + genericVnfItem.setGenericVnf(new AaiNqGenericVnf()); + genericVnfItem.getGenericVnf().setVnfId("dhv-test-gvnf"); + genericVnfItem.getGenericVnf().setVnfName("dhv-test-gvnf-name"); + genericVnfItem.getGenericVnf().setVnfName2("dhv-test-gvnf-name2"); + genericVnfItem.getGenericVnf().setVnfType("SW"); + genericVnfItem.getGenericVnf().setServiceId("d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4"); + genericVnfItem.getGenericVnf().setProvStatus("PREPROV"); + genericVnfItem.getGenericVnf().setOperationalState("dhv-test-operational-state"); + genericVnfItem.getGenericVnf().setIpv4OamAddress("dhv-test-gvnf-ipv4-oam-address"); + genericVnfItem.getGenericVnf().setIpv4Loopback0Address("dhv-test-gvnfipv4-loopback0-address"); + genericVnfItem.getGenericVnf().setInMaint(false); + genericVnfItem.getGenericVnf().setIsClosedLoopDisabled(false); + genericVnfItem.getGenericVnf().setResourceVersion("1485366450"); + genericVnfItem.getGenericVnf().setEncrypedAccessFlag(true); + genericVnfItem.getGenericVnf().setPersonaModelId("acc6edd8-a8d4-4b93-afaa-0994068be14c"); + genericVnfItem.getGenericVnf().setPersonaModelVersion("1.0"); + genericVnfItem.setExtraProperties(new AaiNqExtraProperties()); + genericVnfItem.getExtraProperties().setExtraProperty(new LinkedList<>()); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "generic-vnf")); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-type", "widget")); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-version", "1.0")); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); + genericVnfItem.setItems(new AaiNqInventoryResponseItems()); + genericVnfItem.getItems().setInventoryResponseItems(new LinkedList<>()); + genericVnfItem.getItems().getInventoryResponseItems().add(serviceItem); + genericVnfItem.getItems().getInventoryResponseItems().add(vfModuleItem); + + AaiNqInventoryResponseItem cloudItem = new AaiNqInventoryResponseItem(); + cloudItem.setCloudRegion(new AaiNqCloudRegion()); + cloudItem.getCloudRegion().setCloudOwner("OWNER"); + cloudItem.getCloudRegion().setCloudRegionId("REGIONID"); + cloudItem.getCloudRegion().setCloudRegionVersion("2.5"); + cloudItem.getCloudRegion().setComplexName("COMPLEXNAME"); + cloudItem.getCloudRegion().setResourceVersion("1485365988"); + + AaiNqInventoryResponseItem tenantItem = new AaiNqInventoryResponseItem(); + tenantItem.setTenant(new AaiNqTenant()); + tenantItem.getTenant().setTenantId("dhv-test-tenant"); + tenantItem.getTenant().setTenantName("dhv-test-tenant-name"); + tenantItem.getTenant().setResourceVersion("1485366334"); + tenantItem.setItems(new AaiNqInventoryResponseItems()); + tenantItem.getItems().setInventoryResponseItems(new LinkedList<>()); + tenantItem.getItems().getInventoryResponseItems().add(cloudItem); + AaiNqInventoryResponseItem vserverItem = new AaiNqInventoryResponseItem(); + vserverItem.setVserver(new AaiNqVServer()); + vserverItem.getVserver().setVserverId("dhv-test-vserver"); + vserverItem.getVserver().setVserverName("dhv-test-vserver-name"); + vserverItem.getVserver().setVserverName2("dhv-test-vserver-name2"); + vserverItem.getVserver().setProvStatus("PREPROV"); + vserverItem.getVserver().setVserverSelflink("dhv-test-vserver-selflink"); + vserverItem.getVserver().setInMaint(false); + vserverItem.getVserver().setIsClosedLoopDisabled(false); + vserverItem.getVserver().setResourceVersion("1485366417"); + vserverItem.setItems(new AaiNqInventoryResponseItems()); + vserverItem.getItems().setInventoryResponseItems(new LinkedList<>()); + vserverItem.getItems().getInventoryResponseItems().add(genericVnfItem); + vserverItem.getItems().getInventoryResponseItems().add(tenantItem); + + AaiNqInventoryResponseItems aaiNqInventoryResponseItems = new AaiNqInventoryResponseItems(); + aaiNqInventoryResponseItems.getInventoryResponseItems().add(vserverItem); + assertNotNull(aaiNqInventoryResponseItems); + logger.info(Serialization.gsonPretty.toJson(aaiNqInventoryResponseItems)); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java new file mode 100644 index 000000000..a62046681 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.UUID; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class AaiNqNamedQueryTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); + UUID uuid = UUID.randomUUID(); + aaiNqNamedQuery.setNamedQueryUuid(uuid); + assertNotNull(aaiNqNamedQuery); + assertEquals(aaiNqNamedQuery.getNamedQueryUuid(), uuid); + } +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java new file mode 100644 index 000000000..2c1c0bf74 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.UUID; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class AaiNqQueryParametersTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + AaiNqQueryParameters aaiNqQueryParameters = new AaiNqQueryParameters(); + AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); + aaiNqNamedQuery.setNamedQueryUuid(UUID.randomUUID()); + aaiNqQueryParameters.setNamedQuery(aaiNqNamedQuery); + assertNotNull(aaiNqNamedQuery); + assertEquals(aaiNqQueryParameters.getNamedQuery(), aaiNqNamedQuery); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestErrorTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestErrorTest.java new file mode 100644 index 000000000..6aff8bc55 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestErrorTest.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +public class AaiNqRequestErrorTest { + + @Test + public void test() { + AaiNqRequestError aainqRequestError = new AaiNqRequestError(); + AaiNqServiceExcept serviceExcept = new AaiNqServiceExcept(); + aainqRequestError.setServiceExcept(serviceExcept); + assertEquals(aainqRequestError.getServiceExcept(), serviceExcept); + + assertNull(serviceExcept.getMessageId()); + assertNull(serviceExcept.getText()); + assertNull(serviceExcept.getVariables()); + } +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java new file mode 100644 index 000000000..982258a29 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.UUID; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AaiNqRequestTest { + private static final Logger logger = LoggerFactory.getLogger(AaiNqRequestTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + AaiNqRequest aaiNqRequest = new AaiNqRequest(); + AaiNqInstanceFilters aaiNqInstanceFilters = new AaiNqInstanceFilters(); + + aaiNqRequest.setInstanceFilters(aaiNqInstanceFilters); + assertNotNull(aaiNqRequest.getInstanceFilters()); + AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); + UUID uuid = UUID.randomUUID(); + aaiNqNamedQuery.setNamedQueryUuid(uuid); + + AaiNqQueryParameters aaiNqQueryParameters = new AaiNqQueryParameters(); + aaiNqQueryParameters.setNamedQuery(aaiNqNamedQuery); + aaiNqRequest.setQueryParameters(aaiNqQueryParameters); + + assertNotNull(aaiNqRequest); + + assertEquals(aaiNqNamedQuery.getNamedQueryUuid(), uuid); + assertEquals(aaiNqQueryParameters.getNamedQuery(), aaiNqNamedQuery); + assertEquals(aaiNqRequest.getQueryParameters(), aaiNqQueryParameters); + + logger.info(Serialization.gsonPretty.toJson(aaiNqRequest)); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java new file mode 100644 index 000000000..42979a45d --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java @@ -0,0 +1,161 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.util.LinkedList; + +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AaiNqResponseTest { + private static final Logger logger = LoggerFactory.getLogger(AaiNqResponseTest.class); + + @Test + public void test() { + getAaiNqResponse(); + } + + /** + * Get A&AI NQ response. + * + * @return the A&AI NG response + */ + public AaiNqResponse getAaiNqResponse() { + AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); + serviceItem.setModelName("service-instance"); + serviceItem.setServiceInstance(new AaiNqServiceInstance()); + serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); + serviceItem.getServiceInstance().setServiceInstanceName("dhv-test-service-instance-name1"); + serviceItem.getServiceInstance().setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); + serviceItem.getServiceInstance().setPersonaModelVersion("1.0"); + serviceItem.getServiceInstance().setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); + serviceItem.getServiceInstance().setResourceVersion("1485366092"); + serviceItem.setExtraProperties(new AaiNqExtraProperties()); + serviceItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "service-instance")); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + serviceItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); + serviceItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); + + AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); + vfModuleItem.setModelName("vf-module"); + vfModuleItem.setVfModule(new AaiNqVfModule()); + vfModuleItem.getVfModule().setVfModuleId("example-vf-module-id-val-49261"); + vfModuleItem.getVfModule().setVfModuleName("example-vf-module-name-val-73074"); + vfModuleItem.getVfModule().setHeatStackId("example-heat-stack-id-val-86300"); + vfModuleItem.getVfModule().setOrchestrationStatus("example-orchestration-status-val-56523"); + vfModuleItem.getVfModule().setIsBaseVfModule(true); + vfModuleItem.getVfModule().setResourceVersion("1485366450"); + vfModuleItem.getVfModule().setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); + vfModuleItem.getVfModule().setPersonaModelVersion("1.0"); + vfModuleItem.getVfModule().setWidgetModelId("example-widget-model-id-val-92571"); + vfModuleItem.getVfModule().setWidgetModelVersion("example-widget-model-version-val-83317"); + vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); + vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); + vfModuleItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "vf-module")); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + vfModuleItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); + vfModuleItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); + + AaiNqInventoryResponseItem genericVnfItem = new AaiNqInventoryResponseItem(); + genericVnfItem.setModelName("generic-vnf"); + genericVnfItem.setGenericVnf(new AaiNqGenericVnf()); + genericVnfItem.getGenericVnf().setVnfId("dhv-test-gvnf"); + genericVnfItem.getGenericVnf().setVnfName("dhv-test-gvnf-name"); + genericVnfItem.getGenericVnf().setVnfName2("dhv-test-gvnf-name2"); + genericVnfItem.getGenericVnf().setVnfType("SW"); + genericVnfItem.getGenericVnf().setServiceId("d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4"); + genericVnfItem.getGenericVnf().setProvStatus("PREPROV"); + genericVnfItem.getGenericVnf().setOperationalState("dhv-test-operational-state"); + genericVnfItem.getGenericVnf().setIpv4OamAddress("dhv-test-gvnf-ipv4-oam-address"); + genericVnfItem.getGenericVnf().setIpv4Loopback0Address("dhv-test-gvnfipv4-loopback0-address"); + genericVnfItem.getGenericVnf().setInMaint(false); + genericVnfItem.getGenericVnf().setIsClosedLoopDisabled(false); + genericVnfItem.getGenericVnf().setResourceVersion("1485366450"); + genericVnfItem.getGenericVnf().setEncrypedAccessFlag(true); + genericVnfItem.getGenericVnf().setPersonaModelId("acc6edd8-a8d4-4b93-afaa-0994068be14c"); + genericVnfItem.getGenericVnf().setPersonaModelVersion("1.0"); + genericVnfItem.setExtraProperties(new AaiNqExtraProperties()); + genericVnfItem.getExtraProperties().setExtraProperty(new LinkedList<>()); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "generic-vnf")); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-type", "widget")); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-version", "1.0")); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); + genericVnfItem.setItems(new AaiNqInventoryResponseItems()); + genericVnfItem.getItems().setInventoryResponseItems(new LinkedList<>()); + genericVnfItem.getItems().getInventoryResponseItems().add(serviceItem); + genericVnfItem.getItems().getInventoryResponseItems().add(vfModuleItem); + + AaiNqInventoryResponseItem cloudItem = new AaiNqInventoryResponseItem(); + cloudItem.setCloudRegion(new AaiNqCloudRegion()); + cloudItem.getCloudRegion().setCloudOwner("OWNER"); + cloudItem.getCloudRegion().setCloudRegionId("REGIONID"); + cloudItem.getCloudRegion().setCloudRegionVersion("2.5"); + cloudItem.getCloudRegion().setComplexName("COMPLEXNAME"); + cloudItem.getCloudRegion().setResourceVersion("1485365988"); + + AaiNqInventoryResponseItem tenantItem = new AaiNqInventoryResponseItem(); + tenantItem.setTenant(new AaiNqTenant()); + tenantItem.getTenant().setTenantId("dhv-test-tenant"); + tenantItem.getTenant().setTenantName("dhv-test-tenant-name"); + tenantItem.getTenant().setResourceVersion("1485366334"); + tenantItem.setItems(new AaiNqInventoryResponseItems()); + tenantItem.getItems().setInventoryResponseItems(new LinkedList<>()); + tenantItem.getItems().getInventoryResponseItems().add(cloudItem); + + AaiNqInventoryResponseItem vserverItem = new AaiNqInventoryResponseItem(); + vserverItem.setVserver(new AaiNqVServer()); + vserverItem.getVserver().setVserverId("dhv-test-vserver"); + vserverItem.getVserver().setVserverName("dhv-test-vserver-name"); + vserverItem.getVserver().setVserverName2("dhv-test-vserver-name2"); + vserverItem.getVserver().setProvStatus("PREPROV"); + vserverItem.getVserver().setVserverSelflink("dhv-test-vserver-selflink"); + vserverItem.getVserver().setInMaint(false); + vserverItem.getVserver().setIsClosedLoopDisabled(false); + vserverItem.getVserver().setResourceVersion("1485366417"); + vserverItem.setItems(new AaiNqInventoryResponseItems()); + vserverItem.getItems().setInventoryResponseItems(new LinkedList<>()); + vserverItem.getItems().getInventoryResponseItems().add(genericVnfItem); + vserverItem.getItems().getInventoryResponseItems().add(tenantItem); + + AaiNqResponse aaiResponse = new AaiNqResponse(); + aaiResponse.getInventoryResponseItems().add(vserverItem); + logger.info(Serialization.gsonPretty.toJson(aaiResponse)); + + return aaiResponse; + } +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java new file mode 100644 index 000000000..574ee8670 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java @@ -0,0 +1,262 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; +import org.apache.commons.io.IOUtils; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AaiNqResponseWrapperTest { + private static final Logger logger = LoggerFactory.getLogger(AaiNqResponseWrapperTest.class); + + @Test + public void test() { + AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); + serviceItem.setModelName("service-instance"); + serviceItem.setServiceInstance(new AaiNqServiceInstance()); + serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); + serviceItem.getServiceInstance().setServiceInstanceName("dhv-test-service-instance-name1"); + serviceItem.getServiceInstance().setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); + serviceItem.getServiceInstance().setPersonaModelVersion("1.0"); + serviceItem.getServiceInstance().setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); + serviceItem.getServiceInstance().setResourceVersion("1485366092"); + serviceItem.setExtraProperties(new AaiNqExtraProperties()); + serviceItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "service-instance")); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + serviceItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); + serviceItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); + + AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); + vfModuleItem.setModelName("vf-module"); + vfModuleItem.setVfModule(new AaiNqVfModule()); + vfModuleItem.getVfModule().setVfModuleId("example-vf-module-id-val-49261"); + vfModuleItem.getVfModule().setVfModuleName("example-vf-module-name-val-73074"); + vfModuleItem.getVfModule().setHeatStackId("example-heat-stack-id-val-86300"); + vfModuleItem.getVfModule().setOrchestrationStatus("example-orchestration-status-val-56523"); + vfModuleItem.getVfModule().setIsBaseVfModule(true); + vfModuleItem.getVfModule().setResourceVersion("1485366450"); + vfModuleItem.getVfModule().setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); + vfModuleItem.getVfModule().setPersonaModelVersion("1.0"); + vfModuleItem.getVfModule().setWidgetModelId("example-widget-model-id-val-92571"); + vfModuleItem.getVfModule().setWidgetModelVersion("example-widget-model-version-val-83317"); + vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); + vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); + vfModuleItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "vf-module")); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + vfModuleItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); + vfModuleItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); + + AaiNqInventoryResponseItem genericVnfItem = new AaiNqInventoryResponseItem(); + genericVnfItem.setModelName("generic-vnf"); + genericVnfItem.setGenericVnf(new AaiNqGenericVnf()); + genericVnfItem.getGenericVnf().setVnfId("dhv-test-gvnf"); + genericVnfItem.getGenericVnf().setVnfName("dhv-test-gvnf-name"); + genericVnfItem.getGenericVnf().setVnfName2("dhv-test-gvnf-name2"); + genericVnfItem.getGenericVnf().setVnfType("SW"); + genericVnfItem.getGenericVnf().setServiceId("d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4"); + genericVnfItem.getGenericVnf().setProvStatus("PREPROV"); + genericVnfItem.getGenericVnf().setOperationalState("dhv-test-operational-state"); + genericVnfItem.getGenericVnf().setIpv4OamAddress("dhv-test-gvnf-ipv4-oam-address"); + genericVnfItem.getGenericVnf().setIpv4Loopback0Address("dhv-test-gvnfipv4-loopback0-address"); + genericVnfItem.getGenericVnf().setInMaint(false); + genericVnfItem.getGenericVnf().setIsClosedLoopDisabled(false); + genericVnfItem.getGenericVnf().setResourceVersion("1485366450"); + genericVnfItem.getGenericVnf().setEncrypedAccessFlag(true); + genericVnfItem.getGenericVnf().setPersonaModelId("acc6edd8-a8d4-4b93-afaa-0994068be14c"); + genericVnfItem.getGenericVnf().setPersonaModelVersion("1.0"); + genericVnfItem.setExtraProperties(new AaiNqExtraProperties()); + genericVnfItem.getExtraProperties().setExtraProperty(new LinkedList<>()); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name", "generic-vnf")); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-type", "widget")); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-version", "1.0")); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); + genericVnfItem.getExtraProperties().getExtraProperty() + .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); + genericVnfItem.setItems(new AaiNqInventoryResponseItems()); + genericVnfItem.getItems().setInventoryResponseItems(new LinkedList<>()); + genericVnfItem.getItems().getInventoryResponseItems().add(serviceItem); + genericVnfItem.getItems().getInventoryResponseItems().add(vfModuleItem); + + AaiNqInventoryResponseItem cloudItem = new AaiNqInventoryResponseItem(); + cloudItem.setCloudRegion(new AaiNqCloudRegion()); + cloudItem.getCloudRegion().setCloudOwner("OWNER"); + cloudItem.getCloudRegion().setCloudRegionId("REGIONID"); + cloudItem.getCloudRegion().setCloudRegionVersion("2.5"); + cloudItem.getCloudRegion().setComplexName("COMPLEXNAME"); + cloudItem.getCloudRegion().setResourceVersion("1485365988"); + + AaiNqInventoryResponseItem tenantItem = new AaiNqInventoryResponseItem(); + tenantItem.setTenant(new AaiNqTenant()); + tenantItem.getTenant().setTenantId("dhv-test-tenant"); + tenantItem.getTenant().setTenantName("dhv-test-tenant-name"); + tenantItem.getTenant().setResourceVersion("1485366334"); + tenantItem.setItems(new AaiNqInventoryResponseItems()); + tenantItem.getItems().setInventoryResponseItems(new LinkedList<>()); + tenantItem.getItems().getInventoryResponseItems().add(cloudItem); + + AaiNqInventoryResponseItem vserverItem = new AaiNqInventoryResponseItem(); + vserverItem.setVserver(new AaiNqVServer()); + vserverItem.getVserver().setVserverId("dhv-test-vserver"); + vserverItem.getVserver().setVserverName("dhv-test-vserver-name"); + vserverItem.getVserver().setVserverName2("dhv-test-vserver-name2"); + vserverItem.getVserver().setProvStatus("PREPROV"); + vserverItem.getVserver().setVserverSelflink("dhv-test-vserver-selflink"); + vserverItem.getVserver().setInMaint(false); + vserverItem.getVserver().setIsClosedLoopDisabled(false); + vserverItem.getVserver().setResourceVersion("1485366417"); + vserverItem.setItems(new AaiNqInventoryResponseItems()); + vserverItem.getItems().setInventoryResponseItems(new LinkedList<>()); + vserverItem.getItems().getInventoryResponseItems().add(genericVnfItem); + vserverItem.getItems().getInventoryResponseItems().add(tenantItem); + + AaiNqResponse aaiResponse = new AaiNqResponse(); + aaiResponse.getInventoryResponseItems().add(vserverItem); + AaiNqResponseWrapper aaiNqResponseWarapper = new AaiNqResponseWrapper(); + aaiNqResponseWarapper.setAaiNqResponse(aaiResponse); + aaiNqResponseWarapper.setRequestId(UUID.randomUUID()); + assertNotNull(aaiNqResponseWarapper); + logger.info(Serialization.gsonPretty.toJson(aaiNqResponseWarapper)); + + AaiNqResponse aaiResponse2 = new AaiNqResponse(); + aaiResponse2.getInventoryResponseItems().add(vserverItem); + AaiNqResponseWrapper aaiNqResponseWarapper2 = new AaiNqResponseWrapper(UUID.randomUUID(), aaiResponse); + assertNotNull(aaiNqResponseWarapper2); + assertNotNull(aaiNqResponseWarapper2.getRequestId()); + assertNotNull(aaiNqResponseWarapper2.getAaiNqResponse()); + logger.info(Serialization.gsonPretty.toJson(aaiNqResponseWarapper2)); + } + + @Test + public void testCountVfModules() throws Exception { + AaiNqResponseWrapper resp; + + // null item + resp = new AaiNqResponseWrapper(); + assertEquals(0, resp.countVfModules()); + + // no names + resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoNames.json")); + assertEquals(0, resp.countVfModules()); + + // has VF modules + resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json")); + assertEquals(3, resp.countVfModules()); + } + + @Test + public void testGenVfModuleName() throws Exception { + AaiNqResponseWrapper resp; + + // null item + resp = new AaiNqResponseWrapper(); + assertEquals(null, resp.genVfModuleName()); + + // no names + resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoNames.json")); + assertEquals(null, resp.genVfModuleName()); + + // has VF modules + resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json")); + assertEquals("my-module-abc_124", resp.genVfModuleName()); + } + + @Test + public void testGetVfModules() throws Exception { + AaiNqResponseWrapper resp; + + // null item + resp = new AaiNqResponseWrapper(); + assertTrue(resp.getVfModuleItems(true).isEmpty()); + + // missing item + resp = new AaiNqResponseWrapper(); + resp.setAaiNqResponse(new AaiNqResponse()); + assertTrue(resp.getVfModuleItems(false).isEmpty()); + + // null item list + resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoItems.json")); + resp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems().get(0) + .getItems().setInventoryResponseItems(null); + assertTrue(resp.getVfModuleItems(false).isEmpty()); + + // no modules + resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoModules.json")); + assertTrue(resp.getVfModuleItems(false).isEmpty()); + + // no names + resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoNames.json")); + List<AaiNqInventoryResponseItem> lst; + lst = resp.getVfModuleItems(false); + assertEquals(0, lst.size()); + + // base VF modules + resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json")); + lst = resp.getVfModuleItems(true); + assertEquals(1, lst.size()); + assertEquals("Vfmodule_vLBMS-0809-1", lst.get(0).getVfModule().getVfModuleName()); + + // non base VF modules + resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json")); + lst = resp.getVfModuleItems(false); + assertEquals(3, lst.size()); + int index; + index = 0; + assertEquals("my-module-abc_1", lst.get(index++).getVfModule().getVfModuleName()); + assertEquals("my-module-abc_123", lst.get(index++).getVfModule().getVfModuleName()); + assertEquals("my-module-abc_34", lst.get(index++).getVfModule().getVfModuleName()); + } + + /** + * Loads a response from a JSON file. + * + * @param fileName name of the file containing the JSON response + * @return the response + * @throws IOException if the file cannot be read + */ + private AaiNqResponse load(String fileName) throws IOException { + String json = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8); + return Serialization.gsonPretty.fromJson(json, AaiNqResponse.class); + } +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java new file mode 100644 index 000000000..946372cc9 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AaiNqServiceInstanceTest { + private static final Logger logger = LoggerFactory.getLogger(AaiNqServiceInstanceTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + AaiNqServiceInstance aaiNqServiceInstance = new AaiNqServiceInstance(); + aaiNqServiceInstance.setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); + aaiNqServiceInstance.setServiceInstanceName("dhv-test-service-instance-name1"); + aaiNqServiceInstance.setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); + aaiNqServiceInstance.setPersonaModelVersion("1.0"); + aaiNqServiceInstance.setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); + aaiNqServiceInstance.setResourceVersion("1485366092"); + aaiNqServiceInstance.setModelInvariantId("SomeID"); + aaiNqServiceInstance.setModelVersionId("SomeVersion"); + assertNotNull(aaiNqServiceInstance); + assertEquals("dhv-test-vhnfportal-service-instance-id", aaiNqServiceInstance.getServiceInstanceId()); + assertEquals("dhv-test-service-instance-name1", aaiNqServiceInstance.getServiceInstanceName()); + assertEquals("82194af1-3c2c-485a-8f44-420e22a9eaa4", aaiNqServiceInstance.getPersonaModelId()); + assertEquals("1.0", aaiNqServiceInstance.getPersonaModelVersion()); + assertEquals("dhv-test-service-instance-location-id1", aaiNqServiceInstance.getServiceInstanceLocationId()); + assertEquals("1485366092", aaiNqServiceInstance.getResourceVersion()); + assertEquals("SomeID", aaiNqServiceInstance.getModelInvariantId()); + assertEquals("SomeVersion", aaiNqServiceInstance.getModelVersionId()); + logger.info(Serialization.gsonPretty.toJson(aaiNqServiceInstance)); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java new file mode 100644 index 000000000..18e2de40f --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AaiNqTenantTest { + private static final Logger logger = LoggerFactory.getLogger(AaiNqTenantTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + AaiNqTenant aaiNqTenant = new AaiNqTenant(); + aaiNqTenant.setTenantId("dhv-test-tenant"); + aaiNqTenant.setTenantName("dhv-test-tenant-name"); + aaiNqTenant.setResourceVersion("1485366334"); + assertNotNull(aaiNqTenant); + assertEquals("dhv-test-tenant", aaiNqTenant.getTenantId()); + assertEquals("dhv-test-tenant-name", aaiNqTenant.getTenantName()); + assertEquals("1485366334", aaiNqTenant.getResourceVersion()); + + logger.info(Serialization.gsonPretty.toJson(aaiNqTenant)); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java new file mode 100644 index 000000000..e1b612370 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.File; +import java.nio.file.Files; +import java.util.List; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AaiNqVServerTest { + private static final Logger logger = LoggerFactory.getLogger(AaiNqVServerTest.class); + + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() throws Exception { + // deserialize json and verify fields are populated properly + String json = new String(Files + .readAllBytes(new File("src/test/resources/org/onap/policy/aai/AaiNqVServer.json").toPath())); + + AaiNqVServer resp = Serialization.gsonPretty.fromJson(json, AaiNqVServer.class); + + assertEquals(false, resp.getInMaint()); + assertEquals(true, resp.getIsClosedLoopDisabled()); + assertEquals("ACTIVE", resp.getProvStatus()); + assertEquals("1533850964910", resp.getResourceVersion()); + assertEquals("1c94da3f-16f1-4fc7-9ed1-e018dfa62774", resp.getVserverId()); + assertEquals("vlb-ms-0809-1", resp.getVserverName()); + assertEquals("vlb-ms-0809-7", resp.getVserverName2()); + assertEquals("http://localhost:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774", + resp.getVserverSelflink()); + + // don't need to verify this in depth, as it has its own tests that do that + RelationshipList relationshipList = resp.getRelationshipList(); + assertNotNull(relationshipList); + + List<Relationship> lst = relationshipList.getRelationships(); + assertNotNull(lst); + + assertEquals(3, lst.size()); + assertEquals("generic-vnf", lst.get(0).getRelatedTo()); + assertEquals("image", lst.get(1).getRelatedTo()); + + logger.info(Serialization.gsonPretty.toJson(resp)); + + // verify that setXxx methods work + relationshipList = new RelationshipList(); + + resp.setInMaint(true); + resp.setIsClosedLoopDisabled(false); + resp.setProvStatus("inactive"); + resp.setRelationshipList(relationshipList); + resp.setResourceVersion("vers"); + resp.setVserverId("vid"); + resp.setVserverName("vname"); + resp.setVserverName2("vname2"); + resp.setVserverSelflink("link"); + + assertEquals(true, resp.getInMaint()); + assertEquals(false, resp.getIsClosedLoopDisabled()); + assertEquals("inactive", resp.getProvStatus()); + assertEquals("vers", resp.getResourceVersion()); + assertEquals("vid", resp.getVserverId()); + assertEquals("vname", resp.getVserverName()); + assertEquals("vname2", resp.getVserverName2()); + assertEquals("link", resp.getVserverSelflink()); + assertEquals(relationshipList, resp.getRelationshipList()); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java new file mode 100644 index 000000000..da169d589 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AaiNqVfModuleTest { + private static final Logger logger = LoggerFactory.getLogger(AaiNqVfModuleTest.class); + + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + AaiNqVfModule aaiNqVfModule = new AaiNqVfModule(); + aaiNqVfModule.setVfModuleId("example-vf-module-id-val-49261"); + aaiNqVfModule.setVfModuleName("example-vf-module-name-val-73074"); + aaiNqVfModule.setHeatStackId("example-heat-stack-id-val-86300"); + aaiNqVfModule.setOrchestrationStatus("example-orchestration-status-val-56523"); + aaiNqVfModule.setIsBaseVfModule(true); + aaiNqVfModule.setResourceVersion("1485366450"); + aaiNqVfModule.setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); + aaiNqVfModule.setPersonaModelVersion("1.0"); + aaiNqVfModule.setWidgetModelId("example-widget-model-id-val-92571"); + aaiNqVfModule.setWidgetModelVersion("example-widget-model-version-val-83317"); + aaiNqVfModule.setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); + aaiNqVfModule.setModelInvariantId("SomeId"); + aaiNqVfModule.setModelVersionId("SomeVersion"); + aaiNqVfModule.setModelCustomizationId("SomeCustomizationId"); + assertNotNull(aaiNqVfModule); + assertEquals("example-vf-module-id-val-49261", aaiNqVfModule.getVfModuleId()); + assertEquals("example-vf-module-name-val-73074", aaiNqVfModule.getVfModuleName()); + assertEquals("example-heat-stack-id-val-86300", aaiNqVfModule.getHeatStackId()); + assertEquals("example-orchestration-status-val-56523", aaiNqVfModule.getOrchestrationStatus()); + assertEquals(true, aaiNqVfModule.getIsBaseVfModule()); + assertEquals("1485366450", aaiNqVfModule.getResourceVersion()); + assertEquals("ef86f9c5-2165-44f3-8fc3-96018b609ea5", aaiNqVfModule.getPersonaModelId()); + assertEquals("1.0", aaiNqVfModule.getPersonaModelVersion()); + assertEquals("example-widget-model-id-val-92571", aaiNqVfModule.getWidgetModelId()); + assertEquals("example-widget-model-version-val-83317", aaiNqVfModule.getWidgetModelVersion()); + assertEquals("example-contrail-service-instance-fqdn-val-86796", + aaiNqVfModule.getContrailServiceInstanceFqdn()); + assertEquals("SomeId", aaiNqVfModule.getModelInvariantId()); + assertEquals("SomeVersion", aaiNqVfModule.getModelVersionId()); + assertEquals("SomeCustomizationId", aaiNqVfModule.getModelCustomizationId()); + logger.info(Serialization.gsonPretty.toJson(aaiNqVfModule)); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java new file mode 100644 index 000000000..9771d47d1 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PnfInstanceTest { + private static final Logger logger = LoggerFactory.getLogger(PnfInstanceTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + PnfInstance pnfInstance = new PnfInstance(); + pnfInstance.setPnfInstanceName("pnf-instance-name-test"); + pnfInstance.setPnfName("pnf-name-test"); + pnfInstance.setPnfType(PnfType.ENODEB); + pnfInstance.setPnfSerial("pnf-serial-test"); + assertNotNull(pnfInstance); + assertEquals("pnf-instance-name-test", pnfInstance.getPnfInstanceName()); + + PnfInstance pnfInstanceNull = new PnfInstance(null); + assertNotNull(pnfInstanceNull); + + PnfInstance pnfInstanceClone = new PnfInstance(pnfInstance); + assertNotNull(pnfInstanceClone); + + assertEquals("pnf-name-test", pnfInstanceClone.getPnfName()); + assertEquals(PnfType.ENODEB, pnfInstanceClone.getPnfType()); + assertEquals("pnf-serial-test", pnfInstanceClone.getPnfSerial()); + + assertEquals("PNFInstance [PNFName=pnf-name-test, PNFInstanceName=pnf-instance-name-test, PNFType=eNodeB, " + + "PNFSerial=pnf-serial-test]", pnfInstanceClone.toString()); + assertNotEquals(0, pnfInstanceClone.hashCode()); + assertNotEquals(0, new Pnf().hashCode()); + + PnfInstance pnfInstanceOther0 = new PnfInstance(); + pnfInstanceOther0.setPnfName("pnf-name-test"); + + PnfInstance pnfInstanceOther1 = new PnfInstance(pnfInstance); + pnfInstanceOther1.setPnfName("pnf-name-test-diff"); + + PnfInstance pnfInstanceOther2 = new PnfInstance(pnfInstance); + pnfInstanceOther2.setPnfInstanceName("pnf-instance-name-test-diff"); + + PnfInstance pnfInstanceOther3 = new PnfInstance(pnfInstance); + pnfInstanceOther3.setPnfName(null); + + PnfInstance pnfInstanceOther4 = new PnfInstance(pnfInstance); + pnfInstanceOther4.setPnfSerial(null); + + PnfInstance pnfInstanceOther5 = new PnfInstance(pnfInstance); + pnfInstanceOther5.setPnfSerial("pnf-serial-test-diff"); + + assertTrue(pnfInstance.equals(pnfInstance)); + assertFalse(pnfInstance.equals(null)); + assertFalse(pnfInstance.equals("hello")); + assertTrue(pnfInstance.equals(pnfInstanceClone)); + assertFalse(pnfInstance.equals(new Pnf())); + assertFalse(new Pnf().equals(pnfInstance)); + assertFalse(new Pnf().equals(pnfInstanceOther0)); + assertFalse(pnfInstanceOther0.equals(pnfInstance)); + assertFalse(pnfInstanceOther1.equals(pnfInstance)); + assertFalse(pnfInstanceOther2.equals(pnfInstance)); + assertFalse(pnfInstanceOther3.equals(pnfInstance)); + assertFalse(pnfInstanceOther4.equals(pnfInstance)); + assertFalse(pnfInstanceOther5.equals(pnfInstance)); + + logger.info(Serialization.gsonPretty.toJson(pnfInstance)); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java new file mode 100644 index 000000000..6efbb76c6 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PnfTest { + private static final Logger logger = LoggerFactory.getLogger(PnfTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + Pnf pnf = new Pnf(); + pnf.setPnfName("pnf-name-test"); + pnf.setPnfType(PnfType.ENODEB); + assertNotNull(pnf); + + Pnf pnfClone = new Pnf(pnf); + assertNotNull(pnfClone); + + assertEquals("pnf-name-test", pnfClone.getPnfName()); + assertEquals(PnfType.ENODEB, pnfClone.getPnfType()); + + assertEquals("PNF [PNFName=pnf-name-test, PNFType=eNodeB]", pnfClone.toString()); + assertNotEquals(0, pnfClone.hashCode()); + assertNotEquals(0, new Pnf().hashCode()); + + Pnf pnfOther = new Pnf(); + pnfOther.setPnfName("pnf-name-test"); + + assertTrue(pnf.equals(pnf)); + assertFalse(pnf.equals(null)); + assertFalse(pnf.equals("hello")); + assertTrue(pnf.equals(pnfClone)); + assertFalse(pnf.equals(new Pnf())); + assertFalse(new Pnf().equals(pnf)); + assertFalse(new Pnf().equals(pnfOther)); + assertFalse(pnfOther.equals(pnf)); + + logger.info(Serialization.gsonPretty.toJson(pnf)); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java new file mode 100644 index 000000000..e34c0e1c1 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertNotNull; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PnfTypeTest { + private static final Logger logger = LoggerFactory.getLogger(PnfTypeTest.class); + + + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + @AfterClass + public static void tearDownAfterClass() throws Exception {} + + @Test + public void test() { + PnfType pnfType = PnfType.ENODEB; + assertNotNull(pnfType); + assertNotNull(pnfType.toString()); + logger.info(Serialization.gsonPretty.toJson(pnfType)); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java new file mode 100644 index 000000000..20697d832 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.nio.file.Files; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RelatedToPropertyTest { + private static final Logger logger = LoggerFactory.getLogger(RelatedToPropertyTest.class); + + @Test + public void test() throws Exception { + // deserialize json and verify fields are populated properly + String json = new String(Files.readAllBytes( + new File("src/test/resources/org/onap/policy/aai/RelatedToProperty.json").toPath())); + + RelatedToProperty relatedToProperty = Serialization.gsonPretty.fromJson(json, RelatedToProperty.class); + + assertEquals("generic-vnf.vnf-name", relatedToProperty.getPropertyKey()); + assertEquals("vLoadBalancerMS-Vnf-0809-1", relatedToProperty.getPropertyValue()); + + logger.info(Serialization.gsonPretty.toJson(relatedToProperty)); + + // verify that setXxx methods work + relatedToProperty.setPropertyKey("a key"); + relatedToProperty.setPropertyValue("a value"); + + assertEquals("a key", relatedToProperty.getPropertyKey()); + assertEquals("a value", relatedToProperty.getPropertyValue()); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java new file mode 100644 index 000000000..def353fee --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.nio.file.Files; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RelationshipDataTest { + private static final Logger logger = LoggerFactory.getLogger(RelationshipDataTest.class); + + @Test + public void test() throws Exception { + // deserialize json and verify fields are populated properly + String json = new String(Files.readAllBytes( + new File("src/test/resources/org/onap/policy/aai/RelationshipData.json").toPath())); + + RelationshipData relationshipData = Serialization.gsonPretty.fromJson(json, RelationshipData.class); + + assertEquals("generic-vnf.vnf-id", relationshipData.getRelationshipKey()); + assertEquals("807a3f02-f878-436b-870c-f0e91e81570d", relationshipData.getRelationshipValue()); + + logger.info(Serialization.gsonPretty.toJson(relationshipData)); + + // verify that setXxx methods work + relationshipData.setRelationshipKey("a key"); + relationshipData.setRelationshipValue("a value"); + + assertEquals("a key", relationshipData.getRelationshipKey()); + assertEquals("a value", relationshipData.getRelationshipValue()); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java new file mode 100644 index 000000000..2c5538057 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.File; +import java.nio.file.Files; +import java.util.LinkedList; +import java.util.List; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RelationshipListTest { + private static final Logger logger = LoggerFactory.getLogger(RelationshipListTest.class); + + @Test + public void test() throws Exception { + // deserialize json and verify fields are populated properly + String json = new String(Files.readAllBytes( + new File("src/test/resources/org/onap/policy/aai/RelationshipList.json").toPath())); + + RelationshipList relationshipList = Serialization.gsonPretty.fromJson(json, RelationshipList.class); + + List<Relationship> lst = relationshipList.getRelationships(); + assertNotNull(lst); + assertEquals(3, lst.size()); + + // don't need to verify this in depth, as it has its own tests that do that + assertEquals("generic-vnf", lst.get(0).getRelatedTo()); + assertEquals("image", lst.get(1).getRelatedTo()); + assertEquals("flavor", lst.get(2).getRelatedTo()); + + logger.info(Serialization.gsonPretty.toJson(relationshipList)); + + // verify that setXxx methods work + lst = new LinkedList<>(); + lst.add(new Relationship()); + lst.add(new Relationship()); + + relationshipList.setRelationships(lst); + assertEquals(lst, relationshipList.getRelationships()); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java new file mode 100644 index 000000000..ee40d1fdf --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.policy.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.File; +import java.nio.file.Files; +import java.util.LinkedList; +import java.util.List; +import org.junit.Test; +import org.onap.policy.aai.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RelationshipTest { + private static final Logger logger = LoggerFactory.getLogger(RelationshipTest.class); + + @Test + public void test() throws Exception { + // deserialize json and verify fields are populated properly + String json = new String(Files + .readAllBytes(new File("src/test/resources/org/onap/policy/aai/Relationship.json").toPath())); + + Relationship relationship = Serialization.gsonPretty.fromJson(json, Relationship.class); + + assertEquals("/aai/v11/network/generic-vnfs/generic-vnf/807a3f02-f878-436b-870c-f0e91e81570d", + relationship.getRelatedLink()); + assertEquals("generic-vnf", relationship.getRelatedTo()); + + // don't need to verify this in depth, as it has its own tests that do that + List<RelatedToProperty> relatedToProperty = relationship.getRelatedToProperty(); + assertNotNull(relatedToProperty); + assertEquals(2, relatedToProperty.size()); + assertEquals("vLoadBalancerMS-Vnf-0809-1", relatedToProperty.get(0).getPropertyValue()); + assertEquals("vLoadBalancerMS-Vnf-0809-2", relatedToProperty.get(1).getPropertyValue()); + + // don't need to verify this in depth, as it has its own tests that do that + List<RelationshipData> relationshipData = relationship.getRelationshipData(); + assertNotNull(relationshipData); + assertEquals(2, relationshipData.size()); + assertEquals("807a3f02-f878-436b-870c-f0e91e81570d", relationshipData.get(0).getRelationshipValue()); + assertEquals("907a3f02-f878-436b-870c-f0e91e81570e", relationshipData.get(1).getRelationshipValue()); + + logger.info(Serialization.gsonPretty.toJson(relationship)); + + // verify that setXxx methods work + relatedToProperty = new LinkedList<>(); + relatedToProperty.add(new RelatedToProperty()); + relatedToProperty.add(new RelatedToProperty()); + relatedToProperty.add(new RelatedToProperty()); + + relationshipData = new LinkedList<>(); + relationshipData.add(new RelationshipData()); + relationshipData.add(new RelationshipData()); + relationshipData.add(new RelationshipData()); + + relationship.setRelatedLink("related-link"); + relationship.setRelatedTo("related-to"); + relationship.setRelatedToProperty(relatedToProperty); + relationship.setRelationshipData(relationshipData); + + assertEquals("related-link", relationship.getRelatedLink()); + assertEquals("related-to", relationship.getRelatedTo()); + assertEquals(relatedToProperty, relationship.getRelatedToProperty()); + assertEquals(relationshipData, relationship.getRelationshipData()); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java new file mode 100644 index 000000000..f424385fe --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai.util; + +import static org.junit.Assert.assertNotNull; + +import java.io.IOException; + +import org.junit.Test; + +public class AaiExceptionTest { + + @Test + public void test() { + assertNotNull(new AaiException()); + assertNotNull(new AaiException("message")); + assertNotNull(new AaiException("message", new IOException())); + assertNotNull(new AaiException("message", new IOException(), true, false)); + assertNotNull(new AaiException(new IOException())); + } + +} diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetResponseError.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetResponseError.json new file mode 100644 index 000000000..6751fef5c --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetResponseError.json @@ -0,0 +1,14 @@ +{ + "requestError": { + "serviceException": { + "messageId": "SVC3001", + "text": "Resource not found for %1 using id %2 (msg=%3) (ec=%4)", + "variables": [ + "GET", + "network/generic-vnfs/generic-vnf/3f02-f878-436b-870c-f0e91e81570d", + "Node Not Found:No Node of type generic-vnf found at: network/generic-vnfs/generic-vnf/3f02-f878-436b-870c-f0e91e81570d", + "ERR.5.4.6114" + ] + } + } +} diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetVnfResponse.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetVnfResponse.json new file mode 100644 index 000000000..faa0e0e1b --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetVnfResponse.json @@ -0,0 +1,123 @@ +{ + "in-maint": false, + "ipv4-oam-address": "10.0.150.1", + "is-closed-loop-disabled": true, + "model-customization-id": "6c1a5439-3b77-4d8a-bb2b-9fe7006ad671", + "model-invariant-id": "53638a85-361a-437d-8830-4b0d5329225e", + "model-version-id": "a82cd55f-1452-4c36-941a-c9f970a3e67c", + "nf-function": "", + "nf-naming-code": "", + "nf-role": "vLB", + "nf-type": "", + "orchestration-status": "Active", + "prov-status": "PROV", + "relationship-list": { + "relationship": [ + { + "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vLB/service-instances/service-instance/b66d24cc-feca-4fdc-8090-2e9539a8bbac", + "related-to": "service-instance", + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "vLoadBalancerMS-Service-0809-1" + } + ], + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "Demonstration" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vLB" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "b66d24cc-feca-4fdc-8090-2e9539a8bbac" + } + ] + }, + { + "related-link": "/aai/v11/business/lines-of-business/line-of-business/Test-Business", + "related-to": "line-of-business", + "relationship-data": [ + { + "relationship-key": "line-of-business.line-of-business-name", + "relationship-value": "Test-Business" + } + ] + }, + { + "related-link": "/aai/v11/business/platforms/platform/Test-Platform", + "related-to": "platform", + "relationship-data": [ + { + "relationship-key": "platform.platform-name", + "relationship-value": "Test-Platform" + } + ] + }, + { + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/4086f396c5e04caf9502c5fdeca575c4/vservers/vserver/191729bd-cb1d-485d-aa06-b20c888272a8", + "related-to": "vserver", + "related-to-property": [ + { + "property-key": "vserver.vserver-name", + "property-value": "vdns-ms01-0809-1" + } + ], + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "4086f396c5e04caf9502c5fdeca575c4" + }, + { + "relationship-key": "vserver.vserver-id", + "relationship-value": "191729bd-cb1d-485d-aa06-b20c888272a8" + } + ] + }, + { + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/4086f396c5e04caf9502c5fdeca575c4/vservers/vserver/1c94da3f-16f1-4fc7-9ed1-e018dfa62774", + "related-to": "vserver", + "related-to-property": [ + { + "property-key": "vserver.vserver-name", + "property-value": "vlb-ms-0809-1" + } + ], + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "4086f396c5e04caf9502c5fdeca575c4" + }, + { + "relationship-key": "vserver.vserver-id", + "relationship-value": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774" + } + ] + } + ] + }, + "resource-version": "1533850960381", + "service-id": "50e1b0be-e0c9-48e2-9f42-15279a783ee8", + "vnf-id": "807a3f02-f878-436b-870c-f0e91e81570d", + "vnf-name": "vLoadBalancerMS-Vnf-0809-2", + "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0" +} diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetVserverResponse.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetVserverResponse.json new file mode 100644 index 000000000..19885942e --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetVserverResponse.json @@ -0,0 +1,82 @@ +{ + "vserver": [ + { + "in-maint": false, + "is-closed-loop-disabled": true, + "prov-status": "ACTIVE", + "relationship-list": { + "relationship": [ + { + "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/807a3f02-f878-436b-870c-f0e91e81570d", + "related-to": "generic-vnf", + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "vLoadBalancerMS-Vnf-0809-2" + } + ], + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "807a3f02-f878-436b-870c-f0e91e81570d" + } + ] + }, + { + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/6e219e86-cd94-4989-9119-def29aa10b12", + "related-to": "image", + "related-to-property": [ + { + "property-key": "image.image-name", + "property-value": "unknown" + } + ], + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "image.image-id", + "relationship-value": "6e219e86-cd94-4989-9119-def29aa10b12" + } + ] + }, + { + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/764efb04-5a46-4806-a766-2bdd24559f39", + "related-to": "flavor", + "related-to-property": [ + { + "property-key": "flavor.flavor-name", + "property-value": "m1.medium" + } + ], + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "flavor.flavor-id", + "relationship-value": "764efb04-5a46-4806-a766-2bdd24559f39" + } + ] + } + ] + }, + "resource-version": "1533850964910", + "vserver-id": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774", + "vserver-name": "vlb-ms-0809-1", + "vserver-name2": "vlb-ms-0809-7", + "vserver-selflink": "http://localhost:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774" + } + ] +} diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoItems.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoItems.json new file mode 100644 index 000000000..996692402 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoItems.json @@ -0,0 +1,96 @@ +{ + "inventory-response-item": [ + { + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "extra-properties": { + "extra-property": [ + { + "property-name": "model-ver.model-version-id", + "property-value": "a82cd55f-1452-4c36-941a-c9f970a3e67c" + }, + { + "property-name": "model-ver.model-name", + "property-value": "vLoadBalancerMS" + }, + { + "property-name": "model.model-type", + "property-value": "resource" + }, + { + "property-name": "model.model-invariant-id", + "property-value": "53638a85-361a-437d-8830-4b0d5329225e" + }, + { + "property-name": "model-ver.model-version", + "property-value": "1.0" + } + ] + }, + "generic-vnf": { + "in-maint": false, + "ipv4-oam-address": "10.0.150.1", + "is-closed-loop-disabled": false, + "model-customization-id": "6c1a5439-3b77-4d8a-bb2b-9fe7006ad671", + "model-invariant-id": "53638a85-361a-437d-8830-4b0d5329225e", + "model-version-id": "a82cd55f-1452-4c36-941a-c9f970a3e67c", + "nf-function": "", + "nf-naming-code": "", + "nf-role": "vLB", + "nf-type": "", + "orchestration-status": "Active", + "prov-status": "PROV", + "resource-version": "1533850960381", + "service-id": "50e1b0be-e0c9-48e2-9f42-15279a783ee8", + "vnf-id": "807a3f02-f878-436b-870c-f0e91e81570d", + "vnf-name": "vLoadBalancerMS-Vnf-0809-2", + "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0" + }, + "inventory-response-items": { + "inventory-response-item": [ + ] + }, + "model-name": "vLoadBalancerMS" + }, + { + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "cloud-region": { + "cloud-owner": "CloudOwner", + "cloud-region-id": "RegionOne", + "cloud-region-version": "v2.5", + "cloud-type": "openstack", + "cloud-zone": "zone-1", + "owner-defined-type": "owner type", + "resource-version": "1533652058185", + "sriov-automation": false + }, + "extra-properties": {} + } + ] + }, + "tenant": { + "resource-version": "1533652058206", + "tenant-id": "4086f396c5e04caf9502c5fdeca575c4", + "tenant-name": "PFPP" + } + } + ] + }, + "vserver": { + "in-maint": false, + "is-closed-loop-disabled": false, + "prov-status": "ACTIVE", + "resource-version": "1533850964910", + "vserver-id": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774", + "vserver-name": "vlb-ms-0809-1", + "vserver-name2": "vlb-ms-0809-1", + "vserver-selflink": "http://10.12.25.2:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774" + } + } + ] +} diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoModules.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoModules.json new file mode 100644 index 000000000..2dd6090c7 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoModules.json @@ -0,0 +1,133 @@ +{ + "inventory-response-item": [ + { + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "extra-properties": { + "extra-property": [ + { + "property-name": "model-ver.model-version-id", + "property-value": "a82cd55f-1452-4c36-941a-c9f970a3e67c" + }, + { + "property-name": "model-ver.model-name", + "property-value": "vLoadBalancerMS" + }, + { + "property-name": "model.model-type", + "property-value": "resource" + }, + { + "property-name": "model.model-invariant-id", + "property-value": "53638a85-361a-437d-8830-4b0d5329225e" + }, + { + "property-name": "model-ver.model-version", + "property-value": "1.0" + } + ] + }, + "generic-vnf": { + "in-maint": false, + "ipv4-oam-address": "10.0.150.1", + "is-closed-loop-disabled": false, + "model-customization-id": "6c1a5439-3b77-4d8a-bb2b-9fe7006ad671", + "model-invariant-id": "53638a85-361a-437d-8830-4b0d5329225e", + "model-version-id": "a82cd55f-1452-4c36-941a-c9f970a3e67c", + "nf-function": "", + "nf-naming-code": "", + "nf-role": "vLB", + "nf-type": "", + "orchestration-status": "Active", + "prov-status": "PROV", + "resource-version": "1533850960381", + "service-id": "50e1b0be-e0c9-48e2-9f42-15279a783ee8", + "vnf-id": "807a3f02-f878-436b-870c-f0e91e81570d", + "vnf-name": "vLoadBalancerMS-Vnf-0809-2", + "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0" + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "extra-properties": { + "extra-property": [ + { + "property-name": "model-ver.model-version-id", + "property-value": "4feb459d-d8ef-4cde-a714-235c79787962" + }, + { + "property-name": "model-ver.model-name", + "property-value": "vLoadBalancerMS" + }, + { + "property-name": "model.model-type", + "property-value": "service" + }, + { + "property-name": "model.model-invariant-id", + "property-value": "b5477216-9b7d-4e75-8777-5b632d406759" + }, + { + "property-name": "model-ver.model-version", + "property-value": "1.0" + } + ] + }, + "model-name": "vLoadBalancerMS", + "service-instance": { + "environment-context": "General_Revenue-Bearing", + "model-invariant-id": "b5477216-9b7d-4e75-8777-5b632d406759", + "model-version-id": "4feb459d-d8ef-4cde-a714-235c79787962", + "orchestration-status": "Active", + "resource-version": "1533848425145", + "service-instance-id": "b66d24cc-feca-4fdc-8090-2e9539a8bbac", + "service-instance-name": "vLoadBalancerMS-Service-0809-1", + "workload-context": "Production" + } + } + ] + }, + "model-name": "vLoadBalancerMS" + }, + { + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "cloud-region": { + "cloud-owner": "CloudOwner", + "cloud-region-id": "RegionOne", + "cloud-region-version": "v2.5", + "cloud-type": "openstack", + "cloud-zone": "zone-1", + "owner-defined-type": "owner type", + "resource-version": "1533652058185", + "sriov-automation": false + }, + "extra-properties": {} + } + ] + }, + "tenant": { + "resource-version": "1533652058206", + "tenant-id": "4086f396c5e04caf9502c5fdeca575c4", + "tenant-name": "PFPP" + } + } + ] + }, + "vserver": { + "in-maint": false, + "is-closed-loop-disabled": false, + "prov-status": "ACTIVE", + "resource-version": "1533850964910", + "vserver-id": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774", + "vserver-name": "vlb-ms-0809-1", + "vserver-name2": "vlb-ms-0809-1", + "vserver-selflink": "http://10.12.25.2:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774" + } + } + ] +} diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoNames.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoNames.json new file mode 100644 index 000000000..9c1a9bc5d --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoNames.json @@ -0,0 +1,133 @@ +{ + "inventory-response-item": [ + { + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "extra-properties": { + "extra-property": [ + { + "property-name": "model-ver.model-version-id", + "property-value": "a82cd55f-1452-4c36-941a-c9f970a3e67c" + }, + { + "property-name": "model-ver.model-name", + "property-value": "vLoadBalancerMS" + }, + { + "property-name": "model.model-type", + "property-value": "resource" + }, + { + "property-name": "model.model-invariant-id", + "property-value": "53638a85-361a-437d-8830-4b0d5329225e" + }, + { + "property-name": "model-ver.model-version", + "property-value": "1.0" + } + ] + }, + "generic-vnf": { + "in-maint": false, + "ipv4-oam-address": "10.0.150.1", + "is-closed-loop-disabled": false, + "model-customization-id": "6c1a5439-3b77-4d8a-bb2b-9fe7006ad671", + "model-invariant-id": "53638a85-361a-437d-8830-4b0d5329225e", + "model-version-id": "a82cd55f-1452-4c36-941a-c9f970a3e67c", + "nf-function": "", + "nf-naming-code": "", + "nf-role": "vLB", + "nf-type": "", + "orchestration-status": "Active", + "prov-status": "PROV", + "resource-version": "1533850960381", + "service-id": "50e1b0be-e0c9-48e2-9f42-15279a783ee8", + "vnf-id": "807a3f02-f878-436b-870c-f0e91e81570d", + "vnf-name": "vLoadBalancerMS-Vnf-0809-2", + "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0" + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "vLoadBalancerMS", + "service-instance": { + "environment-context": "General_Revenue-Bearing", + "model-invariant-id": "b5477216-9b7d-4e75-8777-5b632d406759", + "model-version-id": "4feb459d-d8ef-4cde-a714-235c79787962", + "orchestration-status": "Active", + "resource-version": "1533848425145", + "service-instance-id": "b66d24cc-feca-4fdc-8090-2e9539a8bbac", + "service-instance-name": "vLoadBalancerMS-Service-0809-1", + "workload-context": "Production" + } + }, + { + "vf-module": { + "is-base-vf-module": false, + "model-invariant-id": "6d01b7f1-769a-4080-b8ea-57fd03ef1572", + "model-version-id": "3302088a-457e-496c-9282-2eb3d5b8dd24", + "resource-version": "1534270663202", + "vf-module-id": "dummy_807a3f02-f878-436b-870c-f0e91e81570d", + "vf-module-name": "dummy_807a3f02-f878-436b-870c-f0e91e81570d" + } + }, + { + "vf-module": { + "heat-stack-id": "Vfmodule_vLBMS-0809-1/83ab2394-2b22-40f9-8ba2-383698dd2958", + "is-base-vf-module": true, + "model-customization-id": "5198f732-8f22-48f9-98f8-d6b8b50118be", + "model-invariant-id": "1f566a81-58ba-4762-81f9-d2259509429a", + "model-version-id": "94827d25-4ac3-4850-abfc-7b6e3c531db4", + "module-index": 0, + "orchestration-status": "active", + "resource-version": "1533850416834", + "vf-module-id": "b861467d-d3a7-4b21-81b3-94d928a7e8b7", + "vf-module-name": "Vfmodule_vLBMS-0809-1" + } + } + ] + }, + "model-name": "vLoadBalancerMS" + }, + { + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "cloud-region": { + "cloud-owner": "CloudOwner", + "cloud-region-id": "RegionOne", + "cloud-region-version": "v2.5", + "cloud-type": "openstack", + "cloud-zone": "zone-1", + "owner-defined-type": "owner type", + "resource-version": "1533652058185", + "sriov-automation": false + }, + "extra-properties": {} + } + ] + }, + "tenant": { + "resource-version": "1533652058206", + "tenant-id": "4086f396c5e04caf9502c5fdeca575c4", + "tenant-name": "PFPP" + } + } + ] + }, + "vserver": { + "in-maint": false, + "is-closed-loop-disabled": false, + "prov-status": "ACTIVE", + "resource-version": "1533850964910", + "vserver-id": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774", + "vserver-name": "vlb-ms-0809-1", + "vserver-name2": "vlb-ms-0809-1", + "vserver-selflink": "http://10.12.25.2:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774" + } + } + ] +} diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-Vserver.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-Vserver.json new file mode 100644 index 000000000..fb341dc65 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-Vserver.json @@ -0,0 +1,157 @@ +{ + "inventory-response-item": [ + { + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "extra-properties": { + "extra-property": [ + { + "property-name": "model-ver.model-version-id", + "property-value": "a82cd55f-1452-4c36-941a-c9f970a3e67c" + }, + { + "property-name": "model-ver.model-name", + "property-value": "vLoadBalancerMS" + }, + { + "property-name": "model.model-type", + "property-value": "resource" + }, + { + "property-name": "model.model-invariant-id", + "property-value": "53638a85-361a-437d-8830-4b0d5329225e" + }, + { + "property-name": "model-ver.model-version", + "property-value": "1.0" + } + ] + }, + "generic-vnf": { + "in-maint": false, + "ipv4-oam-address": "10.0.150.1", + "is-closed-loop-disabled": false, + "model-customization-id": "6c1a5439-3b77-4d8a-bb2b-9fe7006ad671", + "model-invariant-id": "53638a85-361a-437d-8830-4b0d5329225e", + "model-version-id": "a82cd55f-1452-4c36-941a-c9f970a3e67c", + "nf-function": "", + "nf-naming-code": "", + "nf-role": "vLB", + "nf-type": "", + "orchestration-status": "Active", + "prov-status": "PROV", + "resource-version": "1533850960381", + "service-id": "50e1b0be-e0c9-48e2-9f42-15279a783ee8", + "vnf-id": "807a3f02-f878-436b-870c-f0e91e81570d", + "vnf-name": "vLoadBalancerMS-Vnf-0809-2", + "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0" + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "vLoadBalancerMS", + "service-instance": { + "environment-context": "General_Revenue-Bearing", + "model-invariant-id": "b5477216-9b7d-4e75-8777-5b632d406759", + "model-version-id": "4feb459d-d8ef-4cde-a714-235c79787962", + "orchestration-status": "Active", + "resource-version": "1533848425145", + "service-instance-id": "b66d24cc-feca-4fdc-8090-2e9539a8bbac", + "service-instance-name": "vLoadBalancerMS-Service-0809-1", + "workload-context": "Production" + } + }, + { + "vf-module": { + "is-base-vf-module": false, + "model-invariant-id": "6d01b7f1-769a-4080-b8ea-57fd03ef1572", + "model-version-id": "3302088a-457e-496c-9282-2eb3d5b8dd24", + "resource-version": "1534270663202", + "vf-module-id": "dummy_807a3f02-f878-436b-870c-f0e91e81570d", + "vf-module-name": "dummy_807a3f02-f878-436b-870c-f0e91e81570d" + } + }, + { + "vf-module": { + "is-base-vf-module": false, + "vf-module-name": "my-module-abc_1" + } + }, + { + "vf-module": { + "heat-stack-id": "Vfmodule_vLBMS-0809-1/83ab2394-2b22-40f9-8ba2-383698dd2958", + "is-base-vf-module": true, + "model-customization-id": "5198f732-8f22-48f9-98f8-d6b8b50118be", + "model-invariant-id": "1f566a81-58ba-4762-81f9-d2259509429a", + "model-version-id": "94827d25-4ac3-4850-abfc-7b6e3c531db4", + "module-index": 0, + "orchestration-status": "active", + "resource-version": "1533850416834", + "vf-module-id": "b861467d-d3a7-4b21-81b3-94d928a7e8b7", + "vf-module-name": "Vfmodule_vLBMS-0809-1" + } + }, + { + "vf-module": { + "is-base-vf-module": false, + "vf-module-name": "my-module-abc_123" + } + }, + { + "vf-module": { + "is-base-vf-module": false, + "vf-module-name": "no-underscore-number-9999" + } + }, + { + "vf-module": { + "is-base-vf-module": false, + "vf-module-name": "my-module-abc_34" + } + } + ] + }, + "model-name": "vLoadBalancerMS" + }, + { + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "cloud-region": { + "cloud-owner": "CloudOwner", + "cloud-region-id": "RegionOne", + "cloud-region-version": "v2.5", + "cloud-type": "openstack", + "cloud-zone": "zone-1", + "owner-defined-type": "owner type", + "resource-version": "1533652058185", + "sriov-automation": false + }, + "extra-properties": {} + } + ] + }, + "tenant": { + "resource-version": "1533652058206", + "tenant-id": "4086f396c5e04caf9502c5fdeca575c4", + "tenant-name": "PFPP" + } + } + ] + }, + "vserver": { + "in-maint": false, + "is-closed-loop-disabled": false, + "prov-status": "ACTIVE", + "resource-version": "1533850964910", + "vserver-id": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774", + "vserver-name": "vlb-ms-0809-1", + "vserver-name2": "vlb-ms-0809-1", + "vserver-selflink": "http://10.12.25.2:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774" + } + } + ] +} diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqVServer.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqVServer.json new file mode 100644 index 000000000..0a59d8a87 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqVServer.json @@ -0,0 +1,78 @@ +{ + "in-maint": false, + "is-closed-loop-disabled": true, + "prov-status": "ACTIVE", + "relationship-list": { + "relationship": [ + { + "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/807a3f02-f878-436b-870c-f0e91e81570d", + "related-to": "generic-vnf", + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "vLoadBalancerMS-Vnf-0809-2" + } + ], + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "807a3f02-f878-436b-870c-f0e91e81570d" + } + ] + }, + { + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/6e219e86-cd94-4989-9119-def29aa10b12", + "related-to": "image", + "related-to-property": [ + { + "property-key": "image.image-name", + "property-value": "unknown" + } + ], + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "image.image-id", + "relationship-value": "6e219e86-cd94-4989-9119-def29aa10b12" + } + ] + }, + { + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/764efb04-5a46-4806-a766-2bdd24559f39", + "related-to": "flavor", + "related-to-property": [ + { + "property-key": "flavor.flavor-name", + "property-value": "m1.medium" + } + ], + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "flavor.flavor-id", + "relationship-value": "764efb04-5a46-4806-a766-2bdd24559f39" + } + ] + } + ] + }, + "resource-version": "1533850964910", + "vserver-id": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774", + "vserver-name": "vlb-ms-0809-1", + "vserver-name2": "vlb-ms-0809-7", + "vserver-selflink": "http://localhost:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774" +} diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/RelatedToProperty.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/RelatedToProperty.json new file mode 100644 index 000000000..2211b3725 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/RelatedToProperty.json @@ -0,0 +1,4 @@ +{ + "property-key": "generic-vnf.vnf-name", + "property-value": "vLoadBalancerMS-Vnf-0809-1" +} diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/Relationship.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/Relationship.json new file mode 100644 index 000000000..39d9ce1b6 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/Relationship.json @@ -0,0 +1,25 @@ + +{ + "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/807a3f02-f878-436b-870c-f0e91e81570d", + "related-to": "generic-vnf", + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "vLoadBalancerMS-Vnf-0809-1" + }, + { + "property-key": "generic-vnf.vnf-name", + "property-value": "vLoadBalancerMS-Vnf-0809-2" + } + ], + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "807a3f02-f878-436b-870c-f0e91e81570d" + }, + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "907a3f02-f878-436b-870c-f0e91e81570e" + } + ] +} diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/RelationshipData.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/RelationshipData.json new file mode 100644 index 000000000..4bbb39e8f --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/RelationshipData.json @@ -0,0 +1,4 @@ +{ + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "807a3f02-f878-436b-870c-f0e91e81570d" +} diff --git a/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/RelationshipList.json b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/RelationshipList.json new file mode 100644 index 000000000..ae180f056 --- /dev/null +++ b/models-interactions/model-impl/aai/src/test/resources/org/onap/policy/aai/RelationshipList.json @@ -0,0 +1,68 @@ +{ + "relationship": [ + { + "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/807a3f02-f878-436b-870c-f0e91e81570d", + "related-to": "generic-vnf", + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "vLoadBalancerMS-Vnf-0809-2" + } + ], + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "807a3f02-f878-436b-870c-f0e91e81570d" + } + ] + }, + { + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/6e219e86-cd94-4989-9119-def29aa10b12", + "related-to": "image", + "related-to-property": [ + { + "property-key": "image.image-name", + "property-value": "unknown" + } + ], + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "image.image-id", + "relationship-value": "6e219e86-cd94-4989-9119-def29aa10b12" + } + ] + }, + { + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/764efb04-5a46-4806-a766-2bdd24559f39", + "related-to": "flavor", + "related-to-property": [ + { + "property-key": "flavor.flavor-name", + "property-value": "m1.medium" + } + ], + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "flavor.flavor-id", + "relationship-value": "764efb04-5a46-4806-a766-2bdd24559f39" + } + ] + } + ] +} |