diff options
author | Hengye <yehui.wang@est.tech> | 2019-03-25 14:32:21 +0000 |
---|---|---|
committer | Hengye <yehui.wang@est.tech> | 2019-03-25 14:32:21 +0000 |
commit | b150aa8197e8a21ab7ad4cf1d91cfa30f56fa3df (patch) | |
tree | 60c296267f496f3b40d838294e8f80b04ceb2607 /models-interactions/model-impl/aai/src/test | |
parent | 2a245ef80e39a101015efb164de53f1753fa5d47 (diff) |
migrate model-impl from drools-applications
migrate controlloop/common/model-impl from drools-applicaitons to
policy/models
Issue-ID: POLICY-1264
Change-Id: Ibe0bb5c49a7b1344f4104b30455f52834041e187
Signed-off-by: Hengye <yehui.wang@est.tech>
Diffstat (limited to 'models-interactions/model-impl/aai/src/test')
41 files changed, 3439 insertions, 0 deletions
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" + } + ] + } + ] +} |