diff options
author | Tait,Trevor(rt0435) <rtait@amdocs.com> | 2019-03-01 14:15:33 -0500 |
---|---|---|
committer | Tait,Trevor(rt0435) <rtait@amdocs.com> | 2019-03-06 11:59:32 -0500 |
commit | 2ecb0d9cfcb4fab803da12787b6e75f68fdff280 (patch) | |
tree | 6182903d796d08c0cb779569b1caabdae3a586fb /src/test/java/org/onap | |
parent | f0c44b14013d7418c19ba4cd7f9a5a3043648d5c (diff) |
X-ONAP-RequestId and X-ONAP-PartnerName support
Also cleaned up a few hundred ONAP code audit issues related to:
- white space
- long lines
- naming conventions
Issue-ID: LOG-551
Change-Id: Ic2af0093e1b4d14c42b95fffe013247afbbadd52
Signed-off-by: Tait,Trevor(rt0435) <rtait@amdocs.com>
Diffstat (limited to 'src/test/java/org/onap')
37 files changed, 1756 insertions, 1276 deletions
diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/LInterfaceInstanceTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/LInterfaceInstanceTest.java deleted file mode 100644 index 1dde19d..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/LInterfaceInstanceTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.pomba.contextbuilder.aai.datatype.LInterfaceInstance; - -public class LInterfaceInstanceTest { - @Test - public void testLInterfaceInstanceEquals() { - LInterfaceInstance lInterfaceInstance1 = new LInterfaceInstance - ( "interfaceId1", "interfaceName1", "interfaceRole1", - "isPortMirrored1", "adminStatus1", "networkName1", - "macAddr1", "inMaint1", null); - - LInterfaceInstance lInterfaceInstance2 = new LInterfaceInstance (); - lInterfaceInstance2.setInterfaceId("interfaceId1"); - lInterfaceInstance2.setInterfaceName("interfaceName1"); - lInterfaceInstance2.setInterfaceRole("interfaceRole1"); - lInterfaceInstance2.setIsPortMirrored("isPortMirrored1"); - lInterfaceInstance2.setAdminStatus("adminStatus1"); - lInterfaceInstance2.setNetworkName("networkName1"); - lInterfaceInstance2.setMacAddr("macAddr1"); - lInterfaceInstance2.setInMaint("inMaint1"); - - lInterfaceInstance1.toJson(); - lInterfaceInstance1.toString(); - assertEquals("interfaceName1", lInterfaceInstance2.getInterfaceName()); - assertTrue(lInterfaceInstance1.equals(lInterfaceInstance1)); - assertTrue(lInterfaceInstance1.equals(lInterfaceInstance2)); - } - -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/LogicalLinkInstanceTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/LogicalLinkInstanceTest.java deleted file mode 100644 index b0c4ea8..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/LogicalLinkInstanceTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.pomba.contextbuilder.aai.datatype.LogicalLinkInstance; - -public class LogicalLinkInstanceTest { - @Test - public void testLogicalLinkInstanceEquals() { - LogicalLinkInstance logicalLinkInstance1 = new LogicalLinkInstance - ( "linkName1", "linkId1", "modelVersionId1", - "modelInvariantId1", "linkType1", "routingProtocol1", - "speedValue1", "speedUnits1", "provStatus1", - "inMaint1", "linkRole1", "ipVersion1", - "linkName21","circuitId1","purpose1"); - - LogicalLinkInstance logicalLinkInstance2 = new LogicalLinkInstance (); - logicalLinkInstance2.setLinkName("linkName1"); - logicalLinkInstance2.setLinkId("linkId1"); - logicalLinkInstance2.setModelVersionId("modelVersionId1"); - logicalLinkInstance2.setModelInvariantId("modelInvariantId1"); - logicalLinkInstance2.setLinkType("linkType1"); - logicalLinkInstance2.setRoutingProtocol("routingProtocol1"); - logicalLinkInstance2.setSpeedValue("speedValue1"); - logicalLinkInstance2.setSpeedUnits("speedUnits1"); - logicalLinkInstance2.setProvStatus("provStatus1"); - logicalLinkInstance2.setInMaint("inMaint1"); - logicalLinkInstance2.setLinkRole("linkRole1"); - logicalLinkInstance2.setIpVersion("ipVersion1"); - logicalLinkInstance2.setLinkName2("linkName21"); - logicalLinkInstance2.setCircuitId("circuitId1"); - logicalLinkInstance2.setPurpose("purpose1"); - - logicalLinkInstance1.toJson(); - logicalLinkInstance1.toString(); - assertEquals("linkName1", logicalLinkInstance2.getLinkName()); - assertTrue(logicalLinkInstance1.equals(logicalLinkInstance1)); - assertTrue(logicalLinkInstance1.equals(logicalLinkInstance2)); - } -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/PInterfaceInstanceTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/PInterfaceInstanceTest.java deleted file mode 100644 index 33bba56..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/PInterfaceInstanceTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.pomba.contextbuilder.aai.datatype.PInterfaceInstance; -import org.onap.pomba.contextbuilder.aai.datatype.LInterfaceInstanceList; - -public class PInterfaceInstanceTest { - - @Test - public void testPInterfaceInstanceEquals() { - PInterfaceInstance pInterfaceInstance1 = new PInterfaceInstance - ( "interfaceName1", "speedValue1", "speedUnits1", - "portDescription1", "equipmentIdentifier1", "interfaceRole1", "interfaceType1", - "provStatus1", "resourceVersion1", "inMaint1", "invStatus1" , new LInterfaceInstanceList(), null); - - PInterfaceInstance pInterfaceInstance2 = new PInterfaceInstance (); - pInterfaceInstance2.setInterfaceName("interfaceName1"); - pInterfaceInstance2.setSpeedValue("speedValue1"); - pInterfaceInstance2.setSpeedUnits("speedUnits1"); - pInterfaceInstance2.setPortDescription("portDescription1"); - pInterfaceInstance2.setEquipmentIdentifier("equipmentIdentifier1"); - pInterfaceInstance2.setInterfaceRole("interfaceRole1"); - pInterfaceInstance2.setInterfaceType("interfaceType1"); - pInterfaceInstance2.setProvStatus("provStatus1"); - pInterfaceInstance2.setResourceVersion("resourceVersion1"); - pInterfaceInstance2.setInMaint("inMaint1"); - pInterfaceInstance2.setInvStatus("invStatus1"); - - pInterfaceInstance1.toJson(); - pInterfaceInstance1.toString(); - assertEquals("interfaceName1", pInterfaceInstance2.getInterfaceName()); - assertTrue(pInterfaceInstance1.equals(pInterfaceInstance1)); - assertTrue(pInterfaceInstance1.equals(pInterfaceInstance2)); - } -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/PnfInstanceTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/PnfInstanceTest.java deleted file mode 100644 index e7748c5..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/PnfInstanceTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.pomba.contextbuilder.aai.datatype.PnfInstance; - -public class PnfInstanceTest { - @Test - public void testPnfInstanceEquals() { - PnfInstance pnfInstance1 = new PnfInstance - ( "uuid1", "name1", "networkRole1", - "name21", "name2Source1", "equipmentType1", - "equipmentVendor1", "equipmentModel1", "managementOptions1", - "swVersion1", "frameId1", "serialNumber1", - "modelInvariantId1", "modelVersionId1", null); - - PnfInstance pnfInstance2 = new PnfInstance (); - pnfInstance2.setPnfId("uuid1"); - pnfInstance2.setPnfName("name1"); - pnfInstance2.setNfRole("networkRole1"); - pnfInstance2.setPnfName2("name21"); - pnfInstance2.setPnfName2Source("name2Source1"); - pnfInstance2.setEquipmentType("equipmentType1"); - pnfInstance2.setEquipmentVendor("equipmentVendor1"); - pnfInstance2.setEquipmentModel("equipmentModel1"); - pnfInstance2.setManagementOptions("managementOptions1"); - pnfInstance2.setSwVersion("swVersion1"); - pnfInstance2.setFrameId("frameId1"); - pnfInstance2.setSerialNumber("serialNumber1"); - pnfInstance2.setModelInvariantId("modelInvariantId1"); - pnfInstance2.setModelVersionId("modelVersionId1"); - pnfInstance2.setPInterfaceInstanceList(null); - - pnfInstance1.toJson(); - pnfInstance1.toString(); - assertEquals("name1", pnfInstance2.getPnfName()); - assertTrue(pnfInstance1.equals(pnfInstance1)); - assertTrue(pnfInstance1.equals(pnfInstance2)); - } -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/PserverInstanceTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/PserverInstanceTest.java deleted file mode 100644 index 93afb91..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/PserverInstanceTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.pomba.contextbuilder.aai.datatype.PserverInstance; - -public class PserverInstanceTest { - @Test - public void testPserverInstanceEquals() { - PserverInstance pserverInstance1 = new PserverInstance - ( "pserverId1", "hostname1", "pserverName2a", - "ptniiEquipName1", "equipType1", "equipVendor1", - "equipModel1", "fqdn1", "internetTopology1", - "inMaint1", "resourceVersion1", "serialNumber1", - "purpose1",null); - - PserverInstance pserverInstance2 = new PserverInstance (); - pserverInstance2.setPserverId("pserverId1"); - pserverInstance2.setHostname("hostname1"); - pserverInstance2.setPserverName2("pserverName2a"); - pserverInstance2.setPtniiEquipName("ptniiEquipName1"); - pserverInstance2.setEquipType("equipType1"); - pserverInstance2.setEquipVendor("equipVendor1"); - pserverInstance2.setEquipModel("equipModel1"); - pserverInstance2.setFqdn("fqdn1"); - pserverInstance2.setInternetTopology("internetTopology1"); - pserverInstance2.setInMaint("inMaint1"); - pserverInstance2.setResourceVersion("resourceVersion1"); - pserverInstance2.setSerialNumber("serialNumber1"); - pserverInstance2.setPurpose("purpose1"); - pserverInstance2.setPInterfaceInstanceList(null); - - pserverInstance1.toJson(); - pserverInstance1.toString(); - assertEquals("hostname1", pserverInstance2.getHostname()); - assertTrue(pserverInstance1.equals(pserverInstance1)); - assertTrue(pserverInstance1.equals(pserverInstance2)); - } -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RelatedToPropertyTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RelatedToPropertyTest.java deleted file mode 100644 index 6a3c0ac..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RelatedToPropertyTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.pomba.contextbuilder.aai.datatype.RelatedToProperty; - -public class RelatedToPropertyTest { - - @Test - public void testRelatedToPropertyWithParameters() { - RelatedToProperty relatedToProperty = new RelatedToProperty("propertyKey", "propertyValue"); - assertEquals("propertyKey", relatedToProperty.getPropertyKey()); - assertEquals("propertyValue", relatedToProperty.getPropertyValue()); - } - - @Test - public void testRelatedToProperty() { - RelatedToProperty relatedToProperty = new RelatedToProperty(); - relatedToProperty.setPropertyKey("propertyKey"); - relatedToProperty.setPropertyValue("propertyValue"); - assertEquals("propertyKey", relatedToProperty.getPropertyKey()); - assertEquals("propertyValue", relatedToProperty.getPropertyValue()); - String relatedToPropertyString = relatedToProperty.toString(); - assertTrue(relatedToPropertyString.contains("[propertyKey=propertyKey,propertyValue=propertyValue]")); - } - - @Test - public void testRelatedToPropertyIsEqual() { - RelatedToProperty relatedToProperty1 = new RelatedToProperty("propertyKey1", "propertyValue1"); - RelatedToProperty relatedToProperty2 = new RelatedToProperty("propertyKey2", "propertyValue2"); - RelatedToProperty relatedToProperty3 = new RelatedToProperty("propertyKey1", "propertyValue1"); - assertTrue(relatedToProperty1.equals(relatedToProperty1)); - assertTrue(!relatedToProperty1.equals(relatedToProperty2)); - assertTrue(relatedToProperty1.equals(relatedToProperty3)); - } -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RelationshipDatumTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RelationshipDatumTest.java deleted file mode 100644 index 490e3d3..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RelationshipDatumTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.pomba.contextbuilder.aai.datatype.RelationshipDatum; - -public class RelationshipDatumTest { - @Test - public void testRelationshipDatum() { - RelationshipDatum relationshipDatum = new RelationshipDatum(); - - relationshipDatum.setRelationshipKey("relationshipKey"); - relationshipDatum.setRelationshipValue("relationshipValue"); - - assertEquals("relationshipKey", relationshipDatum.getRelationshipKey()); - assertEquals("relationshipValue", relationshipDatum.getRelationshipValue()); - } - - @Test - public void testRelationshipDatumWithParameters() { - RelationshipDatum relationshipDatum = new RelationshipDatum("relationshipKey", "relationshipValue"); - - assertEquals("relationshipKey", relationshipDatum.getRelationshipKey()); - assertEquals("relationshipValue", relationshipDatum.getRelationshipValue()); - String relationshipDatumString = relationshipDatum.toString(); - assertTrue(relationshipDatumString.contains("[relationshipKey=relationshipKey,relationshipValue=relationshipValue]")); - } - - @Test - public void testRelationshipDatumEqual() { - RelationshipDatum relationshipDatum1 = new RelationshipDatum("relationshipKey1", "relationshipValue1"); - RelationshipDatum relationshipDatum2 = new RelationshipDatum("relationshipKey2", "relationshipValue2"); - RelationshipDatum relationshipDatum3 = new RelationshipDatum("relationshipKey1", "relationshipValue1"); - - assertTrue(relationshipDatum1.equals(relationshipDatum1)); - assertTrue(!relationshipDatum1.equals(relationshipDatum2)); - assertTrue(relationshipDatum1.equals(relationshipDatum3)); - } -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RelationshipListTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RelationshipListTest.java deleted file mode 100644 index f904f25..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RelationshipListTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; -import org.onap.pomba.contextbuilder.aai.datatype.RelatedToProperty; -import org.onap.pomba.contextbuilder.aai.datatype.Relationship; -import org.onap.pomba.contextbuilder.aai.datatype.RelationshipDatum; -import org.onap.pomba.contextbuilder.aai.datatype.RelationshipList; - -public class RelationshipListTest { - @Test - public void testRelationshipList() { - RelationshipList relationshipList = new RelationshipList(); - Relationship relationship = new Relationship(); - List<Relationship> list = new ArrayList<Relationship>(); - list.add(relationship); - relationshipList.setRelationship(list); - - assertTrue(relationshipList.getRelationship().size() == 1); - - relationship.setRelatedLink("relatedLink"); - relationship.setRelatedTo("relatedTo"); - - RelatedToProperty relatedToProperty = new RelatedToProperty(); - List<RelatedToProperty> relatedToPropertyList = new ArrayList<RelatedToProperty>(); - relatedToPropertyList.add(relatedToProperty); - relationship.setRelatedToProperty(relatedToPropertyList); - list.add(relationship); - relationshipList.setRelationship(list); - - String relationshipListString = relationshipList.toString(); - assertTrue(relationshipListString.contains("[relationship=")); - - } - - @Test - public void testRelationshipListWithParameters() { - Relationship relationship = new Relationship("relatedTo", "relatedLink", new ArrayList<RelationshipDatum>(), new ArrayList<RelatedToProperty>()); - List<Relationship> listOfRelationship = new ArrayList<Relationship>(); - listOfRelationship.add(relationship); - RelationshipList relationshipList = new RelationshipList(listOfRelationship); - - assertTrue(relationshipList.getRelationship().size() == 1); - } - - @Test - public void testRelationshipListEquals() { - - Relationship relationship1 = new Relationship("relatedTo1", "relatedLink1", new ArrayList<RelationshipDatum>(), new ArrayList<RelatedToProperty>()); - List<Relationship> listOfRelationship = new ArrayList<Relationship>(); - listOfRelationship.add(relationship1); - RelationshipList relationshipList1 = new RelationshipList(listOfRelationship); - - Relationship relationship2 = new Relationship("relatedTo2", "relatedLink2", new ArrayList<RelationshipDatum>(), new ArrayList<RelatedToProperty>()); - List<Relationship> listOfRelationship2 = new ArrayList<Relationship>(); - listOfRelationship.add(relationship2); - RelationshipList relationshipList2 = new RelationshipList(listOfRelationship2); - - Relationship relationship3 = new Relationship("relatedTo1", "relatedLink1", new ArrayList<RelationshipDatum>(), new ArrayList<RelatedToProperty>()); - List<Relationship> listOfRelationship3 = new ArrayList<Relationship>(); - listOfRelationship.add(relationship3); - RelationshipList relationshipList3 = new RelationshipList(listOfRelationship3); - - assertTrue(relationshipList1.equals(relationshipList1)); - assertTrue(!relationshipList1.equals(relationshipList2)); - assertTrue(!relationshipList1.equals(relationshipList3)); - } -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RelationshipTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RelationshipTest.java deleted file mode 100644 index 786ea13..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RelationshipTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; -import org.onap.pomba.contextbuilder.aai.datatype.RelatedToProperty; -import org.onap.pomba.contextbuilder.aai.datatype.Relationship; -import org.onap.pomba.contextbuilder.aai.datatype.RelationshipDatum; - -public class RelationshipTest { - - @Test - public void testRelationshipWithParameters() { - List<RelationshipDatum> relationshipDatum = new ArrayList<RelationshipDatum>(); - List<RelatedToProperty> relatedToProperty = new ArrayList<RelatedToProperty>(); - Relationship relationship = new Relationship("relatedTo", "relatedLink", relationshipDatum, relatedToProperty); - - assertEquals("relatedTo", relationship.getRelatedTo()); - assertEquals("relatedLink", relationship.getRelatedLink()); - assertTrue(relationship.getRelationshipData().isEmpty()); - assertTrue(relationship.getRelatedToProperty().isEmpty()); - } - - @Test - public void testRelationship() { - Relationship relationship = new Relationship(); - List<RelationshipDatum> relationshipDatum = new ArrayList<RelationshipDatum>(); - List<RelatedToProperty> relatedToProperty = new ArrayList<RelatedToProperty>(); - - relationship.setRelatedLink("relatedLink"); - relationship.setRelatedTo("relatedTo"); - relationship.setRelatedToProperty(relatedToProperty); - relationship.setRelationshipData(relationshipDatum); - - assertEquals("relatedTo", relationship.getRelatedTo()); - assertEquals("relatedLink", relationship.getRelatedLink()); - assertTrue(relationship.getRelationshipData().isEmpty()); - assertTrue(relationship.getRelatedToProperty().isEmpty()); - - String relationshipString = relationship.toString(); - assertTrue(relationshipString.contains("[relatedTo=relatedTo,relatedLink=relatedLink,relationshipData=[],relatedToProperty=[]]")); - } - - @Test - public void testRelationshipEquals() { - List<RelationshipDatum> relationshipDatum = new ArrayList<RelationshipDatum>(); - List<RelatedToProperty> relatedToProperty = new ArrayList<RelatedToProperty>(); - Relationship relationship1 = new Relationship("relatedTo1", "relatedLink1", relationshipDatum, relatedToProperty); - Relationship relationship2 = new Relationship("relatedTo2", "relatedLink2", relationshipDatum, relatedToProperty); - Relationship relationship3 = new Relationship("relatedTo1", "relatedLink1", relationshipDatum, relatedToProperty); - assertTrue(relationship1.equals(relationship1)); - assertTrue(!relationship1.equals(relationship2)); - assertTrue(relationship1.equals(relationship3)); - } - -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/ServiceInstanceTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/ServiceInstanceTest.java deleted file mode 100644 index 74e5994..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/ServiceInstanceTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; -import org.onap.pomba.contextbuilder.aai.datatype.RelatedToProperty; -import org.onap.pomba.contextbuilder.aai.datatype.Relationship; -import org.onap.pomba.contextbuilder.aai.datatype.RelationshipDatum; -import org.onap.pomba.contextbuilder.aai.datatype.RelationshipList; -import org.onap.pomba.contextbuilder.aai.datatype.ServiceInstance; - -public class ServiceInstanceTest { - @Test - public void testServiceInstance() { - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - serviceInstance.setServiceInstanceName("serviceInstanceName"); - serviceInstance.setServiceType("serviceType"); - serviceInstance.setServiceRole("serviceRole"); - serviceInstance.setEnvironmentContext("environmentContext"); - serviceInstance.setWorkloadContext("workloadContext"); - serviceInstance.setModelInvariantId("modelInvariantId"); - serviceInstance.setModelVersionId("modelVersionId"); - serviceInstance.setResourceVersion("resourceVersion"); - serviceInstance.setOrchestrationStatus("orchestrationStatus"); - RelationshipList relationshipList = new RelationshipList(); - List<Relationship> listOfRelationship = new ArrayList<Relationship>(); - Relationship relationship = new Relationship("relatedTo", "relatedLink", new ArrayList<RelationshipDatum>(), new ArrayList<RelatedToProperty>()); - listOfRelationship.add(relationship); - relationshipList.setRelationship(listOfRelationship); - - serviceInstance.setRelationshipList(relationshipList); - - assertEquals("serviceInstanceId", serviceInstance.getServiceInstanceId()); - assertEquals("serviceInstanceName", serviceInstance.getServiceInstanceName()); - assertEquals("serviceType", serviceInstance.getServiceType()); - assertEquals("serviceRole", serviceInstance.getServiceRole()); - assertEquals("environmentContext", serviceInstance.getEnvironmentContext()); - assertEquals("workloadContext", serviceInstance.getWorkloadContext()); - assertEquals("modelInvariantId", serviceInstance.getModelInvariantId()); - assertEquals("modelVersionId", serviceInstance.getModelVersionId()); - assertEquals("resourceVersion", serviceInstance.getResourceVersion()); - assertEquals("orchestrationStatus", serviceInstance.getOrchestrationStatus()); - assertEquals("relatedTo", serviceInstance.getRelationshipList().getRelationship().get(0).getRelatedTo()); - } - - @Test - public void testServiceInstanceWithParameters() { - ServiceInstance serviceInstance = new ServiceInstance("serviceInstanceId", "serviceInstanceName", "serviceType", "serviceRole", "environmentContext", "workloadContext", "modelInvariantId", "modelVersionId", "resourceVersion", "orchestrationStatus", new RelationshipList()); - - assertEquals("serviceInstanceId", serviceInstance.getServiceInstanceId()); - assertEquals("serviceInstanceName", serviceInstance.getServiceInstanceName()); - assertEquals("serviceType", serviceInstance.getServiceType()); - assertEquals("serviceRole", serviceInstance.getServiceRole()); - assertEquals("environmentContext", serviceInstance.getEnvironmentContext()); - assertEquals("workloadContext", serviceInstance.getWorkloadContext()); - assertEquals("modelInvariantId", serviceInstance.getModelInvariantId()); - assertEquals("modelVersionId", serviceInstance.getModelVersionId()); - assertEquals("resourceVersion", serviceInstance.getResourceVersion()); - assertEquals("orchestrationStatus", serviceInstance.getOrchestrationStatus()); - - String serviceInstanceString = serviceInstance.toString(); - assertTrue(serviceInstanceString.contains("[serviceInstanceId=serviceInstanceId,serviceInstanceName=serviceInstanceName,serviceType=serviceType,serviceRole=serviceRole,environmentContext=environmentContext,workloadContext=workloadContext,modelInvariantId=modelInvariantId,modelVersionId=modelVersionId,resourceVersion=resourceVersion,orchestrationStatus=orchestrationStatus,")); - } - - @Test - public void testServiceInstanceEquals() { - ServiceInstance serviceInstance1 = new ServiceInstance("serviceInstanceId1", "serviceInstanceName1", "serviceType1", "serviceRole1", "environmentContext1", "workloadContext1", "modelInvariantId1", "modelVersionId1", "resourceVersion1", "orchestrationStatus1", new RelationshipList()); - ServiceInstance serviceInstance2 = new ServiceInstance("serviceInstanceId2", "serviceInstanceName2", "serviceType2", "serviceRole2", "environmentContext2", "workloadContext2", "modelInvariantId2", "modelVersionId2", "resourceVersion2", "orchestrationStatus2", new RelationshipList()); - ServiceInstance serviceInstance3 = new ServiceInstance("serviceInstanceId1", "serviceInstanceName1", "serviceType1", "serviceRole1", "environmentContext1", "workloadContext1", "modelInvariantId1", "modelVersionId1", "resourceVersion1", "orchestrationStatus1", new RelationshipList()); - - assertTrue(serviceInstance1.equals(serviceInstance1)); - assertTrue(!serviceInstance1.equals(serviceInstance2)); - assertTrue(serviceInstance1.equals(serviceInstance3)); - } -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/TestSrpingServiceImpl.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/TestSrpingServiceImpl.java deleted file mode 100644 index 13d52f9..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/TestSrpingServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -public class TestSrpingServiceImpl { - -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VfModuleTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VfModuleTest.java deleted file mode 100644 index 77da591..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VfModuleTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; -import org.onap.pomba.contextbuilder.aai.datatype.L3networkInstance; -import org.onap.pomba.contextbuilder.aai.datatype.RelatedToProperty; -import org.onap.pomba.contextbuilder.aai.datatype.Relationship; -import org.onap.pomba.contextbuilder.aai.datatype.RelationshipDatum; -import org.onap.pomba.contextbuilder.aai.datatype.RelationshipList; -import org.onap.pomba.contextbuilder.aai.datatype.VfModule; - -public class VfModuleTest { - @Test - public void testVfModule() { - VfModule vfModule = new VfModule(); - vfModule.setVfModuleId("vfModuleId"); - vfModule.setVfModuleName("vfModuleName"); - vfModule.setHeatStackId("heatStackId"); - vfModule.setOrchestrationStatus("orchestrationStatus"); - vfModule.setIsBaseVfModule(true); - vfModule.setResourceVersion("resourceVersion"); - vfModule.setModelInvariantId("modelInvariantId"); - vfModule.setModelVersionId("modelVersionId"); - vfModule.setModelCustomizationId("modelCustomizationId"); - vfModule.setModuleIndex(1); - - RelationshipList relationshipList = new RelationshipList(); - List<Relationship> listOfRelationship = new ArrayList<Relationship>(); - Relationship relationship = new Relationship("relatedTo", "relatedLink", new ArrayList<RelationshipDatum>(), new ArrayList<RelatedToProperty>()); - listOfRelationship.add(relationship); - relationshipList.setRelationship(listOfRelationship); - - vfModule.setRelationshipList(relationshipList); - - assertEquals("vfModuleId", vfModule.getVfModuleId()); - assertEquals("vfModuleName", vfModule.getVfModuleName()); - assertEquals("heatStackId", vfModule.getHeatStackId()); - assertEquals("orchestrationStatus", vfModule.getOrchestrationStatus()); - assertTrue(vfModule.getIsBaseVfModule()); - assertEquals("resourceVersion", vfModule.getResourceVersion()); - assertEquals("modelInvariantId", vfModule.getModelInvariantId()); - assertEquals("modelVersionId", vfModule.getModelVersionId()); - assertEquals("modelCustomizationId", vfModule.getModelCustomizationId()); - assertEquals(new Integer(1), vfModule.getModuleIndex()); - assertEquals("relatedTo", vfModule.getRelationshipList().getRelationship().get(0).getRelatedTo()); - } - - @Test - public void testVfModuleWithParameters() { - VfModule vfModule = new VfModule("vfModuleId", "vfModuleName", "heatStackId", "orchestrationStatus", true, "resourceVersion", "modelInvariantId", "modelVersionId", "modelCustomizationId", 1, new RelationshipList() , new ArrayList<L3networkInstance>()); - - assertEquals("vfModuleId", vfModule.getVfModuleId()); - assertEquals("vfModuleName", vfModule.getVfModuleName()); - assertEquals("heatStackId", vfModule.getHeatStackId()); - assertEquals("orchestrationStatus", vfModule.getOrchestrationStatus()); - assertTrue(vfModule.getIsBaseVfModule()); - assertEquals("resourceVersion", vfModule.getResourceVersion()); - assertEquals("modelInvariantId", vfModule.getModelInvariantId()); - assertEquals("modelVersionId", vfModule.getModelVersionId()); - assertEquals("modelCustomizationId", vfModule.getModelCustomizationId()); - assertEquals(new Integer(1), vfModule.getModuleIndex()); - - String vfModuleString = vfModule.toString(); - assertTrue(vfModuleString.contains("[vfModuleId=vfModuleId,vfModuleName=vfModuleName,heatStackId=heatStackId,orchestrationStatus=orchestrationStatus,isBaseVfModule=true,resourceVersion=resourceVersion,modelInvariantId=modelInvariantId,modelVersionId=modelVersionId,modelCustomizationId=modelCustomizationId,moduleIndex=1")); - - } - - @Test - public void testVfModuleEquals() { - VfModule vfModule1 = new VfModule("vfModuleId1", "vfModuleName1", "heatStackId1", "orchestrationStatus1", true, "resourceVersion1", "modelInvariantId1", "modelVersionId1", "modelCustomizationId1", 1, new RelationshipList() , new ArrayList<L3networkInstance>()); - VfModule vfModule2 = new VfModule("vfModuleId2", "vfModuleName2", "heatStackId2", "orchestrationStatus2", true, "resourceVersion2", "modelInvariantId2", "modelVersionId2", "modelCustomizationId2", 1, new RelationshipList() , new ArrayList<L3networkInstance>()); - VfModule vfModule3 = new VfModule("vfModuleId1", "vfModuleName1", "heatStackId1", "orchestrationStatus1", true, "resourceVersion1", "modelInvariantId1", "modelVersionId1", "modelCustomizationId1", 1, new RelationshipList() , new ArrayList<L3networkInstance>()); - - assertTrue(vfModule1.equals(vfModule1)); - assertTrue(!vfModule1.equals(vfModule2)); - assertTrue(vfModule1.equals(vfModule3)); - } - -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VnfInstanceTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VnfInstanceTest.java deleted file mode 100644 index b9d9329..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VnfInstanceTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.pomba.contextbuilder.aai.datatype.RelationshipList; -import org.onap.pomba.contextbuilder.aai.datatype.VfModules; -import org.onap.pomba.contextbuilder.aai.datatype.VnfInstance; -import org.onap.pomba.contextbuilder.aai.datatype.LInterfaceInstanceList; - -public class VnfInstanceTest { - @Test - public void testVnfInstance() { - VnfInstance vnfInstance = new VnfInstance(); - - vnfInstance.setServiceId("serviceId"); - vnfInstance.setModelCustomizationId("modelCustomizationId"); - vnfInstance.setVnfType("vnfType"); - vnfInstance.setIpv4Loopback0Address("ipv4Loopback0Address"); - vnfInstance.setNfFunction("nfFunction"); - vnfInstance.setModelInvariantId("modelInvariantId"); - vnfInstance.setResourceVersion("resourceVersion"); - vnfInstance.setVnfName2("vnfName2"); - vnfInstance.setRelationshipList(new RelationshipList()); - vnfInstance.setNmLanV6Address("nmLanV6Address"); - vnfInstance.setNfRole("nfRole"); - vnfInstance.setNfType("nfType"); - vnfInstance.setModelVersionId("modelVersionId"); - vnfInstance.setIpv4OamAddress("ipv4OamAddress"); - vnfInstance.setVnfName("vnfName"); - vnfInstance.setInMaintenance(true); - vnfInstance.setMsoCatalogKey("msoCatalogKey"); - vnfInstance.setProvisionStatus("provisionStatus"); - vnfInstance.setVfModules(new VfModules()); - vnfInstance.setEquipmentRole("equipmentRole"); - vnfInstance.setVnfId("vnfId"); - vnfInstance.setOrchestrationStatus("orchestrationStatus"); - vnfInstance.setNfNamingCode("nfNamingCode"); - vnfInstance.setHeatStackId("heatStackId"); - vnfInstance.setIsClosedLoopDisabled(true); - vnfInstance.setLicenseKey("licenseKey"); - vnfInstance.setManagementV6Address("managementV6Address"); - - assertEquals("serviceId", vnfInstance.getServiceId()); - assertEquals("modelCustomizationId", vnfInstance.getModelCustomizationId()); - assertEquals("vnfType", vnfInstance.getVnfType()); - assertEquals("ipv4Loopback0Address", vnfInstance.getIpv4Loopback0Address()); - assertEquals("nfFunction", vnfInstance.getNfFunction()); - assertEquals("modelInvariantId", vnfInstance.getModelInvariantId()); - assertEquals("resourceVersion", vnfInstance.getResourceVersion()); - assertEquals("vnfName2", vnfInstance.getVnfName2()); - assertTrue(vnfInstance.getRelationshipList() instanceof RelationshipList); - assertEquals("nmLanV6Address", vnfInstance.getNmLanV6Address()); - assertEquals("nfRole", vnfInstance.getNfRole()); - assertEquals("nfType", vnfInstance.getNfType()); - assertEquals("modelVersionId", vnfInstance.getModelVersionId()); - assertEquals("ipv4OamAddress", vnfInstance.getIpv4OamAddress()); - assertEquals("vnfName", vnfInstance.getVnfName()); - assertTrue(vnfInstance.getInMaintenance()); - assertEquals("msoCatalogKey", vnfInstance.getMsoCatalogKey()); - assertEquals("provisionStatus", vnfInstance.getProvisionStatus()); - assertTrue(vnfInstance.getVfModules() instanceof VfModules); - assertEquals("equipmentRole", vnfInstance.getEquipmentRole()); - assertEquals("vnfId", vnfInstance.getVnfId()); - assertEquals("orchestrationStatus", vnfInstance.getOrchestrationStatus()); - assertEquals("nfNamingCode", vnfInstance.getNfNamingCode()); - assertEquals("heatStackId", vnfInstance.getHeatStackId()); - assertTrue(vnfInstance.getIsClosedLoopDisabled()); - assertEquals("licenseKey", vnfInstance.getLicenseKey()); - assertEquals("managementV6Address", vnfInstance.getManagementV6Address()); - - } - - @Test - public void testVnfInstanceWithParameters() { - VnfInstance vnfInstance = new VnfInstance("vnfId", "vnfName", "vnfName2", "vnfType", "serviceId", "provisionStatus", "licenseKey", "equipmentRole", "orchestrationStatus", "heatStackId", "msoCatalogKey", "ipv4OamAddress", "ipv4Loopback0Address", "nmLanV6Address", "managementV6Address", true, true, "resourceVersion", "modelInvariantId", "modelVersionId", "modelCustomizationId", "nfType", "nfFunction", "nfRole", "nfNamingCode", new RelationshipList(), new VfModules(), new LInterfaceInstanceList()); - - assertEquals("serviceId", vnfInstance.getServiceId()); - assertEquals("modelCustomizationId", vnfInstance.getModelCustomizationId()); - assertEquals("vnfType", vnfInstance.getVnfType()); - assertEquals("ipv4Loopback0Address", vnfInstance.getIpv4Loopback0Address()); - assertEquals("nfFunction", vnfInstance.getNfFunction()); - assertEquals("modelInvariantId", vnfInstance.getModelInvariantId()); - assertEquals("resourceVersion", vnfInstance.getResourceVersion()); - assertEquals("vnfName2", vnfInstance.getVnfName2()); - assertTrue(vnfInstance.getRelationshipList() instanceof RelationshipList); - assertEquals("nmLanV6Address", vnfInstance.getNmLanV6Address()); - assertEquals("nfRole", vnfInstance.getNfRole()); - assertEquals("nfType", vnfInstance.getNfType()); - assertEquals("modelVersionId", vnfInstance.getModelVersionId()); - assertEquals("ipv4OamAddress", vnfInstance.getIpv4OamAddress()); - assertEquals("vnfName", vnfInstance.getVnfName()); - assertTrue(vnfInstance.getInMaintenance()); - assertEquals("msoCatalogKey", vnfInstance.getMsoCatalogKey()); - assertEquals("provisionStatus", vnfInstance.getProvisionStatus()); - assertTrue(vnfInstance.getVfModules() instanceof VfModules); - assertEquals("equipmentRole", vnfInstance.getEquipmentRole()); - assertEquals("vnfId", vnfInstance.getVnfId()); - assertEquals("orchestrationStatus", vnfInstance.getOrchestrationStatus()); - assertEquals("nfNamingCode", vnfInstance.getNfNamingCode()); - assertEquals("heatStackId", vnfInstance.getHeatStackId()); - assertTrue(vnfInstance.getIsClosedLoopDisabled()); - assertEquals("licenseKey", vnfInstance.getLicenseKey()); - assertEquals("managementV6Address", vnfInstance.getManagementV6Address()); - - String vnfInstanceString = vnfInstance.toString(); - assertTrue(vnfInstanceString.contains("[vnfId=vnfId,vnfName=vnfName,vnfName2=vnfName2,vnfType=vnfType,serviceId=serviceId,provisionStatus=provisionStatus,licenseKey=licenseKey,equipmentRole=equipmentRole,orchestrationStatus=orchestrationStatus,heatStackId=heatStackId,msoCatalogKey=msoCatalogKey,ipv4OamAddress=ipv4OamAddress,ipv4Loopback0Address=ipv4Loopback0Address,nmLanV6Address=nmLanV6Address,managementV6Address=managementV6Address,inMaintenance=true,isClosedLoopDisabled=true,resourceVersion=resourceVersion,modelInvariantId=modelInvariantId,modelVersionId=modelVersionId,modelCustomizationId=modelCustomizationId,nfType=nfType,nfFunction=nfFunction,nfRole=nfRole,nfNamingCode=nfNamingCode,")); - } - - @Test - public void testVnfInstanceEquals() { - VnfInstance vnfInstance1 = new VnfInstance("vnfId1", "vnfName1", "vnfName2-1", "vnfType1", "serviceId1", "provisionStatus1", "licenseKey1", "equipmentRole1", "orchestrationStatus1", "heatStackId1", "msoCatalogKey1", "ipv4OamAddress1", "ipv4Loopback0Address1", "nmLanV6Address1", "managementV6Address1", true, true, "resourceVersion1", "modelInvariantId1", "modelVersionId1", "modelCustomizationId1", "nfType1", "nfFunction1", "nfRole1", "nfNamingCode1", new RelationshipList(), new VfModules(), new LInterfaceInstanceList()); - VnfInstance vnfInstance2 = new VnfInstance("vnfId2", "vnfName2", "vnfName2-2", "vnfType2", "serviceId2", "provisionStatus2", "licenseKey2", "equipmentRole2", "orchestrationStatus2", "heatStackId2", "msoCatalogKey2", "ipv4OamAddress2", "ipv4Loopback0Address2", "nmLanV6Address2", "managementV6Address2", true, true, "resourceVersion2", "modelInvariantId2", "modelVersionId2", "modelCustomizationId2", "nfType2", "nfFunction2", "nfRole2", "nfNamingCode2", new RelationshipList(), new VfModules(), new LInterfaceInstanceList()); - VnfInstance vnfInstance3 = new VnfInstance("vnfId1", "vnfName1", "vnfName2-1", "vnfType1", "serviceId1", "provisionStatus1", "licenseKey1", "equipmentRole1", "orchestrationStatus1", "heatStackId1", "msoCatalogKey1", "ipv4OamAddress1", "ipv4Loopback0Address1", "nmLanV6Address1", "managementV6Address1", true, true, "resourceVersion1", "modelInvariantId1", "modelVersionId1", "modelCustomizationId1", "nfType1", "nfFunction1", "nfRole1", "nfNamingCode1", new RelationshipList(), new VfModules(), new LInterfaceInstanceList()); - - assertTrue(vnfInstance1.equals(vnfInstance1)); - assertTrue(!vnfInstance1.equals(vnfInstance2)); - assertTrue(vnfInstance1.equals(vnfInstance3)); - - } -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VnfcInstanceTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VnfcInstanceTest.java deleted file mode 100644 index 29c55a9..0000000 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VnfcInstanceTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * 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.logging_analytics.pomba.pomba_aai_context_builder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.pomba.contextbuilder.aai.datatype.RelationshipList; -import org.onap.pomba.contextbuilder.aai.datatype.VnfcInstance; - -public class VnfcInstanceTest { - @Test - public void testVnfcInstance() { - VnfcInstance vnfcInstance = new VnfcInstance(); - vnfcInstance.setVnfcName("vnfcName"); - vnfcInstance.setNfcNamingCode("nfcNamingCode"); - vnfcInstance.setNfcFunction("nfcFunction"); - vnfcInstance.setProvisionStatus("provisionStatus"); - vnfcInstance.setOrchestrationStatus("orchestrationStatus"); - vnfcInstance.setInMaintenance(true); - vnfcInstance.setIsClosedLoopDisabled(true); - vnfcInstance.setResourceVersion("resourceVersion"); - vnfcInstance.setModelInvariantId("modelInvariantId"); - vnfcInstance.setModelVersionId("modelVersionId"); - vnfcInstance.setRelationshipList(new RelationshipList()); - - assertEquals("vnfcName", vnfcInstance.getVnfcName()); - assertEquals("nfcNamingCode", vnfcInstance.getNfcNamingCode()); - assertEquals("nfcFunction", vnfcInstance.getNfcFunction()); - assertEquals("provisionStatus", vnfcInstance.getProvisionStatus()); - assertEquals("orchestrationStatus", vnfcInstance.getOrchestrationStatus()); - assertTrue(vnfcInstance.getInMaintenance()); - assertTrue(vnfcInstance.getIsClosedLoopDisabled()); - assertEquals("resourceVersion", vnfcInstance.getResourceVersion()); - assertEquals("modelInvariantId", vnfcInstance.getModelInvariantId()); - assertEquals("modelVersionId", vnfcInstance.getModelVersionId()); - assertTrue(vnfcInstance.getRelationshipList() instanceof RelationshipList); - - } - - @Test - public void testVnfcInstanceWithParameters() { - VnfcInstance vnfcInstance = new VnfcInstance("vnfcName", "nfcNamingCode", "nfcFunction", "provisionStatus", "orchestrationStatus", true, true, "resourceVersion", "modelInvariantId", "modelVersionId", new RelationshipList()); - - assertEquals("vnfcName", vnfcInstance.getVnfcName()); - assertEquals("nfcNamingCode", vnfcInstance.getNfcNamingCode()); - assertEquals("nfcFunction", vnfcInstance.getNfcFunction()); - assertEquals("provisionStatus", vnfcInstance.getProvisionStatus()); - assertEquals("orchestrationStatus", vnfcInstance.getOrchestrationStatus()); - assertTrue(vnfcInstance.getInMaintenance()); - assertTrue(vnfcInstance.getIsClosedLoopDisabled()); - assertEquals("resourceVersion", vnfcInstance.getResourceVersion()); - assertEquals("modelInvariantId", vnfcInstance.getModelInvariantId()); - assertEquals("modelVersionId", vnfcInstance.getModelVersionId()); - assertTrue(vnfcInstance.getRelationshipList() instanceof RelationshipList); - - String vnfcInstanceString = vnfcInstance.toString(); - assertTrue(vnfcInstanceString.contains("[vnfcName=vnfcName,nfcNamingCode=nfcNamingCode,nfcFunction=nfcFunction,provisionStatus=provisionStatus,orchestration_status=orchestrationStatus,inMaintenance=true,isClosedLoopDisabled=true,resourceVersion=resourceVersion,modelInvariantId=modelInvariantId,modelVersionId=modelVersionId,")); - } - - @Test - public void testVnfcInstanceEquals() { - VnfcInstance vnfcInstance1 = new VnfcInstance("vnfcName1", "nfcNamingCode1", "nfcFunction1", "provisionStatus1", "orchestrationStatus1", true, true, "resourceVersion1", "modelInvariantId1", "modelVersionId1", new RelationshipList()); - VnfcInstance vnfcInstance2 = new VnfcInstance("vnfcName2", "nfcNamingCode2", "nfcFunction2", "provisionStatus2", "orchestrationStatus2", true, true, "resourceVersion2", "modelInvariantId2", "modelVersionId2", new RelationshipList()); - VnfcInstance vnfcInstance3 = new VnfcInstance("vnfcName1", "nfcNamingCode1", "nfcFunction1", "provisionStatus1", "orchestrationStatus1", true, true, "resourceVersion1", "modelInvariantId1", "modelVersionId1", new RelationshipList()); - - assertTrue(vnfcInstance1.equals(vnfcInstance1)); - assertTrue(!vnfcInstance1.equals(vnfcInstance2)); - assertTrue(vnfcInstance1.equals(vnfcInstance3)); - } -} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/RestServiceTest.java index c97ea1a..7e1248e 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/RestServiceTest.java @@ -15,13 +15,18 @@ * limitations under the License. * ============LICENSE_END===================================================== */ -package org.onap.logging_analytics.pomba.pomba_aai_context_builder.test; + +package org.onap.pomba.contextbuilder.aai.test; + import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.okJson; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; +import com.google.gson.Gson; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -29,6 +34,7 @@ import java.text.MessageFormat; import java.util.Collections; import java.util.List; import java.util.UUID; +import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; @@ -37,6 +43,11 @@ import javax.ws.rs.core.Response.Status; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.pomba.common.datatypes.ModelContext; +import org.onap.pomba.common.datatypes.VFModule; +import org.onap.pomba.common.datatypes.VM; +import org.onap.pomba.common.datatypes.VNF; +import org.onap.pomba.common.datatypes.VNFC; import org.onap.pomba.contextbuilder.aai.Application; import org.onap.pomba.contextbuilder.aai.service.rs.RestService; import org.onap.pomba.contextbuilder.aai.util.RestUtil; @@ -48,14 +59,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; -import org.onap.pomba.common.datatypes.ModelContext; -import org.onap.pomba.common.datatypes.VFModule; -import org.onap.pomba.common.datatypes.VM; -import org.onap.pomba.common.datatypes.VNF; -import org.onap.pomba.common.datatypes.VNFC; -import org.json.JSONObject; -import com.google.gson.Gson; -import com.github.tomakehurst.wiremock.junit.WireMockRule; @RunWith(SpringJUnit4ClassRunner.class) @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class}) @@ -78,6 +81,8 @@ public class RestServiceTest { HttpHeaders mockHttpHeaders = mock(HttpHeaders.class); + HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class); + private static final String DEPTH = "?depth=2"; @Rule @@ -101,11 +106,11 @@ public class RestServiceTest { } private static MultivaluedMap<String, String> buildHeaders( - String partnerName, String transactionId, String authorization) { + String partnerName, String requestId, String authorization) { MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); headers.put(RestUtil.FROM_APP_ID, Collections.singletonList(partnerName)); - headers.put(RestUtil.TRANSACTION_ID, Collections.singletonList(transactionId)); + headers.put(RestUtil.TRANSACTION_ID, Collections.singletonList(requestId)); if (null != authorization) { headers.put(RestUtil.AUTHORIZATION, Collections.singletonList(authorization)); } @@ -118,43 +123,52 @@ public class RestServiceTest { ///Verify the relationship serviceInstanceId -> vnf -> vserver -> pserver @Test - public void testGetContext_VSERVER_PSERVER() throws Exception { + public void testGetContextVserverPserver() throws Exception { - String transactionId = UUID.randomUUID().toString(); - String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json + String requestId = UUID.randomUUID().toString(); + String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders( - transactionId, testRestHeaders, httpBasicAuthorization); + requestId, testRestHeaders, httpBasicAuthorization); // 2. simulate the response of AAI (1 vnf) // note: match serviceInstanceId in (1) - addResponse( queryNodeUrl, - "junit/aai-service-instance_set2.json", aaiEnricherRule); + addResponse(queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) // note: match vnf_id in (2) - addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH, - "junit/genericVnfInput_set2.json", aaiEnricherRule); + addResponse("/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + + DEPTH, + "junit/genericVnfInput_set2.json", + aaiEnricherRule); // 4. simulate the rsp of vserer // note: match to vserver-id to the path of "vserver" in (3) - addResponse( - "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant" - + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + DEPTH, - "junit/aai-vserver.json", aaiEnricherRule); + addResponse("/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant" + + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + + DEPTH, + "junit/aai-vserver.json", + aaiEnricherRule); // 5. simulate the rsp of pserver // note: match pserver hostname to the path of "pserver" in (4) - addResponse( - "/aai/v13/cloud-infrastructure/pservers/pserver/mtn96compute.cci.att.com" + DEPTH, - "junit/pserverInput_set2.json", aaiEnricherRule); + addResponse("/aai/v13/cloud-infrastructure/pservers/pserver/mtn96compute.cci.att.com" + + DEPTH, + "junit/pserverInput_set2.json", + aaiEnricherRule); when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl); - Response response = this.dummyRestSvc.getContext(mockHttpHeaders, httpBasicAuthorization, testRestHeaders, transactionId, - serviceInstanceId); + when(mockHttpServletRequest.getRemoteAddr()).thenReturn("testGetContextVserverPserver"); + + Response response = this.dummyRestSvc.getContext(mockHttpHeaders, + mockHttpServletRequest, + httpBasicAuthorization, + testRestHeaders, + requestId, + serviceInstanceId); assertEquals(Status.OK.getStatusCode(), response.getStatus()); Gson gson = new Gson(); @@ -171,55 +185,65 @@ public class RestServiceTest { } - ///Verify the relationship serviceInstanceId -> vnf (containing L-Interface) -> vserver (containing - LInterfaceList) + // Verify the relationship + // serviceInstanceId -> vnf (containing L-Interface) -> vserver (containing - LInterfaceList) @Test - public void testGetContext_VSERVER_L_interface_And_Logical_link() throws Exception { + public void testGetContextVserverLinterfaceAndLogicalLink() throws Exception { - String transactionId = UUID.randomUUID().toString(); - String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json + String requestId = UUID.randomUUID().toString(); + String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders( - transactionId, testRestHeaders, httpBasicAuthorization); + requestId, testRestHeaders, httpBasicAuthorization); // 2. simulate the response of AAI (1 vnf) - addResponse( queryNodeUrl, - "junit/aai-service-instance_set2.json", aaiEnricherRule); + addResponse(queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) // note: match vnf_id in (2) - addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH, - "junit/genericVnfInput_set6.json", aaiEnricherRule); + addResponse("/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + + DEPTH, + "junit/genericVnfInput_set6.json", + aaiEnricherRule); // 4. simulate the rsp of vserer // note: match to vserver-id to the path of "vserver" in (3) - addResponse( - "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant" - + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + DEPTH, - "junit/aai-vserver-set3.json", aaiEnricherRule); + addResponse("/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant" + + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + + DEPTH, + "junit/aai-vserver-set3.json", + aaiEnricherRule); // 5. simulate the rsp of logical-link // note: match to link-name to the path of "relationship-list" in (3: genericVnfInput_set6) // and match the link-name to (4 aai-vserver-set3.json) - addResponse( - "/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-1", - "junit/logical-link-input1.json", aaiEnricherRule); - addResponse( - "/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-2", - "junit/logical-link-input2.json", aaiEnricherRule); - addResponse( - "/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-3", - "junit/logical-link-input3.json", aaiEnricherRule); - addResponse( - "/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-4", - "junit/logical-link-input4.json", aaiEnricherRule); + addResponse("/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-1", + "junit/logical-link-input1.json", + aaiEnricherRule); + addResponse("/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-2", + "junit/logical-link-input2.json", + aaiEnricherRule); + addResponse("/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-3", + "junit/logical-link-input3.json", + aaiEnricherRule); + addResponse("/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-4", + "junit/logical-link-input4.json", + aaiEnricherRule); when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl); - Response response = this.dummyRestSvc.getContext(mockHttpHeaders, httpBasicAuthorization, testRestHeaders, transactionId, - serviceInstanceId); + when(mockHttpServletRequest.getRemoteAddr()).thenReturn("testGetContextVserverLinterfaceAndLogicalLink"); + + + Response response = this.dummyRestSvc.getContext(mockHttpHeaders, + mockHttpServletRequest, + httpBasicAuthorization, + testRestHeaders, + requestId, + serviceInstanceId); assertEquals(Status.OK.getStatusCode(), response.getStatus()); Gson gson = new Gson(); @@ -228,65 +252,81 @@ public class RestServiceTest { List<VNF> vnfList = modelCtx.getVnfs(); assertEquals(vnfList.size(), 1); assertEquals(vnfList.get(0).getLInterfaceList().size(), 2); - assertEquals(vnfList.get(0).getLInterfaceList().get(0).getName(), "junit-l-interface-name3"); //l-interface-name - assertEquals(vnfList.get(0).getLInterfaceList().get(1).getName(), "junit-l-interface-name4"); //l-interface-name + assertEquals(vnfList.get(0).getLInterfaceList().get(0).getName(), + "junit-l-interface-name3"); //l-interface-name + assertEquals(vnfList.get(0).getLInterfaceList().get(1).getName(), + "junit-l-interface-name4"); //l-interface-name assertEquals(vnfList.get(0).getLInterfaceList().get(0).getLogicalLinkList().size(), 1); - assertEquals(vnfList.get(0).getLInterfaceList().get(0).getLogicalLinkList().get(0).getName(), "01e8d84a-logical-link-3"); //Logical-link at vnf->l-interface -> Logical-link + assertEquals(vnfList.get(0).getLInterfaceList().get(0).getLogicalLinkList().get(0).getName(), + "01e8d84a-logical-link-3"); //Logical-link at vnf->l-interface -> Logical-link assertEquals(vnfList.get(0).getLInterfaceList().get(1).getLogicalLinkList().size(), 1); - assertEquals(vnfList.get(0).getLInterfaceList().get(1).getLogicalLinkList().get(0).getName(), "01e8d84a-logical-link-4"); + assertEquals(vnfList.get(0).getLInterfaceList().get(1).getLogicalLinkList().get(0).getName(), + "01e8d84a-logical-link-4"); List<VFModule> vfModuleList = vnfList.get(0).getVfModules(); assertEquals(vfModuleList.size(), 1); List<VM> vmList = vfModuleList.get(0).getVms(); assertEquals(vmList.size(), 1); assertEquals(vmList.get(0).getUuid(), "b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a"); //vserver-id assertEquals(vmList.get(0).getLInterfaceList().size(), 2); - assertEquals(vmList.get(0).getLInterfaceList().get(0).getName(), "junit-l-interface-name1"); //l-interface-name - assertEquals(vmList.get(0).getLInterfaceList().get(1).getName(), "junit-l-interface-name2"); //l-interface-name + assertEquals(vmList.get(0).getLInterfaceList().get(0).getName(), + "junit-l-interface-name1"); //l-interface-name + assertEquals(vmList.get(0).getLInterfaceList().get(1).getName(), + "junit-l-interface-name2"); //l-interface-name assertEquals(vmList.get(0).getLInterfaceList().get(0).getLogicalLinkList().size(), 1); - assertEquals(vmList.get(0).getLInterfaceList().get(0).getLogicalLinkList().get(0).getName(), "01e8d84a-logical-link-1"); //Logical-link at vserver->l-interface -> Logical-link + assertEquals(vmList.get(0).getLInterfaceList().get(0).getLogicalLinkList().get(0).getName(), + "01e8d84a-logical-link-1"); //Logical-link at vserver->l-interface -> Logical-link assertEquals(vmList.get(0).getLInterfaceList().get(1).getLogicalLinkList().size(), 1); - assertEquals(vmList.get(0).getLInterfaceList().get(1).getLogicalLinkList().get(0).getName(), "01e8d84a-logical-link-2"); + assertEquals(vmList.get(0).getLInterfaceList().get(1).getLogicalLinkList().get(0).getName(), + "01e8d84a-logical-link-2"); } ///Verify the relationship serviceInstanceId -> vnf + vnfc @Test - public void testGetContext_VNFC() throws Exception { + public void testGetContextVnfc() throws Exception { - String transactionId = UUID.randomUUID().toString(); - String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json + String requestId = UUID.randomUUID().toString(); + String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders( - transactionId, testRestHeaders, httpBasicAuthorization); + requestId, testRestHeaders, httpBasicAuthorization); // 2. simulate the response of AAI (1 vnf) - addResponse( queryNodeUrl, - "junit/aai-service-instance_set2.json", aaiEnricherRule); + addResponse(queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) // note: match vnf_id in (2) - addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH, - "junit/genericVnfInput_set5.json", aaiEnricherRule); + addResponse("/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + + DEPTH, + "junit/genericVnfInput_set5.json", + aaiEnricherRule); // 4. simulate the rsp of vserer // note: match to vserver-id to the path of "vserver" in (3) - addResponse( - "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant" - + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + DEPTH, - "junit/aai-vserver-set2.json", aaiEnricherRule); + addResponse("/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant" + + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + + DEPTH, + "junit/aai-vserver-set2.json", + aaiEnricherRule); // 5. simulate the rsp of vnfc // note: match to vnfc-name to the path of "vnfc" in (3) - addResponse( - "/aai/v13/network/vnfcs/vnfc/junit-vnfc-name1212", - "junit/vnfc-input1.json", aaiEnricherRule); + addResponse("/aai/v13/network/vnfcs/vnfc/junit-vnfc-name1212", + "junit/vnfc-input1.json", + aaiEnricherRule); when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl); - Response response = this.dummyRestSvc.getContext(mockHttpHeaders, httpBasicAuthorization, testRestHeaders, transactionId, - serviceInstanceId); + when(mockHttpServletRequest.getRemoteAddr()).thenReturn("testGetContextVnfc"); + + Response response = this.dummyRestSvc.getContext(mockHttpHeaders, + mockHttpServletRequest, + httpBasicAuthorization, + testRestHeaders, + requestId, + serviceInstanceId); assertEquals(Status.OK.getStatusCode(), response.getStatus()); Gson gson = new Gson(); @@ -307,42 +347,50 @@ public class RestServiceTest { ///Verify the relationship serviceInstanceId -> vnf + vnfc @Test - public void testGetContext_VNFC2() throws Exception { + public void testGetContextVnfc2() throws Exception { - String transactionId = UUID.randomUUID().toString(); - String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json + String requestId = UUID.randomUUID().toString(); + String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders( - transactionId, testRestHeaders, httpBasicAuthorization); + requestId, testRestHeaders, httpBasicAuthorization); // 2. simulate the response of AAI (1 vnf) - addResponse( queryNodeUrl, - "junit/aai-service-instance_set2.json", aaiEnricherRule); + addResponse(queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) // note: match vnf_id in (2) - addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH, - "junit/genericVnfInput_set5.json", aaiEnricherRule); + addResponse("/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + + DEPTH, + "junit/genericVnfInput_set5.json", + aaiEnricherRule); // 4. simulate the rsp of vserer // note: match to vserver-id to the path of "vserver" in (3) - addResponse( - "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant" - + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + DEPTH, - "junit/aai-vserver-set2.json", aaiEnricherRule); + addResponse("/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant" + + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + + DEPTH, + "junit/aai-vserver-set2.json", + aaiEnricherRule); // 5. simulate the rsp of vnfc // note: match to vnfc-name to the path of "vnfc" in (3) - addResponse( - "/aai/v13/network/vnfcs/vnfc/junit-vnfc-name1212", - "junit/vnfc-input1.json", aaiEnricherRule); + addResponse("/aai/v13/network/vnfcs/vnfc/junit-vnfc-name1212", + "junit/vnfc-input1.json", + aaiEnricherRule); when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl); - Response response = this.dummyRestSvc.getContext(mockHttpHeaders, httpBasicAuthorization, testRestHeaders, transactionId, - serviceInstanceId); + when(mockHttpServletRequest.getRemoteAddr()).thenReturn("testGetContextVnfc2"); + + Response response = this.dummyRestSvc.getContext(mockHttpHeaders, + mockHttpServletRequest, + httpBasicAuthorization, + testRestHeaders, + requestId, + serviceInstanceId); assertEquals(Status.OK.getStatusCode(), response.getStatus()); Gson gson = new Gson(); @@ -363,31 +411,35 @@ public class RestServiceTest { ///Verify the relationship serviceInstanceId -> vnf + vnfc @Test - public void testGetContext_LogicalLink_in_service_level() throws Exception { - String transactionId = UUID.randomUUID().toString(); - String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json + public void testGetContextLogicalLinkInServiceLevel() throws Exception { + String requestId = UUID.randomUUID().toString(); + String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders( - transactionId, testRestHeaders, httpBasicAuthorization); + requestId, testRestHeaders, httpBasicAuthorization); // 2. simulate the response of AAI (1 vnf) - addResponse( queryNodeUrl, - "junit/aai-service-instance_set4.json", aaiEnricherRule); + addResponse(queryNodeUrl, "junit/aai-service-instance_set4.json", aaiEnricherRule); // 3. simulate the rsp of logical-link // note: match to link-name to the path of "relationship-list" in (2: aai-service-instance_set4) - addResponse( - "/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-1", - "junit/logical-link-input1.json", aaiEnricherRule); - addResponse( - "/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-2", - "junit/logical-link-input2.json", aaiEnricherRule); + addResponse("/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-1", + "junit/logical-link-input1.json", aaiEnricherRule); + addResponse("/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-2", + "junit/logical-link-input2.json", aaiEnricherRule); when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl); - Response response = this.dummyRestSvc.getContext(mockHttpHeaders, httpBasicAuthorization, testRestHeaders, transactionId, - serviceInstanceId); + + when(mockHttpServletRequest.getRemoteAddr()).thenReturn("testGetContextLogicalLinkInServiceLevel"); + + Response response = this.dummyRestSvc.getContext(mockHttpHeaders, + mockHttpServletRequest, + httpBasicAuthorization, + testRestHeaders, + requestId, + serviceInstanceId); assertEquals(Status.OK.getStatusCode(), response.getStatus()); Gson gson = new Gson(); @@ -399,40 +451,50 @@ public class RestServiceTest { ///Verify the relationship P-interface, L-interaface, Logical-link @Test - public void testGetContext_LogicalLink_in_PInterface_level_with_PNF() throws Exception { - String transactionId = UUID.randomUUID().toString(); - String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json + public void testGetContextLogicalLinkInPInterfaceLevelWithPnf() throws Exception { + String requestId = UUID.randomUUID().toString(); + String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders( - transactionId, testRestHeaders, httpBasicAuthorization); + requestId, testRestHeaders, httpBasicAuthorization); // 2. simulate the response of AAI (1 vnf and 1 pnf) - addResponse( queryNodeUrl, - "junit/aai-service-instance.json", aaiEnricherRule); + addResponse(queryNodeUrl, "junit/aai-service-instance.json", aaiEnricherRule); // 3. simulate the rsp of VNF - addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH, - "junit/genericVnfInput.json", aaiEnricherRule); + addResponse("/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + + DEPTH, + "junit/genericVnfInput.json", + aaiEnricherRule); // 4. simulate the response of PNF based on the resourceLink in (2) //note: match pnf_id in junit/aai-service-instance.json - addResponse( "/aai/v13/network/pnfs/pnf/amdocsPnfName" + DEPTH, - "junit/pnfInput_w_pInterface_LInterface_set2.json", aaiEnricherRule); + addResponse("/aai/v13/network/pnfs/pnf/amdocsPnfName" + + DEPTH, + "junit/pnfInput_w_pInterface_LInterface_set2.json", + aaiEnricherRule); // 5. simulate the rsp of logical-link // note: match to link-name to the path of "relationship-list" in (4: pnfInput_w_pInterface_LInterface_set2) - addResponse( - "/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-1", - "junit/logical-link-input1.json", aaiEnricherRule); - addResponse( - "/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-2", - "junit/logical-link-input2.json", aaiEnricherRule); + addResponse("/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-1", + "junit/logical-link-input1.json", + aaiEnricherRule); + addResponse("/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-2", + "junit/logical-link-input2.json", + aaiEnricherRule); when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl); - Response response = this.dummyRestSvc.getContext(mockHttpHeaders, httpBasicAuthorization, testRestHeaders, transactionId, - serviceInstanceId); + + when(mockHttpServletRequest.getRemoteAddr()).thenReturn("testGetContextLogicalLinkInPInterfaceLevelWithPnf"); + + Response response = this.dummyRestSvc.getContext(mockHttpHeaders, + mockHttpServletRequest, + httpBasicAuthorization, + testRestHeaders, + requestId, + serviceInstanceId); assertEquals(Status.OK.getStatusCode(), response.getStatus()); Gson gson = new Gson(); @@ -441,64 +503,81 @@ public class RestServiceTest { assertEquals(modelCtx.getPnfs().size(), 1); assertEquals(modelCtx.getPnfs().get(0).getPInterfaceList().size(), 1); assertEquals(modelCtx.getPnfs().get(0).getPInterfaceList().get(0).getLInterfaceList().size(), 2); - assertEquals(modelCtx.getPnfs().get(0).getPInterfaceList().get(0).getLInterfaceList().get(0).getName(), "junit-l-interface-name5"); //l-interface-name - assertEquals(modelCtx.getPnfs().get(0).getPInterfaceList().get(0).getLInterfaceList().get(1).getName(), "junit-l-interface-name6"); //l-interface-name + assertEquals(modelCtx.getPnfs().get(0).getPInterfaceList().get(0).getLInterfaceList().get(0).getName(), + "junit-l-interface-name5"); //l-interface-name + assertEquals(modelCtx.getPnfs().get(0).getPInterfaceList().get(0).getLInterfaceList().get(1).getName(), + "junit-l-interface-name6"); //l-interface-name assertEquals(modelCtx.getPnfs().get(0).getPInterfaceList().get(0).getLogicalLinkList().size(), 2); - assertEquals(modelCtx.getPnfs().get(0).getPInterfaceList().get(0).getLogicalLinkList().get(0).getName(), "01e8d84a-logical-link-1"); - assertEquals(modelCtx.getPnfs().get(0).getPInterfaceList().get(0).getLogicalLinkList().get(1).getName(), "01e8d84a-logical-link-2"); + assertEquals(modelCtx.getPnfs().get(0).getPInterfaceList().get(0).getLogicalLinkList().get(0).getName(), + "01e8d84a-logical-link-1"); + assertEquals(modelCtx.getPnfs().get(0).getPInterfaceList().get(0).getLogicalLinkList().get(1).getName(), + "01e8d84a-logical-link-2"); } ///Verify the relationship P-interface, L-interaface, Logical-link @Test - public void testGetContext_LogicalLink_in_PInterface_level_with_PSERVER() throws Exception { - String transactionId = UUID.randomUUID().toString(); - String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json + public void testGetContextLogicalLinkInPInterfaceLevelWithPserver() throws Exception { + String requestId = UUID.randomUUID().toString(); + String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders( - transactionId, testRestHeaders, httpBasicAuthorization); + requestId, testRestHeaders, httpBasicAuthorization); // 2. simulate the response of AAI (1 vnf) - addResponse( queryNodeUrl, - "junit/aai-service-instance_set2.json", aaiEnricherRule); + addResponse(queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) // note: match vnf_id in (2) - addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH, - "junit/genericVnfInput_set2.json", aaiEnricherRule); + addResponse("/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + + DEPTH, + "junit/genericVnfInput_set2.json", + aaiEnricherRule); // 4. simulate the rsp of vserer // note: match to vserver-id to the path of "vserver" in (3) - addResponse( - "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant" - + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + DEPTH, - "junit/aai-vserver.json", aaiEnricherRule); + addResponse("/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant" + + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + + DEPTH, + "junit/aai-vserver.json", + aaiEnricherRule); // 5. simulate the rsp of pserver with P-interface which also contains L-interface. // note: match pserver hostname to the path of "pserver" in (4) - addResponse( - "/aai/v13/cloud-infrastructure/pservers/pserver/mtn96compute.cci.att.com" + DEPTH, - "junit/pserverInput_with_pInterface_LInterface_set2.json", aaiEnricherRule); + addResponse("/aai/v13/cloud-infrastructure/pservers/pserver/mtn96compute.cci.att.com" + + DEPTH, + "junit/pserverInput_with_pInterface_LInterface_set2.json", + aaiEnricherRule); // 6. simulate the rsp of logical-link - // note: match to link-name to the path of "relationship-list" in (5: pserverInput_with_pInterface_LInterface_set2) - addResponse( - "/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-1", - "junit/logical-link-input1.json", aaiEnricherRule); - addResponse( - "/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-2", - "junit/logical-link-input2.json", aaiEnricherRule); - addResponse( - "/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-3", - "junit/logical-link-input3.json", aaiEnricherRule); - addResponse( - "/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-4", - "junit/logical-link-input4.json", aaiEnricherRule); + // note: match to link-name to the path of "relationship-list" in + // (5: pserverInput_with_pInterface_LInterface_set2) + addResponse("/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-1", + "junit/logical-link-input1.json", + aaiEnricherRule); + addResponse("/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-2", + "junit/logical-link-input2.json", + aaiEnricherRule); + addResponse("/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-3", + "junit/logical-link-input3.json", + aaiEnricherRule); + addResponse("/aai/v13/network/logical-links/logical-link/01e8d84a-logical-link-4", + "junit/logical-link-input4.json", + aaiEnricherRule); when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl); - Response response = this.dummyRestSvc.getContext(mockHttpHeaders, httpBasicAuthorization, testRestHeaders, transactionId, - serviceInstanceId); + + when(mockHttpServletRequest + .getRemoteAddr()) + .thenReturn("testGetContextLogicalLinkInPInterfaceLevelWithPserver"); + + Response response = this.dummyRestSvc.getContext(mockHttpHeaders, + mockHttpServletRequest, + httpBasicAuthorization, + testRestHeaders, + requestId, + serviceInstanceId); assertEquals(Status.OK.getStatusCode(), response.getStatus()); Gson gson = new Gson(); @@ -511,16 +590,27 @@ public class RestServiceTest { List<VM> vmList = vfModuleList.get(0).getVms(); assertEquals(vmList.size(), 1); assertEquals(vmList.get(0).getPServer().getPInterfaceList().size(), 1); - assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getName(), "bdc3cc2a-c73e-414f-7ddb-367de92801cb"); //interface-name + assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getName(), + "bdc3cc2a-c73e-414f-7ddb-367de92801cb"); //interface-name assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLInterfaceList().size(), 2); - assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLInterfaceList().get(0).getName(), "junit-l-interface-name7"); //Vserver-> Pserver-> P-interface -> l-interface - assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLInterfaceList().get(1).getName(), "junit-l-interface-name8"); - assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLInterfaceList().get(0).getLogicalLinkList().size(), 1); - assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLInterfaceList().get(0).getLogicalLinkList().get(0).getName(), "01e8d84a-logical-link-3"); //Vserver-> Pserver-> P-interface -> l-interface -> logical-link - assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLInterfaceList().get(1).getLogicalLinkList().size(), 1); - assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLInterfaceList().get(1).getLogicalLinkList().get(0).getName(), "01e8d84a-logical-link-4"); + assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLInterfaceList().get(0).getName(), + "junit-l-interface-name7"); //Vserver-> Pserver-> P-interface -> l-interface + assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLInterfaceList().get(1).getName(), + "junit-l-interface-name8"); + assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLInterfaceList().get(0) + .getLogicalLinkList().size(), 1); + assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLInterfaceList().get(0) + .getLogicalLinkList().get(0).getName(), + "01e8d84a-logical-link-3"); //Vserver-> Pserver-> P-interface -> l-interface -> logical-link + assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLInterfaceList().get(1) + .getLogicalLinkList().size(), 1); + assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLInterfaceList().get(1) + .getLogicalLinkList().get(0).getName(), + "01e8d84a-logical-link-4"); assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLogicalLinkList().size(), 2); - assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLogicalLinkList().get(0).getName(), "01e8d84a-logical-link-1"); //Vserver-> Pserver-> P-interface -> Logical-link - assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLogicalLinkList().get(1).getName(), "01e8d84a-logical-link-2"); + assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLogicalLinkList().get(0).getName(), + "01e8d84a-logical-link-1"); //Vserver-> Pserver-> P-interface -> Logical-link + assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getLogicalLinkList().get(1).getName(), + "01e8d84a-logical-link-2"); } } diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/RestUtilTest.java index 8c445c1..bbf4c8f 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/RestUtilTest.java @@ -15,23 +15,33 @@ * limitations under the License. * ============LICENSE_END===================================================== */ -package org.onap.logging_analytics.pomba.pomba_aai_context_builder; +package org.onap.pomba.contextbuilder.aai.test; import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.okJson; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.text.MessageFormat; import java.util.List; import java.util.UUID; +import javax.servlet.http.HttpServletRequest; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.aai.restclient.client.RestClient; +import org.onap.pomba.common.datatypes.ModelContext; +import org.onap.pomba.common.datatypes.Network; +import org.onap.pomba.common.datatypes.VFModule; +import org.onap.pomba.common.datatypes.VM; +import org.onap.pomba.common.datatypes.VNF; import org.onap.pomba.contextbuilder.aai.Application; import org.onap.pomba.contextbuilder.aai.exception.AuditException; import org.onap.pomba.contextbuilder.aai.util.RestUtil; @@ -43,12 +53,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import org.onap.pomba.common.datatypes.ModelContext; -import org.onap.pomba.common.datatypes.VNF; -import org.onap.pomba.common.datatypes.VFModule; -import org.onap.pomba.common.datatypes.VM; -import org.onap.pomba.common.datatypes.Network; @RunWith(SpringJUnit4ClassRunner.class) @EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class }) @@ -65,6 +69,10 @@ public class RestUtilTest { @Autowired private String aaiBasicAuthorization; + HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class); + + private String partnerName = "RestUtilTest"; + private static final String DEPTH = "?depth=2"; @Rule @@ -116,9 +124,9 @@ public class RestUtilTest { //// @Test - public void testretrieveAAIModelDataFromAAI_PNF() throws Exception { + public void testretrieveAaiModelDataFromAaiPnf() throws Exception { - String transactionId = UUID.randomUUID().toString(); + String requestId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); @@ -136,17 +144,25 @@ public class RestUtilTest { addResponse( "/aai/v13/network/pnfs/pnf/amdocsPnfName" + DEPTH, "junit/pnfSampleInput.json", aaiEnricherRule); - ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + when(mockHttpServletRequest.getRemoteAddr()).thenReturn("testretrieveAaiModelDataFromAaiPnf"); + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, + aaiBaseUrl, + aaiPathToSearchNodeQuery, + mockHttpServletRequest, + requestId, + partnerName, + serviceInstanceId, + aaiBasicAuthorization); assertEquals(modelCtx.getVnfs().size(), 1); assertEquals(modelCtx.getPnfs().size(), 1); } ///Verify the relationship serviceInstanceId -> vnf -> vserver @Test - public void testretrieveAAIModelDataFromAAI_VSERVER_PSERVER() throws Exception { + public void testretrieveAaiModelDataFromAaiVserverPserver() throws Exception { - String transactionId = UUID.randomUUID().toString(); + String requestId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); @@ -173,8 +189,16 @@ public class RestUtilTest { "/aai/v13/cloud-infrastructure/pservers/pserver/mtn96compute.cci.att.com" + DEPTH, "junit/pserverInput_set2.json", aaiEnricherRule); - ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + when(mockHttpServletRequest.getRemoteAddr()).thenReturn("testretrieveAaiModelDataFromAaiVserverPserver"); + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, + aaiBaseUrl, + aaiPathToSearchNodeQuery, + mockHttpServletRequest, + requestId, + partnerName, + serviceInstanceId, + aaiBasicAuthorization); // verify results List<VNF> vnfList = modelCtx.getVnfs(); assertEquals(vnfList.size(), 1); @@ -188,9 +212,9 @@ public class RestUtilTest { //// @Test - public void testretrieveAAIModelDataFromAAI_PInterface_LInterface_with_PNF() throws Exception { + public void testretrieveAaiModelDataFromAaiPinterfaceLinterfaceWithPnf() throws Exception { - String transactionId = UUID.randomUUID().toString(); + String requestId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // 2. simulate the response of AAI (1 vnf and 1 pnf) @@ -206,7 +230,18 @@ public class RestUtilTest { addResponse( "/aai/v13/network/pnfs/pnf/amdocsPnfName" + DEPTH, "junit/pnfInput_w_pInterface_LInterface.json", aaiEnricherRule); - ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + when(mockHttpServletRequest + .getRemoteAddr()) + .thenReturn("testretrieveAaiModelDataFromAaiPinterfaceLinterfaceWithPnf"); + + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, + aaiBaseUrl, + aaiPathToSearchNodeQuery, + mockHttpServletRequest, + requestId, + partnerName, + serviceInstanceId, + aaiBasicAuthorization); assertEquals(modelCtx.getVnfs().size(), 1); assertEquals(modelCtx.getPnfs().size(), 1); @@ -217,9 +252,9 @@ public class RestUtilTest { } @Test - public void testretrieveAAIModelDataFromAAI_PInterface_LInterface_with_PSERVER() throws Exception { + public void testretrieveAaiModelDataFromAaiPinterfaceLinterfaceWithPserver() throws Exception { - String transactionId = UUID.randomUUID().toString(); + String requestId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // 2. simulate the response of AAI (1 vnf) @@ -244,7 +279,18 @@ public class RestUtilTest { "/aai/v13/cloud-infrastructure/pservers/pserver/mtn96compute.cci.att.com" + DEPTH, "junit/pserverInput_with_pInterface_LInterface.json", aaiEnricherRule); - ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + when(mockHttpServletRequest + .getRemoteAddr()) + .thenReturn("testretrieveAaiModelDataFromAaiPinterfaceLinterfaceWithPserver"); + + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, + aaiBaseUrl, + aaiPathToSearchNodeQuery, + mockHttpServletRequest, + requestId, + partnerName, + serviceInstanceId, + aaiBasicAuthorization); // verify results List<VNF> vnfList = modelCtx.getVnfs(); @@ -262,9 +308,9 @@ public class RestUtilTest { ///Verify the relationship serviceInstanceId -> l3network @Test - public void testretrieveAAIModelDataFromAAI_L3_network_in_service_level () throws Exception { + public void testretrieveAaiModelDataFromAaiL3NetworkInServiceLevel () throws Exception { - String transactionId = UUID.randomUUID().toString(); + String requestId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // 2. simulate the response of AAI (1 vnf) @@ -281,7 +327,18 @@ public class RestUtilTest { "junit/l3-network-2.json", aaiEnricherRule); - ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + when(mockHttpServletRequest + .getRemoteAddr()) + .thenReturn("testretrieveAaiModelDataFromAaiL3NetworkInServiceLevel"); + + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, + aaiBaseUrl, + aaiPathToSearchNodeQuery, + mockHttpServletRequest, + requestId, + partnerName, + serviceInstanceId, + aaiBasicAuthorization); // verify results List<Network> networkList = modelCtx.getNetworkList(); @@ -292,9 +349,9 @@ public class RestUtilTest { ///Verify the relationship serviceInstanceId -> vnf -> l3network @Test - public void testretrieveAAIModelDataFromAAI_L3_network_in_VNF_level() throws Exception { + public void testretrieveAaiModelDataFromAaiL3NetworkInVnfLevel() throws Exception { - String transactionId = UUID.randomUUID().toString(); + String requestId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // 2. simulate the response of AAI (1 vnf) @@ -319,7 +376,18 @@ public class RestUtilTest { "/aai/v13/network/l3-networks/l3-network/01e8d84a-l3-network-1" + DEPTH, "junit/l3-network-1.json", aaiEnricherRule); - ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + when(mockHttpServletRequest + .getRemoteAddr()) + .thenReturn("testretrieveAaiModelDataFromAaiL3NetworkInVnfLevel"); + + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, + aaiBaseUrl, + aaiPathToSearchNodeQuery, + mockHttpServletRequest, + requestId, + partnerName, + serviceInstanceId, + aaiBasicAuthorization); // verify results List<VNF> vnfList = modelCtx.getVnfs(); @@ -330,9 +398,9 @@ public class RestUtilTest { } @Test - public void testretrieveAAIModelDataFromAAI_L3_network_in_vModule_level() throws Exception { + public void testretrieveAaiModelDataFromAaiL3NetworkInvModuleLevel() throws Exception { - String transactionId = UUID.randomUUID().toString(); + String requestId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // 2. simulate the response of AAI (1 vnf) @@ -361,8 +429,18 @@ public class RestUtilTest { "junit/l3-network-2.json", aaiEnricherRule); - ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + when(mockHttpServletRequest + .getRemoteAddr()) + .thenReturn("testretrieveAaiModelDataFromAaiL3NetworkInvModuleLevel"); + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, + aaiBaseUrl, + aaiPathToSearchNodeQuery, + mockHttpServletRequest, + requestId, + partnerName, + serviceInstanceId, + aaiBasicAuthorization); // verify results List<VNF> vnfList = modelCtx.getVnfs(); assertEquals(vnfList.size(), 1); diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/AppTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/AppTest.java index cb631cc..9e274b2 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/AppTest.java +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/AppTest.java @@ -15,7 +15,8 @@ * limitations under the License. * ============LICENSE_END===================================================== */ -package org.onap.logging_analytics.pomba.pomba_aai_context_builder; + +package org.onap.pomba.contextbuilder.aai.test.datatype; import junit.framework.Test; import junit.framework.TestCase; @@ -24,32 +25,27 @@ import junit.framework.TestSuite; /** * Unit test for simple App. */ -public class AppTest - extends TestCase -{ +public class AppTest extends TestCase { /** * Create the test case * * @param testName name of the test case */ - public AppTest( String testName ) - { + public AppTest( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ - public static Test suite() - { + public static Test suite() { return new TestSuite( AppTest.class ); } /** * Rigourous Test :-) */ - public void testApp() - { + public void testApp() { assertTrue( true ); } } diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/GenericResponseTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/GenericResponseTest.java index ce11d61..d64b2e8 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/GenericResponseTest.java +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/GenericResponseTest.java @@ -14,11 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END===================================================== + * */ -package org.onap.logging_analytics.pomba.pomba_aai_context_builder; + +package org.onap.pomba.contextbuilder.aai.test.datatype; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.onap.pomba.contextbuilder.aai.model.GenericResponse; diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/JerseyConfigurationTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/JerseyConfigurationTest.java index a0570c3..dde6f8d 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/JerseyConfigurationTest.java +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/JerseyConfigurationTest.java @@ -14,8 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END===================================================== + * */ -package org.onap.logging_analytics.pomba.pomba_aai_context_builder; + +package org.onap.pomba.contextbuilder.aai.test.datatype; import static org.junit.Assert.assertEquals; @@ -24,11 +26,11 @@ import org.junit.Test; import org.onap.pomba.contextbuilder.aai.JerseyConfiguration; public class JerseyConfigurationTest { - @Test - public void testJerseyConfiguration() { - JerseyConfiguration jerseyConfiguration = new JerseyConfiguration(); - Client client = jerseyConfiguration.jerseyClient(); - String protocol = client.getSslContext().getProtocol(); - assertEquals("TLS", protocol); - } + @Test + public void testJerseyConfiguration() { + JerseyConfiguration jerseyConfiguration = new JerseyConfiguration(); + Client client = jerseyConfiguration.jerseyClient(); + String protocol = client.getSslContext().getProtocol(); + assertEquals("TLS", protocol); + } } diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/JsonReaderTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/JsonReaderTest.java index b827fbc..f4e26ac 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/JsonReaderTest.java +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/JsonReaderTest.java @@ -15,9 +15,11 @@ * limitations under the License. * ============LICENSE_END===================================================== */ -package org.onap.logging_analytics.pomba.pomba_aai_context_builder; + +package org.onap.pomba.contextbuilder.aai.test.datatype; import static org.junit.Assert.fail; + import org.junit.Test; import org.onap.pomba.contextbuilder.aai.exception.AuditException; import org.onap.pomba.contextbuilder.aai.reader.JsonReader; @@ -29,7 +31,7 @@ public class JsonReaderTest { JsonReader reader = new JsonReader(); try { reader.parse("{test:test}"); - } catch(AuditException e) { + } catch (AuditException e) { fail("This should not throw an exception."); } } @@ -40,7 +42,7 @@ public class JsonReaderTest { try { reader.parse("{test}"); fail("This should throw an exception."); - } catch(AuditException e) { + } catch (AuditException e) { //Just a test, no need to log the exception here. } } diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/L3networkInstanceTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/L3networkInstanceTest.java index d08d696..8432f87 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/L3networkInstanceTest.java +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/L3networkInstanceTest.java @@ -15,7 +15,8 @@ * limitations under the License. * ============LICENSE_END===================================================== */ -package org.onap.logging_analytics.pomba.pomba_aai_context_builder; + +package org.onap.pomba.contextbuilder.aai.test.datatype; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -24,16 +25,14 @@ import org.junit.Test; import org.onap.pomba.contextbuilder.aai.datatype.L3networkInstance; public class L3networkInstanceTest { - @Test - public void testL3networkInstanceEquals() { - L3networkInstance l3networkInstance1 = new L3networkInstance - ( "networkId1", "networkName1", "networkType1", - "networkRole1", "networkTechnology1", "resourceVersion1", - "modelInvariantId1", "modelVersionId1", "physicalNetworkName1", "true", - null); + @Test + public void testL3networkInstanceEquals() { + L3networkInstance l3networkInstance1 = new L3networkInstance("networkId1", "networkName1", "networkType1", + "networkRole1", "networkTechnology1", "resourceVersion1", "modelInvariantId1", "modelVersionId1", + "physicalNetworkName1", "true", null); - L3networkInstance l3networkInstance2 = new L3networkInstance (); - l3networkInstance2.setNetworkId("networkId1"); + L3networkInstance l3networkInstance2 = new L3networkInstance(); + l3networkInstance2.setNetworkId("networkId1"); l3networkInstance2.setNetworkName("networkName1"); l3networkInstance2.setNetworkType("networkType1"); l3networkInstance2.setNetworkRole("networkRole1"); @@ -48,7 +47,7 @@ public class L3networkInstanceTest { l3networkInstance1.toJson(); l3networkInstance1.toString(); assertEquals("physicalNetworkName1", l3networkInstance2.getPhysicalNetworkName()); - assertTrue(l3networkInstance1.equals(l3networkInstance1)); - assertTrue(l3networkInstance1.equals(l3networkInstance2)); - } + assertTrue(l3networkInstance1.equals(l3networkInstance1)); + assertTrue(l3networkInstance1.equals(l3networkInstance2)); + } } diff --git a/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/LInterfaceInstanceTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/LInterfaceInstanceTest.java new file mode 100644 index 0000000..5ec2420 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/LInterfaceInstanceTest.java @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * 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.pomba.contextbuilder.aai.test.datatype; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.LInterfaceInstance; + +public class LInterfaceInstanceTest { + @Test + public void testLInterfaceInstanceEquals() { + LInterfaceInstance lInterfaceInstance1 = new LInterfaceInstance("interfaceId1", "interfaceName1", + "interfaceRole1", "isPortMirrored1", "adminStatus1", "networkName1", "macAddr1", "inMaint1", null); + + LInterfaceInstance lInterfaceInstance2 = new LInterfaceInstance(); + lInterfaceInstance2.setInterfaceId("interfaceId1"); + lInterfaceInstance2.setInterfaceName("interfaceName1"); + lInterfaceInstance2.setInterfaceRole("interfaceRole1"); + lInterfaceInstance2.setIsPortMirrored("isPortMirrored1"); + lInterfaceInstance2.setAdminStatus("adminStatus1"); + lInterfaceInstance2.setNetworkName("networkName1"); + lInterfaceInstance2.setMacAddr("macAddr1"); + lInterfaceInstance2.setInMaint("inMaint1"); + + lInterfaceInstance1.toJson(); + lInterfaceInstance1.toString(); + assertEquals("interfaceName1", lInterfaceInstance2.getInterfaceName()); + assertTrue(lInterfaceInstance1.equals(lInterfaceInstance1)); + assertTrue(lInterfaceInstance1.equals(lInterfaceInstance2)); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/LogicalLinkInstanceTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/LogicalLinkInstanceTest.java new file mode 100644 index 0000000..9ee3c3e --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/LogicalLinkInstanceTest.java @@ -0,0 +1,57 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * 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.pomba.contextbuilder.aai.test.datatype; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.LogicalLinkInstance; + +public class LogicalLinkInstanceTest { + @Test + public void testLogicalLinkInstanceEquals() { + LogicalLinkInstance logicalLinkInstance1 = new LogicalLinkInstance("linkName1", "linkId1", + "modelVersionId1", "modelInvariantId1", "linkType1", "routingProtocol1", "speedValue1", "speedUnits1", + "provStatus1", "inMaint1", "linkRole1", "ipVersion1", "linkName21","circuitId1","purpose1"); + + LogicalLinkInstance logicalLinkInstance2 = new LogicalLinkInstance(); + logicalLinkInstance2.setLinkName("linkName1"); + logicalLinkInstance2.setLinkId("linkId1"); + logicalLinkInstance2.setModelVersionId("modelVersionId1"); + logicalLinkInstance2.setModelInvariantId("modelInvariantId1"); + logicalLinkInstance2.setLinkType("linkType1"); + logicalLinkInstance2.setRoutingProtocol("routingProtocol1"); + logicalLinkInstance2.setSpeedValue("speedValue1"); + logicalLinkInstance2.setSpeedUnits("speedUnits1"); + logicalLinkInstance2.setProvStatus("provStatus1"); + logicalLinkInstance2.setInMaint("inMaint1"); + logicalLinkInstance2.setLinkRole("linkRole1"); + logicalLinkInstance2.setIpVersion("ipVersion1"); + logicalLinkInstance2.setLinkName2("linkName21"); + logicalLinkInstance2.setCircuitId("circuitId1"); + logicalLinkInstance2.setPurpose("purpose1"); + + logicalLinkInstance1.toJson(); + logicalLinkInstance1.toString(); + assertEquals("linkName1", logicalLinkInstance2.getLinkName()); + assertTrue(logicalLinkInstance1.equals(logicalLinkInstance1)); + assertTrue(logicalLinkInstance1.equals(logicalLinkInstance2)); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/PInterfaceInstanceTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/PInterfaceInstanceTest.java new file mode 100644 index 0000000..60c0e92 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/PInterfaceInstanceTest.java @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * 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.pomba.contextbuilder.aai.test.datatype; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.LInterfaceInstanceList; +import org.onap.pomba.contextbuilder.aai.datatype.PInterfaceInstance; + +public class PInterfaceInstanceTest { + + @Test + public void testPInterfaceInstanceEquals() { + PInterfaceInstance pInterfaceInstance1 = new PInterfaceInstance("interfaceName1", "speedValue1", + "speedUnits1", "portDescription1", "equipmentIdentifier1", "interfaceRole1", "interfaceType1", + "provStatus1", "resourceVersion1", "inMaint1", "invStatus1" , new LInterfaceInstanceList(), null); + + PInterfaceInstance pInterfaceInstance2 = new PInterfaceInstance(); + pInterfaceInstance2.setInterfaceName("interfaceName1"); + pInterfaceInstance2.setSpeedValue("speedValue1"); + pInterfaceInstance2.setSpeedUnits("speedUnits1"); + pInterfaceInstance2.setPortDescription("portDescription1"); + pInterfaceInstance2.setEquipmentIdentifier("equipmentIdentifier1"); + pInterfaceInstance2.setInterfaceRole("interfaceRole1"); + pInterfaceInstance2.setInterfaceType("interfaceType1"); + pInterfaceInstance2.setProvStatus("provStatus1"); + pInterfaceInstance2.setResourceVersion("resourceVersion1"); + pInterfaceInstance2.setInMaint("inMaint1"); + pInterfaceInstance2.setInvStatus("invStatus1"); + + pInterfaceInstance1.toJson(); + pInterfaceInstance1.toString(); + assertEquals("interfaceName1", pInterfaceInstance2.getInterfaceName()); + assertTrue(pInterfaceInstance1.equals(pInterfaceInstance1)); + assertTrue(pInterfaceInstance1.equals(pInterfaceInstance2)); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/PnfInstanceTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/PnfInstanceTest.java new file mode 100644 index 0000000..a623912 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/PnfInstanceTest.java @@ -0,0 +1,58 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * 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.pomba.contextbuilder.aai.test.datatype; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.PnfInstance; + +public class PnfInstanceTest { + + @Test + public void testPnfInstanceEquals() { + PnfInstance pnfInstance1 = new PnfInstance("uuid1", "name1", "networkRole1", "name21", "name2Source1", + "equipmentType1", "equipmentVendor1", "equipmentModel1", "managementOptions1", "swVersion1", + "frameId1", "serialNumber1", "modelInvariantId1", "modelVersionId1", null); + + PnfInstance pnfInstance2 = new PnfInstance(); + pnfInstance2.setPnfId("uuid1"); + pnfInstance2.setPnfName("name1"); + pnfInstance2.setNfRole("networkRole1"); + pnfInstance2.setPnfName2("name21"); + pnfInstance2.setPnfName2Source("name2Source1"); + pnfInstance2.setEquipmentType("equipmentType1"); + pnfInstance2.setEquipmentVendor("equipmentVendor1"); + pnfInstance2.setEquipmentModel("equipmentModel1"); + pnfInstance2.setManagementOptions("managementOptions1"); + pnfInstance2.setSwVersion("swVersion1"); + pnfInstance2.setFrameId("frameId1"); + pnfInstance2.setSerialNumber("serialNumber1"); + pnfInstance2.setModelInvariantId("modelInvariantId1"); + pnfInstance2.setModelVersionId("modelVersionId1"); + pnfInstance2.setPInterfaceInstanceList(null); + + pnfInstance1.toJson(); + pnfInstance1.toString(); + assertEquals("name1", pnfInstance2.getPnfName()); + assertTrue(pnfInstance1.equals(pnfInstance1)); + assertTrue(pnfInstance1.equals(pnfInstance2)); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/PserverInstanceTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/PserverInstanceTest.java new file mode 100644 index 0000000..b20cfc2 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/PserverInstanceTest.java @@ -0,0 +1,58 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * 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.pomba.contextbuilder.aai.test.datatype; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.PserverInstance; + +public class PserverInstanceTest { + + @Test + public void testPserverInstanceEquals() { + PserverInstance pserverInstance1 = new PserverInstance("pserverId1", "hostname1", "pserverName2a", + "ptniiEquipName1", "equipType1", "equipVendor1", "equipModel1", "fqdn1", "internetTopology1", + "inMaint1", "resourceVersion1", "serialNumber1", + "purpose1",null); + + PserverInstance pserverInstance2 = new PserverInstance(); + pserverInstance2.setPserverId("pserverId1"); + pserverInstance2.setHostname("hostname1"); + pserverInstance2.setPserverName2("pserverName2a"); + pserverInstance2.setPtniiEquipName("ptniiEquipName1"); + pserverInstance2.setEquipType("equipType1"); + pserverInstance2.setEquipVendor("equipVendor1"); + pserverInstance2.setEquipModel("equipModel1"); + pserverInstance2.setFqdn("fqdn1"); + pserverInstance2.setInternetTopology("internetTopology1"); + pserverInstance2.setInMaint("inMaint1"); + pserverInstance2.setResourceVersion("resourceVersion1"); + pserverInstance2.setSerialNumber("serialNumber1"); + pserverInstance2.setPurpose("purpose1"); + pserverInstance2.setPInterfaceInstanceList(null); + + pserverInstance1.toJson(); + pserverInstance1.toString(); + assertEquals("hostname1", pserverInstance2.getHostname()); + assertTrue(pserverInstance1.equals(pserverInstance1)); + assertTrue(pserverInstance1.equals(pserverInstance2)); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/RelatedToPropertyTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/RelatedToPropertyTest.java new file mode 100644 index 0000000..e64a63a --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/RelatedToPropertyTest.java @@ -0,0 +1,56 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * 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.pomba.contextbuilder.aai.test.datatype; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.RelatedToProperty; + +public class RelatedToPropertyTest { + + @Test + public void testRelatedToPropertyWithParameters() { + RelatedToProperty relatedToProperty = new RelatedToProperty("propertyKey", "propertyValue"); + assertEquals("propertyKey", relatedToProperty.getPropertyKey()); + assertEquals("propertyValue", relatedToProperty.getPropertyValue()); + } + + @Test + public void testRelatedToProperty() { + RelatedToProperty relatedToProperty = new RelatedToProperty(); + relatedToProperty.setPropertyKey("propertyKey"); + relatedToProperty.setPropertyValue("propertyValue"); + assertEquals("propertyKey", relatedToProperty.getPropertyKey()); + assertEquals("propertyValue", relatedToProperty.getPropertyValue()); + String relatedToPropertyString = relatedToProperty.toString(); + assertTrue(relatedToPropertyString.contains("[propertyKey=propertyKey,propertyValue=propertyValue]")); + } + + @Test + public void testRelatedToPropertyIsEqual() { + RelatedToProperty relatedToProperty1 = new RelatedToProperty("propertyKey1", "propertyValue1"); + RelatedToProperty relatedToProperty2 = new RelatedToProperty("propertyKey2", "propertyValue2"); + RelatedToProperty relatedToProperty3 = new RelatedToProperty("propertyKey1", "propertyValue1"); + assertTrue(relatedToProperty1.equals(relatedToProperty1)); + assertTrue(!relatedToProperty1.equals(relatedToProperty2)); + assertTrue(relatedToProperty1.equals(relatedToProperty3)); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/RelationshipDatumTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/RelationshipDatumTest.java new file mode 100644 index 0000000..4fdf979 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/RelationshipDatumTest.java @@ -0,0 +1,60 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * 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.pomba.contextbuilder.aai.test.datatype; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.RelationshipDatum; + +public class RelationshipDatumTest { + @Test + public void testRelationshipDatum() { + RelationshipDatum relationshipDatum = new RelationshipDatum(); + + relationshipDatum.setRelationshipKey("relationshipKey"); + relationshipDatum.setRelationshipValue("relationshipValue"); + + assertEquals("relationshipKey", relationshipDatum.getRelationshipKey()); + assertEquals("relationshipValue", relationshipDatum.getRelationshipValue()); + } + + @Test + public void testRelationshipDatumWithParameters() { + RelationshipDatum relationshipDatum = new RelationshipDatum("relationshipKey", "relationshipValue"); + + assertEquals("relationshipKey", relationshipDatum.getRelationshipKey()); + assertEquals("relationshipValue", relationshipDatum.getRelationshipValue()); + String relationshipDatumString = relationshipDatum.toString(); + assertTrue(relationshipDatumString.contains("[relationshipKey=relationshipKey," + + "relationshipValue=relationshipValue]")); + } + + @Test + public void testRelationshipDatumEqual() { + RelationshipDatum relationshipDatum1 = new RelationshipDatum("relationshipKey1", "relationshipValue1"); + RelationshipDatum relationshipDatum2 = new RelationshipDatum("relationshipKey2", "relationshipValue2"); + RelationshipDatum relationshipDatum3 = new RelationshipDatum("relationshipKey1", "relationshipValue1"); + + assertTrue(relationshipDatum1.equals(relationshipDatum1)); + assertTrue(!relationshipDatum1.equals(relationshipDatum2)); + assertTrue(relationshipDatum1.equals(relationshipDatum3)); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/RelationshipListTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/RelationshipListTest.java new file mode 100644 index 0000000..59cc0c5 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/RelationshipListTest.java @@ -0,0 +1,101 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * 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.pomba.contextbuilder.aai.test.datatype; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.RelatedToProperty; +import org.onap.pomba.contextbuilder.aai.datatype.Relationship; +import org.onap.pomba.contextbuilder.aai.datatype.RelationshipDatum; +import org.onap.pomba.contextbuilder.aai.datatype.RelationshipList; + +public class RelationshipListTest { + @Test + public void testRelationshipList() { + RelationshipList relationshipList = new RelationshipList(); + Relationship relationship = new Relationship(); + List<Relationship> list = new ArrayList<Relationship>(); + list.add(relationship); + relationshipList.setRelationship(list); + + assertTrue(relationshipList.getRelationship().size() == 1); + + relationship.setRelatedLink("relatedLink"); + relationship.setRelatedTo("relatedTo"); + + RelatedToProperty relatedToProperty = new RelatedToProperty(); + List<RelatedToProperty> relatedToPropertyList = new ArrayList<RelatedToProperty>(); + relatedToPropertyList.add(relatedToProperty); + relationship.setRelatedToProperty(relatedToPropertyList); + list.add(relationship); + relationshipList.setRelationship(list); + + String relationshipListString = relationshipList.toString(); + assertTrue(relationshipListString.contains("[relationship=")); + + } + + @Test + public void testRelationshipListWithParameters() { + Relationship relationship = new Relationship("relatedTo", + "relatedLink", + new ArrayList<RelationshipDatum>(), + new ArrayList<RelatedToProperty>()); + List<Relationship> listOfRelationship = new ArrayList<Relationship>(); + listOfRelationship.add(relationship); + RelationshipList relationshipList = new RelationshipList(listOfRelationship); + + assertTrue(relationshipList.getRelationship().size() == 1); + } + + @Test + public void testRelationshipListEquals() { + + Relationship relationship1 = new Relationship("relatedTo1", + "relatedLink1", + new ArrayList<RelationshipDatum>(), + new ArrayList<RelatedToProperty>()); + List<Relationship> listOfRelationship = new ArrayList<Relationship>(); + listOfRelationship.add(relationship1); + RelationshipList relationshipList1 = new RelationshipList(listOfRelationship); + + Relationship relationship2 = new Relationship("relatedTo2", + "relatedLink2", + new ArrayList<RelationshipDatum>(), + new ArrayList<RelatedToProperty>()); + List<Relationship> listOfRelationship2 = new ArrayList<Relationship>(); + listOfRelationship.add(relationship2); + RelationshipList relationshipList2 = new RelationshipList(listOfRelationship2); + + Relationship relationship3 = new Relationship("relatedTo1", + "relatedLink1", + new ArrayList<RelationshipDatum>(), + new ArrayList<RelatedToProperty>()); + List<Relationship> listOfRelationship3 = new ArrayList<Relationship>(); + listOfRelationship.add(relationship3); + RelationshipList relationshipList3 = new RelationshipList(listOfRelationship3); + + assertTrue(relationshipList1.equals(relationshipList1)); + assertTrue(!relationshipList1.equals(relationshipList2)); + assertTrue(!relationshipList1.equals(relationshipList3)); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/RelationshipTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/RelationshipTest.java new file mode 100644 index 0000000..14195d9 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/RelationshipTest.java @@ -0,0 +1,89 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * 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.pomba.contextbuilder.aai.test.datatype; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.RelatedToProperty; +import org.onap.pomba.contextbuilder.aai.datatype.Relationship; +import org.onap.pomba.contextbuilder.aai.datatype.RelationshipDatum; + +public class RelationshipTest { + + @Test + public void testRelationshipWithParameters() { + List<RelationshipDatum> relationshipDatum = new ArrayList<RelationshipDatum>(); + List<RelatedToProperty> relatedToProperty = new ArrayList<RelatedToProperty>(); + Relationship relationship = new Relationship("relatedTo", "relatedLink", relationshipDatum, relatedToProperty); + + assertEquals("relatedTo", relationship.getRelatedTo()); + assertEquals("relatedLink", relationship.getRelatedLink()); + assertTrue(relationship.getRelationshipData().isEmpty()); + assertTrue(relationship.getRelatedToProperty().isEmpty()); + } + + @Test + public void testRelationship() { + Relationship relationship = new Relationship(); + List<RelationshipDatum> relationshipDatum = new ArrayList<RelationshipDatum>(); + List<RelatedToProperty> relatedToProperty = new ArrayList<RelatedToProperty>(); + + relationship.setRelatedLink("relatedLink"); + relationship.setRelatedTo("relatedTo"); + relationship.setRelatedToProperty(relatedToProperty); + relationship.setRelationshipData(relationshipDatum); + + assertEquals("relatedTo", relationship.getRelatedTo()); + assertEquals("relatedLink", relationship.getRelatedLink()); + assertTrue(relationship.getRelationshipData().isEmpty()); + assertTrue(relationship.getRelatedToProperty().isEmpty()); + + String relationshipString = relationship.toString(); + assertTrue(relationshipString.contains("[relatedTo=relatedTo," + + "relatedLink=relatedLink," + + "relationshipData=[]," + + "relatedToProperty=[]]")); + } + + @Test + public void testRelationshipEquals() { + List<RelationshipDatum> relationshipDatum = new ArrayList<RelationshipDatum>(); + List<RelatedToProperty> relatedToProperty = new ArrayList<RelatedToProperty>(); + Relationship relationship1 = new Relationship("relatedTo1", + "relatedLink1", + relationshipDatum, + relatedToProperty); + Relationship relationship2 = new Relationship("relatedTo2", + "relatedLink2", + relationshipDatum, + relatedToProperty); + Relationship relationship3 = new Relationship("relatedTo1", + "relatedLink1", + relationshipDatum, + relatedToProperty); + assertTrue(relationship1.equals(relationship1)); + assertTrue(!relationship1.equals(relationship2)); + assertTrue(relationship1.equals(relationship3)); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/ServiceInstanceTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/ServiceInstanceTest.java new file mode 100644 index 0000000..f852d76 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/ServiceInstanceTest.java @@ -0,0 +1,145 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * 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.pomba.contextbuilder.aai.test.datatype; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.RelatedToProperty; +import org.onap.pomba.contextbuilder.aai.datatype.Relationship; +import org.onap.pomba.contextbuilder.aai.datatype.RelationshipDatum; +import org.onap.pomba.contextbuilder.aai.datatype.RelationshipList; +import org.onap.pomba.contextbuilder.aai.datatype.ServiceInstance; + +public class ServiceInstanceTest { + @Test + public void testServiceInstance() { + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + serviceInstance.setServiceInstanceName("serviceInstanceName"); + serviceInstance.setServiceType("serviceType"); + serviceInstance.setServiceRole("serviceRole"); + serviceInstance.setEnvironmentContext("environmentContext"); + serviceInstance.setWorkloadContext("workloadContext"); + serviceInstance.setModelInvariantId("modelInvariantId"); + serviceInstance.setModelVersionId("modelVersionId"); + serviceInstance.setResourceVersion("resourceVersion"); + serviceInstance.setOrchestrationStatus("orchestrationStatus"); + RelationshipList relationshipList = new RelationshipList(); + List<Relationship> listOfRelationship = new ArrayList<Relationship>(); + Relationship relationship = new Relationship("relatedTo", + "relatedLink", + new ArrayList<RelationshipDatum>(), + new ArrayList<RelatedToProperty>()); + listOfRelationship.add(relationship); + relationshipList.setRelationship(listOfRelationship); + + serviceInstance.setRelationshipList(relationshipList); + + assertEquals("serviceInstanceId", serviceInstance.getServiceInstanceId()); + assertEquals("serviceInstanceName", serviceInstance.getServiceInstanceName()); + assertEquals("serviceType", serviceInstance.getServiceType()); + assertEquals("serviceRole", serviceInstance.getServiceRole()); + assertEquals("environmentContext", serviceInstance.getEnvironmentContext()); + assertEquals("workloadContext", serviceInstance.getWorkloadContext()); + assertEquals("modelInvariantId", serviceInstance.getModelInvariantId()); + assertEquals("modelVersionId", serviceInstance.getModelVersionId()); + assertEquals("resourceVersion", serviceInstance.getResourceVersion()); + assertEquals("orchestrationStatus", serviceInstance.getOrchestrationStatus()); + assertEquals("relatedTo", serviceInstance.getRelationshipList().getRelationship().get(0).getRelatedTo()); + } + + @Test + public void testServiceInstanceWithParameters() { + ServiceInstance serviceInstance = new ServiceInstance("serviceInstanceId", + "serviceInstanceName", + "serviceType", + "serviceRole", + "environmentContext", + "workloadContext", + "modelInvariantId", + "modelVersionId", + "resourceVersion", + "orchestrationStatus", + new RelationshipList()); + + assertEquals("serviceInstanceId", serviceInstance.getServiceInstanceId()); + assertEquals("serviceInstanceName", serviceInstance.getServiceInstanceName()); + assertEquals("serviceType", serviceInstance.getServiceType()); + assertEquals("serviceRole", serviceInstance.getServiceRole()); + assertEquals("environmentContext", serviceInstance.getEnvironmentContext()); + assertEquals("workloadContext", serviceInstance.getWorkloadContext()); + assertEquals("modelInvariantId", serviceInstance.getModelInvariantId()); + assertEquals("modelVersionId", serviceInstance.getModelVersionId()); + assertEquals("resourceVersion", serviceInstance.getResourceVersion()); + assertEquals("orchestrationStatus", serviceInstance.getOrchestrationStatus()); + + String serviceInstanceString = serviceInstance.toString(); + assertTrue(serviceInstanceString.contains("[serviceInstanceId=serviceInstanceId," + + "serviceInstanceName=serviceInstanceName,serviceType=serviceType," + + "serviceRole=serviceRole,environmentContext=environmentContext," + + "workloadContext=workloadContext,modelInvariantId=modelInvariantId," + + "modelVersionId=modelVersionId,resourceVersion=resourceVersion," + + "orchestrationStatus=orchestrationStatus,")); + } + + @Test + public void testServiceInstanceEquals() { + ServiceInstance serviceInstance1 = new ServiceInstance("serviceInstanceId1", + "serviceInstanceName1", + "serviceType1", + "serviceRole1", + "environmentContext1", + "workloadContext1", + "modelInvariantId1", + "modelVersionId1", + "resourceVersion1", + "orchestrationStatus1", + new RelationshipList()); + ServiceInstance serviceInstance2 = new ServiceInstance("serviceInstanceId2", + "serviceInstanceName2", + "serviceType2", + "serviceRole2", + "environmentContext2", + "workloadContext2", + "modelInvariantId2", + "modelVersionId2", + "resourceVersion2", + "orchestrationStatus2", + new RelationshipList()); + ServiceInstance serviceInstance3 = new ServiceInstance("serviceInstanceId1", + "serviceInstanceName1", + "serviceType1", + "serviceRole1", + "environmentContext1", + "workloadContext1", + "modelInvariantId1", + "modelVersionId1", + "resourceVersion1", + "orchestrationStatus1", + new RelationshipList()); + + assertTrue(serviceInstance1.equals(serviceInstance1)); + assertTrue(!serviceInstance1.equals(serviceInstance2)); + assertTrue(serviceInstance1.equals(serviceInstance3)); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/VfModuleTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/VfModuleTest.java new file mode 100644 index 0000000..3be2346 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/VfModuleTest.java @@ -0,0 +1,152 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * 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.pomba.contextbuilder.aai.test.datatype; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.L3networkInstance; +import org.onap.pomba.contextbuilder.aai.datatype.RelatedToProperty; +import org.onap.pomba.contextbuilder.aai.datatype.Relationship; +import org.onap.pomba.contextbuilder.aai.datatype.RelationshipDatum; +import org.onap.pomba.contextbuilder.aai.datatype.RelationshipList; +import org.onap.pomba.contextbuilder.aai.datatype.VfModule; + +public class VfModuleTest { + @Test + public void testVfModule() { + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setVfModuleName("vfModuleName"); + vfModule.setHeatStackId("heatStackId"); + vfModule.setOrchestrationStatus("orchestrationStatus"); + vfModule.setIsBaseVfModule(true); + vfModule.setResourceVersion("resourceVersion"); + vfModule.setModelInvariantId("modelInvariantId"); + vfModule.setModelVersionId("modelVersionId"); + vfModule.setModelCustomizationId("modelCustomizationId"); + vfModule.setModuleIndex(1); + + RelationshipList relationshipList = new RelationshipList(); + List<Relationship> listOfRelationship = new ArrayList<Relationship>(); + Relationship relationship = new Relationship("relatedTo", + "relatedLink", + new ArrayList<RelationshipDatum>(), + new ArrayList<RelatedToProperty>()); + listOfRelationship.add(relationship); + relationshipList.setRelationship(listOfRelationship); + + vfModule.setRelationshipList(relationshipList); + + assertEquals("vfModuleId", vfModule.getVfModuleId()); + assertEquals("vfModuleName", vfModule.getVfModuleName()); + assertEquals("heatStackId", vfModule.getHeatStackId()); + assertEquals("orchestrationStatus", vfModule.getOrchestrationStatus()); + assertTrue(vfModule.getIsBaseVfModule()); + assertEquals("resourceVersion", vfModule.getResourceVersion()); + assertEquals("modelInvariantId", vfModule.getModelInvariantId()); + assertEquals("modelVersionId", vfModule.getModelVersionId()); + assertEquals("modelCustomizationId", vfModule.getModelCustomizationId()); + assertEquals(new Integer(1), vfModule.getModuleIndex()); + assertEquals("relatedTo", vfModule.getRelationshipList().getRelationship().get(0).getRelatedTo()); + } + + @Test + public void testVfModuleWithParameters() { + VfModule vfModule = new VfModule("vfModuleId", + "vfModuleName", + "heatStackId", + "orchestrationStatus", + true, + "resourceVersion", + "modelInvariantId", + "modelVersionId", + "modelCustomizationId", + 1, + new RelationshipList() , + new ArrayList<L3networkInstance>()); + + assertEquals("vfModuleId", vfModule.getVfModuleId()); + assertEquals("vfModuleName", vfModule.getVfModuleName()); + assertEquals("heatStackId", vfModule.getHeatStackId()); + assertEquals("orchestrationStatus", vfModule.getOrchestrationStatus()); + assertTrue(vfModule.getIsBaseVfModule()); + assertEquals("resourceVersion", vfModule.getResourceVersion()); + assertEquals("modelInvariantId", vfModule.getModelInvariantId()); + assertEquals("modelVersionId", vfModule.getModelVersionId()); + assertEquals("modelCustomizationId", vfModule.getModelCustomizationId()); + assertEquals(new Integer(1), vfModule.getModuleIndex()); + + String vfModuleString = vfModule.toString(); + assertTrue(vfModuleString.contains("[vfModuleId=vfModuleId,vfModuleName=vfModuleName,heatStackId=heatStackId," + + "orchestrationStatus=orchestrationStatus,isBaseVfModule=true," + + "resourceVersion=resourceVersion,modelInvariantId=modelInvariantId," + + "modelVersionId=modelVersionId,modelCustomizationId=modelCustomizationId," + + "moduleIndex=1")); + + } + + @Test + public void testVfModuleEquals() { + VfModule vfModule1 = new VfModule("vfModuleId1", + "vfModuleName1", + "heatStackId1", + "orchestrationStatus1", + true, + "resourceVersion1", + "modelInvariantId1", + "modelVersionId1", + "modelCustomizationId1", + 1, + new RelationshipList() , + new ArrayList<L3networkInstance>()); + VfModule vfModule2 = new VfModule("vfModuleId2", + "vfModuleName2", + "heatStackId2", + "orchestrationStatus2", + true, + "resourceVersion2", + "modelInvariantId2", + "modelVersionId2", + "modelCustomizationId2", + 1, + new RelationshipList() , + new ArrayList<L3networkInstance>()); + VfModule vfModule3 = new VfModule("vfModuleId1", + "vfModuleName1", + "heatStackId1", + "orchestrationStatus1", + true, + "resourceVersion1", + "modelInvariantId1", + "modelVersionId1", + "modelCustomizationId1", + 1, + new RelationshipList() , + new ArrayList<L3networkInstance>()); + + assertTrue(vfModule1.equals(vfModule1)); + assertTrue(!vfModule1.equals(vfModule2)); + assertTrue(vfModule1.equals(vfModule3)); + } + +} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VfModulesTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/VfModulesTest.java index 3e1588c..0202359 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VfModulesTest.java +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/VfModulesTest.java @@ -15,7 +15,8 @@ * limitations under the License. * ============LICENSE_END===================================================== */ -package org.onap.logging_analytics.pomba.pomba_aai_context_builder; + +package org.onap.pomba.contextbuilder.aai.test.datatype; import static org.junit.Assert.assertTrue; @@ -26,31 +27,31 @@ import org.onap.pomba.contextbuilder.aai.datatype.VfModule; import org.onap.pomba.contextbuilder.aai.datatype.VfModules; public class VfModulesTest { - @Test - public void testVfModules() { - VfModules vfModules = new VfModules(); + @Test + public void testVfModules() { + VfModules vfModules = new VfModules(); - List<VfModule> vfModuleList = new ArrayList<VfModule>(); - vfModuleList.add(new VfModule()); - vfModules.setVfModule(vfModuleList); + List<VfModule> vfModuleList = new ArrayList<VfModule>(); + vfModuleList.add(new VfModule()); + vfModules.setVfModule(vfModuleList); - assertTrue(vfModules.getVfModule().get(0) instanceof VfModule); - } + assertTrue(vfModules.getVfModule().get(0) instanceof VfModule); + } - @Test - public void testVfModulesWithParameters() { - VfModules vfModules = new VfModules(new ArrayList<VfModule>()); + @Test + public void testVfModulesWithParameters() { + VfModules vfModules = new VfModules(new ArrayList<VfModule>()); - String vfModulesString = vfModules.toString(); - assertTrue(vfModulesString.contains("[vfModule=")); - } + String vfModulesString = vfModules.toString(); + assertTrue(vfModulesString.contains("[vfModule=")); + } - @Test - public void testVfModulesEquals() { - VfModules vfModules1 = new VfModules(new ArrayList<VfModule>()); - VfModules vfModules2 = new VfModules(new ArrayList<VfModule>()); + @Test + public void testVfModulesEquals() { + VfModules vfModules1 = new VfModules(new ArrayList<VfModule>()); + VfModules vfModules2 = new VfModules(new ArrayList<VfModule>()); - assertTrue(vfModules1.equals(vfModules1)); - assertTrue(vfModules1.equals(vfModules2)); - } + assertTrue(vfModules1.equals(vfModules1)); + assertTrue(vfModules1.equals(vfModules2)); + } } diff --git a/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/VnfInstanceTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/VnfInstanceTest.java new file mode 100644 index 0000000..7e022f5 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/VnfInstanceTest.java @@ -0,0 +1,259 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * 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.pomba.contextbuilder.aai.test.datatype; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.LInterfaceInstanceList; +import org.onap.pomba.contextbuilder.aai.datatype.RelationshipList; +import org.onap.pomba.contextbuilder.aai.datatype.VfModules; +import org.onap.pomba.contextbuilder.aai.datatype.VnfInstance; + +public class VnfInstanceTest { + @Test + public void testVnfInstance() { + VnfInstance vnfInstance = new VnfInstance(); + + vnfInstance.setServiceId("serviceId"); + vnfInstance.setModelCustomizationId("modelCustomizationId"); + vnfInstance.setVnfType("vnfType"); + vnfInstance.setIpv4Loopback0Address("ipv4Loopback0Address"); + vnfInstance.setNfFunction("nfFunction"); + vnfInstance.setModelInvariantId("modelInvariantId"); + vnfInstance.setResourceVersion("resourceVersion"); + vnfInstance.setVnfName2("vnfName2"); + vnfInstance.setRelationshipList(new RelationshipList()); + vnfInstance.setNmLanV6Address("nmLanV6Address"); + vnfInstance.setNfRole("nfRole"); + vnfInstance.setNfType("nfType"); + vnfInstance.setModelVersionId("modelVersionId"); + vnfInstance.setIpv4OamAddress("ipv4OamAddress"); + vnfInstance.setVnfName("vnfName"); + vnfInstance.setInMaintenance(true); + vnfInstance.setMsoCatalogKey("msoCatalogKey"); + vnfInstance.setProvisionStatus("provisionStatus"); + vnfInstance.setVfModules(new VfModules()); + vnfInstance.setEquipmentRole("equipmentRole"); + vnfInstance.setVnfId("vnfId"); + vnfInstance.setOrchestrationStatus("orchestrationStatus"); + vnfInstance.setNfNamingCode("nfNamingCode"); + vnfInstance.setHeatStackId("heatStackId"); + vnfInstance.setIsClosedLoopDisabled(true); + vnfInstance.setLicenseKey("licenseKey"); + vnfInstance.setManagementV6Address("managementV6Address"); + + assertEquals("serviceId", vnfInstance.getServiceId()); + assertEquals("modelCustomizationId", vnfInstance.getModelCustomizationId()); + assertEquals("vnfType", vnfInstance.getVnfType()); + assertEquals("ipv4Loopback0Address", vnfInstance.getIpv4Loopback0Address()); + assertEquals("nfFunction", vnfInstance.getNfFunction()); + assertEquals("modelInvariantId", vnfInstance.getModelInvariantId()); + assertEquals("resourceVersion", vnfInstance.getResourceVersion()); + assertEquals("vnfName2", vnfInstance.getVnfName2()); + assertTrue(vnfInstance.getRelationshipList() instanceof RelationshipList); + assertEquals("nmLanV6Address", vnfInstance.getNmLanV6Address()); + assertEquals("nfRole", vnfInstance.getNfRole()); + assertEquals("nfType", vnfInstance.getNfType()); + assertEquals("modelVersionId", vnfInstance.getModelVersionId()); + assertEquals("ipv4OamAddress", vnfInstance.getIpv4OamAddress()); + assertEquals("vnfName", vnfInstance.getVnfName()); + assertTrue(vnfInstance.getInMaintenance()); + assertEquals("msoCatalogKey", vnfInstance.getMsoCatalogKey()); + assertEquals("provisionStatus", vnfInstance.getProvisionStatus()); + assertTrue(vnfInstance.getVfModules() instanceof VfModules); + assertEquals("equipmentRole", vnfInstance.getEquipmentRole()); + assertEquals("vnfId", vnfInstance.getVnfId()); + assertEquals("orchestrationStatus", vnfInstance.getOrchestrationStatus()); + assertEquals("nfNamingCode", vnfInstance.getNfNamingCode()); + assertEquals("heatStackId", vnfInstance.getHeatStackId()); + assertTrue(vnfInstance.getIsClosedLoopDisabled()); + assertEquals("licenseKey", vnfInstance.getLicenseKey()); + assertEquals("managementV6Address", vnfInstance.getManagementV6Address()); + + } + + @Test + public void testVnfInstanceWithParameters() { + VnfInstance vnfInstance = new VnfInstance("vnfId", + "vnfName", + "vnfName2", + "vnfType", + "serviceId", + "provisionStatus", + "licenseKey", + "equipmentRole", + "orchestrationStatus", + "heatStackId", + "msoCatalogKey", + "ipv4OamAddress", + "ipv4Loopback0Address", + "nmLanV6Address", + "managementV6Address", + true, + true, + "resourceVersion", + "modelInvariantId", + "modelVersionId", + "modelCustomizationId", + "nfType", + "nfFunction", + "nfRole", + "nfNamingCode", + new RelationshipList(), + new VfModules(), + new LInterfaceInstanceList()); + + assertEquals("serviceId", vnfInstance.getServiceId()); + assertEquals("modelCustomizationId", vnfInstance.getModelCustomizationId()); + assertEquals("vnfType", vnfInstance.getVnfType()); + assertEquals("ipv4Loopback0Address", vnfInstance.getIpv4Loopback0Address()); + assertEquals("nfFunction", vnfInstance.getNfFunction()); + assertEquals("modelInvariantId", vnfInstance.getModelInvariantId()); + assertEquals("resourceVersion", vnfInstance.getResourceVersion()); + assertEquals("vnfName2", vnfInstance.getVnfName2()); + assertTrue(vnfInstance.getRelationshipList() instanceof RelationshipList); + assertEquals("nmLanV6Address", vnfInstance.getNmLanV6Address()); + assertEquals("nfRole", vnfInstance.getNfRole()); + assertEquals("nfType", vnfInstance.getNfType()); + assertEquals("modelVersionId", vnfInstance.getModelVersionId()); + assertEquals("ipv4OamAddress", vnfInstance.getIpv4OamAddress()); + assertEquals("vnfName", vnfInstance.getVnfName()); + assertTrue(vnfInstance.getInMaintenance()); + assertEquals("msoCatalogKey", vnfInstance.getMsoCatalogKey()); + assertEquals("provisionStatus", vnfInstance.getProvisionStatus()); + assertTrue(vnfInstance.getVfModules() instanceof VfModules); + assertEquals("equipmentRole", vnfInstance.getEquipmentRole()); + assertEquals("vnfId", vnfInstance.getVnfId()); + assertEquals("orchestrationStatus", vnfInstance.getOrchestrationStatus()); + assertEquals("nfNamingCode", vnfInstance.getNfNamingCode()); + assertEquals("heatStackId", vnfInstance.getHeatStackId()); + assertTrue(vnfInstance.getIsClosedLoopDisabled()); + assertEquals("licenseKey", vnfInstance.getLicenseKey()); + assertEquals("managementV6Address", vnfInstance.getManagementV6Address()); + + String vnfInstanceString = vnfInstance.toString(); + assertTrue(vnfInstanceString.contains("[vnfId=vnfId,vnfName=vnfName,vnfName2=vnfName2,vnfType=vnfType," + + "serviceId=serviceId,provisionStatus=provisionStatus," + + "licenseKey=licenseKey,equipmentRole=equipmentRole," + + "orchestrationStatus=orchestrationStatus,heatStackId=heatStackId," + + "msoCatalogKey=msoCatalogKey,ipv4OamAddress=ipv4OamAddress," + + "ipv4Loopback0Address=ipv4Loopback0Address," + + "nmLanV6Address=nmLanV6Address,managementV6Address=managementV6Address," + + "inMaintenance=true,isClosedLoopDisabled=true," + + "resourceVersion=resourceVersion,modelInvariantId=modelInvariantId," + + "modelVersionId=modelVersionId," + + "modelCustomizationId=modelCustomizationId,nfType=nfType," + + "nfFunction=nfFunction,nfRole=nfRole,nfNamingCode=nfNamingCode,")); + } + + @Test + public void testVnfInstanceEquals() { + VnfInstance vnfInstance1 = new VnfInstance("vnfId1", + "vnfName1", + "vnfName2-1", + "vnfType1", + "serviceId1", + "provisionStatus1", + "licenseKey1", + "equipmentRole1", + "orchestrationStatus1", + "heatStackId1", + "msoCatalogKey1", + "ipv4OamAddress1", + "ipv4Loopback0Address1", + "nmLanV6Address1", + "managementV6Address1", + true, + true, + "resourceVersion1", + "modelInvariantId1", + "modelVersionId1", + "modelCustomizationId1", + "nfType1", + "nfFunction1", + "nfRole1", + "nfNamingCode1", + new RelationshipList(), + new VfModules(), + new LInterfaceInstanceList()); + VnfInstance vnfInstance2 = new VnfInstance("vnfId2", + "vnfName2", + "vnfName2-2", + "vnfType2", + "serviceId2", + "provisionStatus2", + "licenseKey2", + "equipmentRole2", + "orchestrationStatus2", + "heatStackId2", + "msoCatalogKey2", + "ipv4OamAddress2", + "ipv4Loopback0Address2", + "nmLanV6Address2", + "managementV6Address2", + true, + true, + "resourceVersion2", + "modelInvariantId2", + "modelVersionId2", + "modelCustomizationId2", + "nfType2", + "nfFunction2", + "nfRole2", + "nfNamingCode2", + new RelationshipList(), + new VfModules(), + new LInterfaceInstanceList()); + VnfInstance vnfInstance3 = new VnfInstance("vnfId1", + "vnfName1", + "vnfName2-1", + "vnfType1", + "serviceId1", + "provisionStatus1", + "licenseKey1", + "equipmentRole1", + "orchestrationStatus1", + "heatStackId1", + "msoCatalogKey1", + "ipv4OamAddress1", + "ipv4Loopback0Address1", + "nmLanV6Address1", + "managementV6Address1", + true, + true, + "resourceVersion1", + "modelInvariantId1", + "modelVersionId1", + "modelCustomizationId1", + "nfType1", + "nfFunction1", + "nfRole1", + "nfNamingCode1", + new RelationshipList(), + new VfModules(), + new LInterfaceInstanceList()); + + assertTrue(vnfInstance1.equals(vnfInstance1)); + assertTrue(!vnfInstance1.equals(vnfInstance2)); + assertTrue(vnfInstance1.equals(vnfInstance3)); + + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/VnfcInstanceTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/VnfcInstanceTest.java new file mode 100644 index 0000000..d9f6509 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/VnfcInstanceTest.java @@ -0,0 +1,132 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * 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.pomba.contextbuilder.aai.test.datatype; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.RelationshipList; +import org.onap.pomba.contextbuilder.aai.datatype.VnfcInstance; + +public class VnfcInstanceTest { + @Test + public void testVnfcInstance() { + VnfcInstance vnfcInstance = new VnfcInstance(); + vnfcInstance.setVnfcName("vnfcName"); + vnfcInstance.setNfcNamingCode("nfcNamingCode"); + vnfcInstance.setNfcFunction("nfcFunction"); + vnfcInstance.setProvisionStatus("provisionStatus"); + vnfcInstance.setOrchestrationStatus("orchestrationStatus"); + vnfcInstance.setInMaintenance(true); + vnfcInstance.setIsClosedLoopDisabled(true); + vnfcInstance.setResourceVersion("resourceVersion"); + vnfcInstance.setModelInvariantId("modelInvariantId"); + vnfcInstance.setModelVersionId("modelVersionId"); + vnfcInstance.setRelationshipList(new RelationshipList()); + + assertEquals("vnfcName", vnfcInstance.getVnfcName()); + assertEquals("nfcNamingCode", vnfcInstance.getNfcNamingCode()); + assertEquals("nfcFunction", vnfcInstance.getNfcFunction()); + assertEquals("provisionStatus", vnfcInstance.getProvisionStatus()); + assertEquals("orchestrationStatus", vnfcInstance.getOrchestrationStatus()); + assertTrue(vnfcInstance.getInMaintenance()); + assertTrue(vnfcInstance.getIsClosedLoopDisabled()); + assertEquals("resourceVersion", vnfcInstance.getResourceVersion()); + assertEquals("modelInvariantId", vnfcInstance.getModelInvariantId()); + assertEquals("modelVersionId", vnfcInstance.getModelVersionId()); + assertTrue(vnfcInstance.getRelationshipList() instanceof RelationshipList); + + } + + @Test + public void testVnfcInstanceWithParameters() { + VnfcInstance vnfcInstance = new VnfcInstance("vnfcName", + "nfcNamingCode", + "nfcFunction", + "provisionStatus", + "orchestrationStatus", + true, + true, + "resourceVersion", + "modelInvariantId", + "modelVersionId", + new RelationshipList()); + + assertEquals("vnfcName", vnfcInstance.getVnfcName()); + assertEquals("nfcNamingCode", vnfcInstance.getNfcNamingCode()); + assertEquals("nfcFunction", vnfcInstance.getNfcFunction()); + assertEquals("provisionStatus", vnfcInstance.getProvisionStatus()); + assertEquals("orchestrationStatus", vnfcInstance.getOrchestrationStatus()); + assertTrue(vnfcInstance.getInMaintenance()); + assertTrue(vnfcInstance.getIsClosedLoopDisabled()); + assertEquals("resourceVersion", vnfcInstance.getResourceVersion()); + assertEquals("modelInvariantId", vnfcInstance.getModelInvariantId()); + assertEquals("modelVersionId", vnfcInstance.getModelVersionId()); + assertTrue(vnfcInstance.getRelationshipList() instanceof RelationshipList); + + String vnfcInstanceString = vnfcInstance.toString(); + assertTrue(vnfcInstanceString.contains("[vnfcName=vnfcName,nfcNamingCode=nfcNamingCode," + + "nfcFunction=nfcFunction,provisionStatus=provisionStatus," + + "orchestration_status=orchestrationStatus,inMaintenance=true," + + "isClosedLoopDisabled=true,resourceVersion=resourceVersion," + + "modelInvariantId=modelInvariantId,modelVersionId=modelVersionId,")); + } + + @Test + public void testVnfcInstanceEquals() { + VnfcInstance vnfcInstance1 = new VnfcInstance("vnfcName1", + "nfcNamingCode1", + "nfcFunction1", + "provisionStatus1", + "orchestrationStatus1", + true, + true, + "resourceVersion1", + "modelInvariantId1", + "modelVersionId1", + new RelationshipList()); + VnfcInstance vnfcInstance2 = new VnfcInstance("vnfcName2", + "nfcNamingCode2", + "nfcFunction2", + "provisionStatus2", + "orchestrationStatus2", + true, + true, + "resourceVersion2", + "modelInvariantId2", + "modelVersionId2", + new RelationshipList()); + VnfcInstance vnfcInstance3 = new VnfcInstance("vnfcName1", + "nfcNamingCode1", + "nfcFunction1", + "provisionStatus1", + "orchestrationStatus1", + true, + true, + "resourceVersion1", + "modelInvariantId1", + "modelVersionId1", + new RelationshipList()); + + assertTrue(vnfcInstance1.equals(vnfcInstance1)); + assertTrue(!vnfcInstance1.equals(vnfcInstance2)); + assertTrue(vnfcInstance1.equals(vnfcInstance3)); + } +} diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VserverTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/VserverTest.java index 509db34..34c81bd 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VserverTest.java +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/VserverTest.java @@ -15,18 +15,20 @@ * limitations under the License. * ============LICENSE_END===================================================== */ -package org.onap.logging_analytics.pomba.pomba_aai_context_builder; + +package org.onap.pomba.contextbuilder.aai.test.datatype; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.List; import org.junit.Test; +import org.onap.pomba.contextbuilder.aai.datatype.LInterfaceInstanceList; import org.onap.pomba.contextbuilder.aai.datatype.Relationship; import org.onap.pomba.contextbuilder.aai.datatype.RelationshipList; import org.onap.pomba.contextbuilder.aai.datatype.Vserver; -import org.onap.pomba.contextbuilder.aai.datatype.LInterfaceInstanceList; public class VserverTest { @@ -58,12 +60,23 @@ public class VserverTest { assertEquals("resourceVersion", aVServer.getResourceVersion()); String vserverToString = aVServer.toString(); - assertTrue(vserverToString.contains("[vserverId=vserverId,vserverName=vserverName,vserverName2=vserverName2,provStatus=provStatus,vserverSelflink=vserverSelflink,inMaint=true,isClosedLoopDisabled=true,resourceVersion=resourceVersion")); + assertTrue(vserverToString.contains("[vserverId=vserverId,vserverName=vserverName,vserverName2=vserverName2" + + ",provStatus=provStatus,vserverSelflink=vserverSelflink,inMaint=true," + + "isClosedLoopDisabled=true,resourceVersion=resourceVersion")); } @Test public void testVserverWithParameters() { - Vserver aVServer = new Vserver("vserverId", "vserverName", "vserverName2", "provStatus", "vserverSelflink", true, true, "resourceVersion", new RelationshipList(), new LInterfaceInstanceList()); + Vserver aVServer = new Vserver("vserverId", + "vserverName", + "vserverName2", + "provStatus", + "vserverSelflink", + true, + true, + "resourceVersion", + new RelationshipList(), + new LInterfaceInstanceList()); assertEquals("vserverId", aVServer.getVserverId()); assertEquals("vserverName", aVServer.getVserverName()); @@ -77,9 +90,36 @@ public class VserverTest { @Test public void testVserverEquals() { - Vserver aVServer1 = new Vserver("vserverId1", "vserverName1", "vserverName2", "provStatus1", "vserverSelflink1", true, true, "resourceVersion1", new RelationshipList(), new LInterfaceInstanceList()); - Vserver aVServer2 = new Vserver("vserverId2", "vserverName2", "vserverName2", "provStatus2", "vserverSelflink2", false, false, "resourceVersion2", new RelationshipList(), new LInterfaceInstanceList()); - Vserver aVServer3 = new Vserver("vserverId1", "vserverName1", "vserverName2", "provStatus1", "vserverSelflink1", true, true, "resourceVersion1", new RelationshipList(), new LInterfaceInstanceList()); + Vserver aVServer1 = new Vserver("vserverId1", + "vserverName1", + "vserverName2", + "provStatus1", + "vserverSelflink1", + true, + true, + "resourceVersion1", + new RelationshipList(), + new LInterfaceInstanceList()); + Vserver aVServer2 = new Vserver("vserverId2", + "vserverName2", + "vserverName2", + "provStatus2", + "vserverSelflink2", + false, + false, + "resourceVersion2", + new RelationshipList(), + new LInterfaceInstanceList()); + Vserver aVServer3 = new Vserver("vserverId1", + "vserverName1", + "vserverName2", + "provStatus1", + "vserverSelflink1", + true, + true, + "resourceVersion1", + new RelationshipList(), + new LInterfaceInstanceList()); assertTrue(aVServer1.equals(aVServer1)); assertFalse(aVServer1.equals(aVServer2)); diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/WebConfigurationTest.java b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/WebConfigurationTest.java index a07524d..65c0ede 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/WebConfigurationTest.java +++ b/src/test/java/org/onap/pomba/contextbuilder/aai/test/datatype/WebConfigurationTest.java @@ -15,7 +15,8 @@ * limitations under the License. * ============LICENSE_END===================================================== */ -package org.onap.logging_analytics.pomba.pomba_aai_context_builder; + +package org.onap.pomba.contextbuilder.aai.test.datatype; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; @@ -26,13 +27,13 @@ import org.springframework.web.servlet.config.annotation.ViewResolverRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; public class WebConfigurationTest { - @Test - public void runTest() { - WebConfiguration webConfiguration = new WebConfiguration(); - WebMvcConfigurerAdapter webMvConfigurationAdapter = webConfiguration.forwardToIndex(); - ViewResolverRegistry registry = mock(ViewResolverRegistry.class); - webMvConfigurationAdapter.configureViewResolvers(registry); - assertEquals(false, registry.hasRegistrations()); - } + @Test + public void runTest() { + WebConfiguration webConfiguration = new WebConfiguration(); + WebMvcConfigurerAdapter webMvConfigurationAdapter = webConfiguration.forwardToIndex(); + ViewResolverRegistry registry = mock(ViewResolverRegistry.class); + webMvConfigurationAdapter.configureViewResolvers(registry); + assertEquals(false, registry.hasRegistrations()); + } } |