summaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/aai/src/test/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-08-10 18:16:21 -0400
committerJim Hahn <jrh3@att.com>2018-08-14 12:07:09 -0400
commit71aacf6cf96b35020937aefc799122ab695f2a31 (patch)
treef999168e8f5dd1dc7685bad0761529180de05930 /controlloop/common/model-impl/aai/src/test/java
parentb88421e9bc12e96894bd59950efc1312a3f15b7b (diff)
update AAI response classes per API
Several of the AAI response classes did not match the new AAI interface. Updated AaiGetVnfResponse and AaiGetVserverResponse and the classes they use to reflect the new API; other top-level classes were left untouched. Fix checkstyle errors. Change-Id: Ife5830c45ba8aece8d676a10f0fd8a9c9fe6cb66 Issue-ID: POLICY-964 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/model-impl/aai/src/test/java')
-rw-r--r--controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetResponseTest.java (renamed from controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipItemTest.java)47
-rw-r--r--controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java128
-rw-r--r--controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java104
-rw-r--r--controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java75
-rw-r--r--controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyItemTest.java50
-rw-r--r--controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java40
-rw-r--r--controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataItemTest.java45
-rw-r--r--controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java41
-rw-r--r--controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java60
-rw-r--r--controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java78
10 files changed, 297 insertions, 371 deletions
diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipItemTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetResponseTest.java
index 98445a2de..9afa70a59 100644
--- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipItemTest.java
+++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetResponseTest.java
@@ -20,37 +20,42 @@
package org.onap.policy.aai;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+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 RelationshipItemTest {
- private static final Logger logger = LoggerFactory.getLogger(RelationshipItemTest.class);
+public class AaiGetResponseTest {
+ private static final Logger logger = LoggerFactory.getLogger(AaiGetResponseTest.class);
- @BeforeClass
- public static void setUpBeforeClass() 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/AaiGetResponseError.json").toPath()));
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
+ AaiGetResponse resp = Serialization.gsonPretty.fromJson(json, AaiGetResponse.class);
- @Test
- public void test() {
- RelationshipItem relationshipItem = new RelationshipItem();
- RelatedToPropertyItem relatedToPropertyItem = new RelatedToPropertyItem();
- relatedToPropertyItem.setPropertyKey("model.model-name");
- relatedToPropertyItem.setPropertyValue("service-instance");
- relationshipItem.getRelatedToProperty().add(relatedToPropertyItem);
- assertNotNull(relationshipItem);
-
- relationshipItem.setRelatedToProperty(relationshipItem.getRelatedToProperty());
- assertNotNull(relationshipItem);
-
- logger.info(Serialization.gsonPretty.toJson(relationshipItem));
+ // 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/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java
index d78952111..d56aaaece 100644
--- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java
+++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java
@@ -21,7 +21,11 @@
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;
@@ -31,64 +35,70 @@ public class AaiGetVnfResponseTest {
private static final Logger logger = LoggerFactory.getLogger(AaiGetVnfResponseTest.class);
@Test
- public void test() {
- AaiGetVnfResponse response = new AaiGetVnfResponse();
-
- response.setVnfId("83f674e8-7555-44d7-9a39-bdc3770b0491");
- response.setVnfName("lll_vnf_010317");
- response.setVnfType("Basa-122216-Service/VidVsamp12BaseVolume 1");
- response.setServiceId("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
- response.setOrchestrationStatus("Created");
- response.setInMaint("false");
- response.setIsClosedLoopDisabled("false");
- response.setResourceVersion("1494001988835");
- response.setModelInvariantId("f18be3cd-d446-456e-9109-121d9b62feaa");
- assertEquals("83f674e8-7555-44d7-9a39-bdc3770b0491", response.getVnfId());
- assertEquals("lll_vnf_010317", response.getVnfName());
- assertEquals("Basa-122216-Service/VidVsamp12BaseVolume 1", response.getVnfType());
- assertEquals("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", response.getServiceId());
- assertEquals("Created", response.getOrchestrationStatus());
- assertEquals("false", response.getInMaint());
- assertEquals("false", response.getIsClosedLoopDisabled());
- assertEquals("1494001988835", response.getResourceVersion());
- assertEquals("f18be3cd-d446-456e-9109-121d9b62feaa", response.getModelInvariantId());
-
- final RelationshipList relationshipList = new RelationshipList();
- final Relationship relationship = new Relationship();
- RelationshipData relationshipData = new RelationshipData();
- RelationshipDataItem relationshipDataItem = new RelationshipDataItem();
-
- relationshipDataItem.setRelationshipKey("customer.global-customer-id");
- relationshipDataItem.setRelationshipValue("MSO_1610_ST");
- relationshipData.getRelationshipData().add(relationshipDataItem);
-
- relationshipDataItem.setRelationshipKey("service-subscription.service-type");
- relationshipDataItem.setRelationshipValue("MSO-dev-service-type");
- relationshipData.getRelationshipData().add(relationshipDataItem);
-
- relationshipDataItem.setRelationshipKey("service-instance.service-instance-id");
- relationshipDataItem.setRelationshipValue("e1e9c97c-02c0-4919-9b4c-eb5d5ef68970");
- relationshipData.getRelationshipData().add(relationshipDataItem);
-
- RelatedToProperty relatedToProperty = new RelatedToProperty();
- RelatedToPropertyItem item = new RelatedToPropertyItem();
- item.setPropertyKey("service-instance.service-instance-name");
- item.setPropertyValue("lll_svc_010317");
- relatedToProperty.getRelatedTo().add(item);
- assertEquals("service-instance.service-instance-name", item.getPropertyKey());
- assertEquals("lll_svc_010317", item.getPropertyValue());
-
- relationship.setRelatedTo("service-instance");
- relationship.setRelatedLink(
- "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/"
- + "MSO-dev-service-type/service-instances/service-instance/"
- + "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970");
- relationship.setRelationshipData(relationshipData);
- relationship.setRelatedToProperty(relatedToProperty);
-
- relationshipList.getRelationshipList().add(relationship);
- response.setRelationshipList(relationshipList);
-
- logger.info(Serialization.gsonPretty.toJson(response));
+ 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("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.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("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/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java
index 6962b31f4..c0160e421 100644
--- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java
+++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java
@@ -1,4 +1,4 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* aai
* ================================================================================
@@ -21,8 +21,12 @@
package org.onap.policy.aai;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+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;
@@ -32,66 +36,42 @@ public class AaiGetVserverResponseTest {
private static final Logger logger = LoggerFactory.getLogger(AaiGetVserverResponseTest.class);
@Test
- public void test() {
- AaiGetVserverResponse response = new AaiGetVserverResponse();
-
- response.setVserverId("d0668d4f-c25e-4a1b-87c4-83845c01efd8");
- response.setVserverName("USMSO1SX7NJ0103UJZZ01-vjunos0");
- response.setVserverName2("vjunos0");
- response.setVserverSelflink(
- "https://aai-ext1.test.aaa.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/aaa-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver/d0668d4f-c25e-4a1b-87c4-83845c01efd8");
- response.setInMaint("false");
- response.setIsClosedLoopDisabled("false");
- response.setResourceVersion("1494001931513");
-
- assertEquals("d0668d4f-c25e-4a1b-87c4-83845c01efd8", response.getVserverId());
- assertEquals("USMSO1SX7NJ0103UJZZ01-vjunos0", response.getVserverName());
- assertEquals("vjunos0", response.getVserverName2());
- assertEquals("https://aai-ext1.test.aaa.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/"
- + "aaa-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver"
- + "/d0668d4f-c25e-4a1b-87c4-83845c01efd8", response.getVserverSelflink());
- assertEquals("false", response.getInMaint());
- assertEquals("false", response.getIsClosedLoopDisabled());
- assertEquals("1494001931513", response.getResourceVersion());
-
- final RelationshipList relationshipList = new RelationshipList();
- final Relationship relationship = new Relationship();
- RelationshipData relationshipData = new RelationshipData();
- RelationshipDataItem relationshipDataItem = new RelationshipDataItem();
-
- relationshipDataItem.setRelationshipKey("customer.global-customer-id");
- relationshipDataItem.setRelationshipValue("MSO_1610_ST");
- relationshipData.getRelationshipData().add(relationshipDataItem);
-
- relationshipDataItem.setRelationshipKey("service-subscription.service-type");
- relationshipDataItem.setRelationshipValue("MSO-dev-service-type");
- relationshipData.getRelationshipData().add(relationshipDataItem);
-
- relationshipDataItem.setRelationshipKey("service-instance.service-instance-id");
- relationshipDataItem.setRelationshipValue("e1e9c97c-02c0-4919-9b4c-eb5d5ef68970");
- relationshipData.getRelationshipData().add(relationshipDataItem);
-
- RelatedToProperty relatedToProperty = new RelatedToProperty();
- RelatedToPropertyItem item = new RelatedToPropertyItem();
- item.setPropertyKey("service-instance.service-instance-name");
- item.setPropertyValue("lll_svc_010317");
- relatedToProperty.getRelatedTo().add(item);
-
- relationship.setRelatedTo("service-instance");
- relationship.setRelatedLink(
- "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/"
- + "MSO-dev-service-type/service-instances/service-instance/"
- + "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970");
- relationship.setRelationshipData(relationshipData);
- relationship.setRelatedToProperty(relatedToProperty);
-
- relationshipList.getRelationshipList().add(relationship);
- response.setRelationshipList(relationshipList);
- assertEquals(response.getRelationshipList(), relationshipList);
- response.setRequestError(null);
- assertNull(response.getRequestError());
-
- logger.info(Serialization.gsonPretty.toJson(response));
+ 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/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java
index 9f49ecfef..bdda679d5 100644
--- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java
+++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java
@@ -23,6 +23,9 @@ 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;
@@ -41,26 +44,58 @@ public class AaiNqVServerTest {
public static void tearDownAfterClass() throws Exception {}
@Test
- public void test() {
- 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");
- assertNotNull(aaiNqVServer);
- assertEquals("dhv-test-vserver", aaiNqVServer.getVserverId());
- assertEquals("dhv-test-vserver-name", aaiNqVServer.getVserverName());
- assertEquals("dhv-test-vserver-name2", aaiNqVServer.getVserverName2());
- assertEquals("PREPROV", aaiNqVServer.getProvStatus());
- assertEquals("dhv-test-vserver-selflink", aaiNqVServer.getVserverSelflink());
- assertEquals(false, aaiNqVServer.getInMaint());
- assertEquals(false, aaiNqVServer.getIsClosedLoopDisabled());
- assertEquals("1485366417", aaiNqVServer.getResourceVersion());
- logger.info(Serialization.gsonPretty.toJson(aaiNqVServer));
+ 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/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyItemTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyItemTest.java
deleted file mode 100644
index 57f6c7605..000000000
--- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyItemTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * aai
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
-*/
-
-package org.onap.policy.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 RelatedToPropertyItemTest {
- private static final Logger logger = LoggerFactory.getLogger(RelatedToPropertyItemTest.class);
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {}
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
-
- @Test
- public void test() {
- RelatedToPropertyItem relatedToPropertyItem = new RelatedToPropertyItem();
- relatedToPropertyItem.setPropertyKey("model.model-name");
- relatedToPropertyItem.setPropertyValue("service-instance");
- assertNotNull(relatedToPropertyItem);
- logger.info(Serialization.gsonPretty.toJson(relatedToPropertyItem));
- }
-
-}
diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java
index 439c11dd2..832d59f89 100644
--- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java
+++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java
@@ -20,10 +20,10 @@
package org.onap.policy.aai;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import java.io.File;
+import java.nio.file.Files;
import org.junit.Test;
import org.onap.policy.aai.util.Serialization;
import org.slf4j.Logger;
@@ -32,29 +32,25 @@ import org.slf4j.LoggerFactory;
public class RelatedToPropertyTest {
private static final Logger logger = LoggerFactory.getLogger(RelatedToPropertyTest.class);
- @BeforeClass
- public static void setUpBeforeClass() 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/RelatedToProperty.json").toPath()));
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
+ RelatedToProperty relatedToProperty = Serialization.gsonPretty.fromJson(json, RelatedToProperty.class);
- @Test
- public void test() {
- RelatedToProperty relatedToProperty = new RelatedToProperty();
- RelatedToPropertyItem relatedToPropertyItem = new RelatedToPropertyItem();
- relatedToPropertyItem.setPropertyKey("model.model-name");
- relatedToPropertyItem.setPropertyValue("service-instance");
- relatedToProperty.getRelatedTo().add(relatedToPropertyItem);
- RelatedToPropertyItem relatedToPropertyItem2 = new RelatedToPropertyItem();
- relatedToPropertyItem2.setPropertyKey("model.model-name2");
- relatedToPropertyItem2.setPropertyValue("service-instance2");
- relatedToProperty.getRelatedTo().add(relatedToPropertyItem2);
- assertNotNull(relatedToProperty);
-
- relatedToProperty.setRelatedTo(relatedToProperty.getRelatedTo());
- assertNotNull(relatedToProperty);
+ 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/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataItemTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataItemTest.java
deleted file mode 100644
index 5ad99f9a7..000000000
--- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataItemTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * aai
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
-*/
-
-package org.onap.policy.aai;
-
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class RelationshipDataItemTest {
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {}
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
-
- @Test
- public void test() {
- RelationshipDataItem relationshipDataItem = new RelationshipDataItem();
- relationshipDataItem.setRelationshipKey("relationship-key");
- relationshipDataItem.setRelationshipValue("relationship-value");
- assertNotNull(relationshipDataItem);
- }
-
-}
diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java
index 57543711d..93b1d32c4 100644
--- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java
+++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java
@@ -21,10 +21,9 @@
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 java.io.File;
+import java.nio.file.Files;
import org.junit.Test;
import org.onap.policy.aai.util.Serialization;
import org.slf4j.Logger;
@@ -33,33 +32,25 @@ import org.slf4j.LoggerFactory;
public class RelationshipDataTest {
private static final Logger logger = LoggerFactory.getLogger(RelationshipDataTest.class);
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {}
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
-
@Test
- public void test() {
- RelationshipDataItem relationshipDataItem = new RelationshipDataItem();
- relationshipDataItem.setRelationshipKey("relationship-key");
- relationshipDataItem.setRelationshipValue("relationship-value");
- assertNotNull(relationshipDataItem);
- assertEquals("relationship-key", relationshipDataItem.getRelationshipKey());
- assertEquals("relationship-value", relationshipDataItem.getRelationshipValue());
+ 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 = new RelationshipData();
- relationshipData.getRelationshipData().add(relationshipDataItem);
- RelationshipDataItem relationshipDataItem2 = new RelationshipDataItem();
- relationshipDataItem2.setRelationshipKey("relationship-key2");
- relationshipDataItem2.setRelationshipValue("relationship-value2");
- relationshipData.getRelationshipData().add(relationshipDataItem2);
- assertNotNull(relationshipData);
+ RelationshipData relationshipData = Serialization.gsonPretty.fromJson(json, RelationshipData.class);
- relationshipData.setRelationshipData(relationshipData.getRelationshipData());
- assertNotNull(relationshipData);
+ 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/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java
index e7f207e6b..d67f2bb8b 100644
--- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java
+++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java
@@ -23,8 +23,10 @@ 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 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;
@@ -33,46 +35,32 @@ import org.slf4j.LoggerFactory;
public class RelationshipListTest {
private static final Logger logger = LoggerFactory.getLogger(RelationshipListTest.class);
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {}
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
-
@Test
- public void test() {
- Relationship relationship = new Relationship();
- relationship.setRelatedLink("related-link");
- relationship.setRelatedTo("related-to");
- assertEquals("related-link", relationship.getRelatedLink());
- assertEquals("related-to", relationship.getRelatedTo());
-
- RelatedToProperty relatedToProperty = new RelatedToProperty();
- RelatedToPropertyItem relatedToPropertyItem = new RelatedToPropertyItem();
- relatedToPropertyItem.setPropertyKey("model.model-name");
- relatedToPropertyItem.setPropertyValue("service-instance");
- relatedToProperty.getRelatedTo().add(relatedToPropertyItem);
- RelatedToPropertyItem relatedToPropertyItem2 = new RelatedToPropertyItem();
- relatedToPropertyItem2.setPropertyKey("model.model-name2");
- relatedToPropertyItem2.setPropertyValue("service-instance2");
- relatedToProperty.getRelatedTo().add(relatedToPropertyItem2);
- relationship.setRelatedToProperty(relatedToProperty);
- RelationshipDataItem relationshipDataItem = new RelationshipDataItem();
- relationshipDataItem.setRelationshipKey("relationship-key");
- relationshipDataItem.setRelationshipValue("relationship-value");
- RelationshipData relationshipData = new RelationshipData();
- relationshipData.getRelationshipData().add(relationshipDataItem);
- relationship.setRelationshipData(relationshipData);
+ 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 = new RelationshipList();
- relationshipList.getRelationshipList().add(relationship);
+ RelationshipList relationshipList = Serialization.gsonPretty.fromJson(json, RelationshipList.class);
- assertNotNull(relationshipList);
+ List<Relationship> lst = relationshipList.getRelationships();
+ assertNotNull(lst);
+ assertEquals(3, lst.size());
- relationshipList.setRelationshipList(relationshipList.getRelationshipList());
- assertNotNull(relationshipList);
+ // 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/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java
index 526ff8a1f..f229a091a 100644
--- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java
+++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java
@@ -23,50 +23,66 @@ 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 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(AaiNqResponseWrapperTest.class);
+ private static final Logger logger = LoggerFactory.getLogger(RelationshipTest.class);
- @BeforeClass
- public static void setUpBeforeClass() 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/Relationship.json").toPath()));
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
+ 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());
- @Test
- public void test() {
- Relationship relationship = new Relationship();
relationship.setRelatedLink("related-link");
relationship.setRelatedTo("related-to");
- assertEquals("related-link", relationship.getRelatedLink());
- assertEquals("related-to", relationship.getRelatedTo());
-
- RelatedToProperty relatedToProperty = new RelatedToProperty();
- RelatedToPropertyItem relatedToPropertyItem = new RelatedToPropertyItem();
- relatedToPropertyItem.setPropertyKey("model.model-name");
- relatedToPropertyItem.setPropertyValue("service-instance");
- relatedToProperty.getRelatedTo().add(relatedToPropertyItem);
- RelatedToPropertyItem relatedToPropertyItem2 = new RelatedToPropertyItem();
- relatedToPropertyItem2.setPropertyKey("model.model-name2");
- relatedToPropertyItem2.setPropertyValue("service-instance2");
- relatedToProperty.getRelatedTo().add(relatedToPropertyItem2);
relationship.setRelatedToProperty(relatedToProperty);
- assertEquals(relationship.getRelatedToProperty(), relatedToProperty);
- RelationshipDataItem relationshipDataItem = new RelationshipDataItem();
- relationshipDataItem.setRelationshipKey("relationship-key");
- relationshipDataItem.setRelationshipValue("relationship-value");
- RelationshipData relationshipData = new RelationshipData();
- relationshipData.getRelationshipData().add(relationshipDataItem);
relationship.setRelationshipData(relationshipData);
- assertEquals(relationship.getRelationshipData(), relationshipData);
- assertNotNull(relationship);
- logger.info(Serialization.gsonPretty.toJson(relationship));
+
+ assertEquals("related-link", relationship.getRelatedLink());
+ assertEquals("related-to", relationship.getRelatedTo());
+ assertEquals(relatedToProperty, relationship.getRelatedToProperty());
+ assertEquals(relationshipData, relationship.getRelationshipData());
}
}