From f6a725a0b5b6864c09443e7f328927772a78ea05 Mon Sep 17 00:00:00 2001 From: "Tait,Trevor(rt0435)" Date: Fri, 26 Oct 2018 13:27:54 -0400 Subject: SDNC context builder API Mapping Configuration Issue-ID: LOG-421 Add code to use the VNF-API on SDNC where required. This involves using the api-mapping logic to select the VNF-API over the GNERIC-RESOURCES-API as well as adding the code to extract the information required by the VNF-API from AAI and adding the code to parse the VNF-API resonse into ModelContext. Change-Id: I4447a14d7fa39b2c5d9b655c2b20e651e56d3d77 Signed-off-by: Tait,Trevor(rt0435) --- .../sdnc/test/AudutExceptionTest.java | 47 ++++ .../sdnc/test/AvailabilityZoneTest.java | 50 ++++ .../contextbuilder/sdnc/test/NetworkIpTest.java | 50 ++++ .../contextbuilder/sdnc/test/NetworkIpV6Test.java | 50 ++++ .../contextbuilder/sdnc/test/OperStatusTest.java | 57 +++++ .../sdnc/test/RelatedToPropertyTest.java | 57 +++++ .../sdnc/test/RelationshipDatumTest.java | 60 +++++ .../sdnc/test/RelationshipListTest.java | 102 +++++++++ .../contextbuilder/sdnc/test/RelationshipTest.java | 88 +++++++ .../sdnc/test/RequestInformationTest.java | 57 +++++ .../sdnc/test/SdncRequestHeaderTest.java | 61 +++++ .../contextbuilder/sdnc/test/ServiceDataTest.java | 86 +++++++ .../sdnc/test/ServiceEntityTest.java | 44 ++++ .../sdnc/test/ServiceInformationTest.java | 67 ++++++ .../sdnc/test/ServiceInstanceTest.java | 148 ++++++++++++ .../sdnc/test/ServiceStatusTest.java | 83 +++++++ .../contextbuilder/sdnc/test/VfModuleTest.java | 149 ++++++++++++ .../contextbuilder/sdnc/test/VfModulesTest.java | 58 +++++ .../pomba/contextbuilder/sdnc/test/VmNameTest.java | 50 ++++ .../contextbuilder/sdnc/test/VmNetworkTest.java | 81 +++++++ .../sdnc/test/VnfAssignmentsTest.java | 66 ++++++ .../contextbuilder/sdnc/test/VnfInstanceTest.java | 253 +++++++++++++++++++++ .../contextbuilder/sdnc/test/VnfListTest.java | 52 +++++ .../contextbuilder/sdnc/test/VnfNetworkTest.java | 72 ++++++ .../contextbuilder/sdnc/test/VnfParameterTest.java | 54 +++++ .../sdnc/test/VnfRequestInformationTest.java | 93 ++++++++ .../pomba/contextbuilder/sdnc/test/VnfTest.java | 56 +++++ .../sdnc/test/VnfTopologyIdentifierTest.java | 72 ++++++ .../sdnc/test/VnfTopologyInformationTest.java | 62 +++++ .../pomba/contextbuilder/sdnc/test/VnfVmTest.java | 59 +++++ .../unittest/service/SdncContextBuilderTest.java | 209 ++++++++++------- 31 files changed, 2413 insertions(+), 80 deletions(-) create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/AudutExceptionTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/AvailabilityZoneTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/NetworkIpTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/NetworkIpV6Test.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/OperStatusTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelatedToPropertyTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelationshipDatumTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelationshipListTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelationshipTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RequestInformationTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/SdncRequestHeaderTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceDataTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceEntityTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceInformationTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceInstanceTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceStatusTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VfModuleTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VfModulesTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VmNameTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VmNetworkTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfAssignmentsTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfInstanceTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfListTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfNetworkTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfParameterTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfRequestInformationTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfTopologyIdentifierTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfTopologyInformationTest.java create mode 100644 src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfVmTest.java (limited to 'src/test/java/org') diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/AudutExceptionTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/AudutExceptionTest.java new file mode 100644 index 0000000..b9c9db4 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/AudutExceptionTest.java @@ -0,0 +1,47 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertTrue; + +import javax.ws.rs.core.Response.Status; +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.exception.AuditError; +import org.onap.pomba.contextbuilder.sdnc.exception.AuditException; + +public class AudutExceptionTest { + @Test + public void testAudutException() { + AuditException auditException1 = new AuditException(AuditError.JSON_PARSE_ERROR); + assertTrue(auditException1.getMessage().equals(AuditError.JSON_PARSE_ERROR)); + + AuditException auditException2 = new AuditException(AuditError.INTERNAL_SERVER_ERROR, + Status.INTERNAL_SERVER_ERROR); + assertTrue(auditException2.getMessage().equals(AuditError.INTERNAL_SERVER_ERROR)); + assertTrue(auditException2.getHttpStatus().equals(Status.INTERNAL_SERVER_ERROR)); + + Exception ex = new Exception(AuditError.JSON_EMPTY_RESPONSE); + AuditException auditException3 = new AuditException(AuditError.JSON_EMPTY_RESPONSE, ex); + assertTrue(auditException3.getMessage().equals(AuditError.JSON_EMPTY_RESPONSE)); + assertTrue(auditException3.getCause().getMessage().equals(AuditError.JSON_EMPTY_RESPONSE)); + + + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/AvailabilityZoneTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/AvailabilityZoneTest.java new file mode 100644 index 0000000..b826946 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/AvailabilityZoneTest.java @@ -0,0 +1,50 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.AvailabilityZone; + +public class AvailabilityZoneTest { + @Test + public void testAvailabilityZoneWithParameters() { + AvailabilityZone availabilityZone = new AvailabilityZone("availabilityZone"); + assertEquals("availabilityZone", availabilityZone.getAvailabilityZone()); + } + + @Test + public void testAvailabilityZone() { + AvailabilityZone availabilityZone = new AvailabilityZone(); + availabilityZone.setAvailabilityZone("availabilityZone"); + assertEquals("availabilityZone", availabilityZone.getAvailabilityZone()); + String availabilityZoneString = availabilityZone.toString(); + assertTrue(availabilityZoneString.contains("[availabilityZone=availabilityZone]")); + } + + @Test + public void testAvailabilityZoneIsEqual() { + AvailabilityZone availabilityZone1 = new AvailabilityZone("availabilityZone1"); + assertTrue(availabilityZone1.equals(availabilityZone1)); + assertTrue(availabilityZone1.hashCode() == -383357559); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/NetworkIpTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/NetworkIpTest.java new file mode 100644 index 0000000..13ba678 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/NetworkIpTest.java @@ -0,0 +1,50 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.NetworkIp; + +public class NetworkIpTest { + @Test + public void testNetworkIpWithParameters() { + NetworkIp networkIp = new NetworkIp("networkIp"); + assertEquals("networkIp", networkIp.getIpAddress()); + } + + @Test + public void testNetworkIp() { + NetworkIp networkIp = new NetworkIp(); + networkIp.setIpAddress("networkIp"); + assertEquals("networkIp", networkIp.getIpAddress()); + String networkIpString = networkIp.toString(); + assertTrue(networkIpString.contains("[ipAddress=networkIp]")); + } + + @Test + public void testNetworkIpIsEqual() { + NetworkIp networkIp1 = new NetworkIp("networkIp1"); + assertTrue(networkIp1.equals(networkIp1)); + assertTrue(networkIp1.hashCode() == -478253317); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/NetworkIpV6Test.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/NetworkIpV6Test.java new file mode 100644 index 0000000..68e1e48 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/NetworkIpV6Test.java @@ -0,0 +1,50 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.NetworkIpV6; + +public class NetworkIpV6Test { + @Test + public void testNetworkIpV6WithParameters() { + NetworkIpV6 networkIpV6 = new NetworkIpV6("networkIpV6"); + assertEquals("networkIpV6", networkIpV6.getIpAddressIpV6()); + } + + @Test + public void testNetworkIpV6() { + NetworkIpV6 networkIpV6 = new NetworkIpV6(); + networkIpV6.setIpAddressIpV6("networkIpV6"); + assertEquals("networkIpV6", networkIpV6.getIpAddressIpV6()); + String networkIpV6String = networkIpV6.toString(); + assertTrue(networkIpV6String.contains("[ipAddressIpV6=networkIpV6]")); + } + + @Test + public void testNetworkIpV6IsEqual() { + NetworkIpV6 networkIpV61 = new NetworkIpV6("networkIpV61"); + assertTrue(networkIpV61.equals(networkIpV61)); + assertTrue(networkIpV61.hashCode() == -39929445); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/OperStatusTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/OperStatusTest.java new file mode 100644 index 0000000..5c9dc4b --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/OperStatusTest.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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.OperStatus; + +public class OperStatusTest { + @Test + public void testOperStatusWithParameters() { + OperStatus operStatus = new OperStatus("lastAction", "orderStatus", "lastOrderStatus"); + assertEquals("lastAction", operStatus.getLastAction()); + assertEquals("orderStatus", operStatus.getOrderStatus()); + assertEquals("lastOrderStatus", operStatus.getLastOrderStatus()); + } + + @Test + public void testOperStatus() { + OperStatus operStatus = new OperStatus(); + operStatus.setLastAction("lastAction"); + operStatus.setOrderStatus("orderStatus"); + operStatus.setLastOrderStatus("lastOrderStatus"); + assertEquals("lastAction", operStatus.getLastAction()); + assertEquals("orderStatus", operStatus.getOrderStatus()); + assertEquals("lastOrderStatus", operStatus.getLastOrderStatus()); + String operStatusString = operStatus.toString(); + assertTrue(operStatusString + .contains("[lastAction=lastAction,orderStatus=orderStatus,lastOrderStatus=lastOrderStatus]")); + } + + @Test + public void testOperStatusIsEqual() { + OperStatus operStatus1 = new OperStatus("lastAction1", "orderStatus1", "lastOrderStatus1"); + assertTrue(operStatus1.equals(operStatus1)); + assertTrue(operStatus1.hashCode() == 1846706130); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelatedToPropertyTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelatedToPropertyTest.java new file mode 100644 index 0000000..c60d89c --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelatedToPropertyTest.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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.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)); + assertTrue(relatedToProperty1.hashCode() == 551990433); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelationshipDatumTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelationshipDatumTest.java new file mode 100644 index 0000000..8581f0b --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.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)); + assertTrue(relationshipDatum1.hashCode() == 1756006411); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelationshipListTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelationshipListTest.java new file mode 100644 index 0000000..5656932 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelationshipListTest.java @@ -0,0 +1,102 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.RelatedToProperty; +import org.onap.pomba.contextbuilder.sdnc.model.Relationship; +import org.onap.pomba.contextbuilder.sdnc.model.RelationshipDatum; +import org.onap.pomba.contextbuilder.sdnc.model.RelationshipList; + +public class RelationshipListTest { + @Test + public void testRelationshipList() { + RelationshipList relationshipList = new RelationshipList(); + Relationship relationship = new Relationship(); + List list = new ArrayList(); + list.add(relationship); + relationshipList.setRelationship(list); + + assertTrue(relationshipList.getRelationship().size() == 1); + + relationship.setRelatedLink("relatedLink"); + relationship.setRelatedTo("relatedTo"); + + RelatedToProperty relatedToProperty = new RelatedToProperty(); + List relatedToPropertyList = new ArrayList(); + 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(), + new ArrayList()); + List listOfRelationship = new ArrayList(); + 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(), + new ArrayList()); + List listOfRelationship = new ArrayList(); + listOfRelationship.add(relationship1); + RelationshipList relationshipList1 = new RelationshipList(listOfRelationship); + + Relationship relationship2 = new Relationship("relatedTo2", + "relatedLink2", + new ArrayList(), + new ArrayList()); + List listOfRelationship2 = new ArrayList(); + listOfRelationship.add(relationship2); + RelationshipList relationshipList2 = new RelationshipList(listOfRelationship2); + + Relationship relationship3 = new Relationship("relatedTo1", + "relatedLink1", + new ArrayList(), + new ArrayList()); + List listOfRelationship3 = new ArrayList(); + listOfRelationship.add(relationship3); + RelationshipList relationshipList3 = new RelationshipList(listOfRelationship3); + + assertTrue(relationshipList1.equals(relationshipList1)); + assertTrue(!relationshipList1.equals(relationshipList2)); + assertTrue(!relationshipList1.equals(relationshipList3)); + assertTrue(relationshipList1.hashCode() == 489848468); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelationshipTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelationshipTest.java new file mode 100644 index 0000000..8535575 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RelationshipTest.java @@ -0,0 +1,88 @@ +/* + * ============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.sdnc.test; + +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.sdnc.model.RelatedToProperty; +import org.onap.pomba.contextbuilder.sdnc.model.Relationship; +import org.onap.pomba.contextbuilder.sdnc.model.RelationshipDatum; + +public class RelationshipTest { + + @Test + public void testRelationshipWithParameters() { + List relationshipDatum = new ArrayList(); + List relatedToProperty = new ArrayList(); + 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 = new ArrayList(); + List relatedToProperty = new ArrayList(); + + 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 = new ArrayList(); + List relatedToProperty = new ArrayList(); + 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)); + assertTrue(relationship1.hashCode() == 1959828762); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RequestInformationTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RequestInformationTest.java new file mode 100644 index 0000000..5208ce1 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/RequestInformationTest.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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.RequestInformation; + +public class RequestInformationTest { + @Test + public void testRequestInformationWithParameters() { + RequestInformation requestInformation = new RequestInformation("requestId", "source", "requestAction"); + assertEquals("requestId", requestInformation.getRequestId()); + assertEquals("source", requestInformation.getSource()); + assertEquals("requestAction", requestInformation.getRequestAction()); + } + + @Test + public void testRequestInformation() { + RequestInformation requestInformation = new RequestInformation(); + requestInformation.setRequestId("requestId"); + requestInformation.setSource("source"); + requestInformation.setRequestAction("requestAction"); + assertEquals("requestId", requestInformation.getRequestId()); + assertEquals("source", requestInformation.getSource()); + assertEquals("requestAction", requestInformation.getRequestAction()); + String requestInformationString = requestInformation.toString(); + assertTrue(requestInformationString + .contains("[requestId=requestId,source=source,requestAction=requestAction]")); + } + + @Test + public void testRequestInformationIsEqual() { + RequestInformation requestInformation1 = new RequestInformation("requestId1", "source1", "requestAction1"); + assertTrue(requestInformation1.equals(requestInformation1)); + assertTrue(requestInformation1.hashCode() == 636999996); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/SdncRequestHeaderTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/SdncRequestHeaderTest.java new file mode 100644 index 0000000..1fc18a7 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/SdncRequestHeaderTest.java @@ -0,0 +1,61 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.SdncRequestHeader; + +public class SdncRequestHeaderTest { + @Test + public void testSdncRequestHeaderWithParameters() { + SdncRequestHeader sdncRequestHeader = new SdncRequestHeader("svcNotificationUrl", + "svcRequestId", + "svcAction"); + assertEquals("svcNotificationUrl", sdncRequestHeader.getSvcNotificationUrl()); + assertEquals("svcRequestId", sdncRequestHeader.getSvcRequestId()); + assertEquals("svcAction", sdncRequestHeader.getSvcAction()); + } + + @Test + public void testSdncRequestHeader() { + SdncRequestHeader sdncRequestHeader = new SdncRequestHeader(); + sdncRequestHeader.setSvcNotificationUrl("svcNotificationUrl"); + sdncRequestHeader.setSvcRequestId("svcRequestId"); + sdncRequestHeader.setSvcAction("svcAction"); + assertEquals("svcNotificationUrl", sdncRequestHeader.getSvcNotificationUrl()); + assertEquals("svcRequestId", sdncRequestHeader.getSvcRequestId()); + assertEquals("svcAction", sdncRequestHeader.getSvcAction()); + String sdncRequestHeaderString = sdncRequestHeader.toString(); + assertTrue(sdncRequestHeaderString + .contains("[svcNotificationUrl=svcNotificationUrl,svcRequestId=svcRequestId,svcAction=svcAction]")); + } + + @Test + public void testSdncRequestHeaderIsEqual() { + SdncRequestHeader sdncRequestHeader1 = new SdncRequestHeader("svcNotificationUrl1", + "svcRequestId1", + "svcAction1"); + assertTrue(sdncRequestHeader1.equals(sdncRequestHeader1)); + assertTrue(sdncRequestHeader1.hashCode() == 749721816); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceDataTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceDataTest.java new file mode 100644 index 0000000..12f2af3 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceDataTest.java @@ -0,0 +1,86 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.OperStatus; +import org.onap.pomba.contextbuilder.sdnc.model.RequestInformation; +import org.onap.pomba.contextbuilder.sdnc.model.SdncRequestHeader; +import org.onap.pomba.contextbuilder.sdnc.model.ServiceData; +import org.onap.pomba.contextbuilder.sdnc.model.ServiceInformation; +import org.onap.pomba.contextbuilder.sdnc.model.VnfRequestInformation; +import org.onap.pomba.contextbuilder.sdnc.model.VnfTopologyInformation; + +public class ServiceDataTest { + @Test + public void testServiceDataWithParameters() { + ServiceData serviceData = new ServiceData(new RequestInformation(), + new ServiceInformation(), + "vnfId", + new SdncRequestHeader(), + new VnfRequestInformation(), + new OperStatus(), + new VnfTopologyInformation()); + assertEquals(new RequestInformation(), serviceData.getRequestInformation()); + assertEquals(new ServiceInformation(), serviceData.getServiceInformation()); + assertEquals("vnfId", serviceData.getVnfId()); + assertEquals(new SdncRequestHeader(), serviceData.getSdncRequestHeader()); + assertEquals(new VnfRequestInformation(), serviceData.getVnfRequestInformation()); + assertEquals(new OperStatus(), serviceData.getOperStatus()); + assertEquals(new VnfTopologyInformation(), serviceData.getVnfTopologyInformation()); + } + + @Test + public void testServiceData() { + ServiceData serviceData = new ServiceData(); + serviceData.setRequestInformation(new RequestInformation()); + serviceData.setServiceInformation(new ServiceInformation()); + serviceData.setVnfId("vnfId"); + serviceData.setSdncRequestHeader(new SdncRequestHeader()); + serviceData.setVnfRequestInformation(new VnfRequestInformation()); + serviceData.setOperStatus(new OperStatus()); + serviceData.setVnfTopologyInformation(new VnfTopologyInformation()); + assertEquals(new RequestInformation(), serviceData.getRequestInformation()); + assertEquals(new ServiceInformation(), serviceData.getServiceInformation()); + assertEquals("vnfId", serviceData.getVnfId()); + assertEquals(new SdncRequestHeader(), serviceData.getSdncRequestHeader()); + assertEquals(new VnfRequestInformation(), serviceData.getVnfRequestInformation()); + assertEquals(new OperStatus(), serviceData.getOperStatus()); + assertEquals(new VnfTopologyInformation(), serviceData.getVnfTopologyInformation()); + String serviceDataString = serviceData.toString(); + assertTrue(serviceDataString.contains("vnfId=vnfId")); + } + + @Test + public void testServiceDataIsEqual() { + ServiceData serviceData1 = new ServiceData(new RequestInformation(), + new ServiceInformation(), + "vnfId1", + new SdncRequestHeader(), + new VnfRequestInformation(), + new OperStatus(), + new VnfTopologyInformation()); + assertTrue(serviceData1.equals(serviceData1)); + assertTrue(serviceData1.hashCode() == -140583576); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceEntityTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceEntityTest.java new file mode 100644 index 0000000..510fcb8 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceEntityTest.java @@ -0,0 +1,44 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.ServiceEntity; + +public class ServiceEntityTest { + + @Test + public void testGenericResponse() { + ServiceEntity serviceEntity = new ServiceEntity(); + + serviceEntity.setApiName("VNF-API"); + serviceEntity.setCustomerName("customer"); + serviceEntity.setCustomerType("customerType"); + serviceEntity.setServiceInstanceId("serviceInstanceId"); + serviceEntity.setServiceType("vFW"); + + assertEquals("VNF-API", serviceEntity.getApiName()); + assertEquals("customer", serviceEntity.getCustomerName()); + assertEquals("customerType", serviceEntity.getCustomerType()); + assertEquals("serviceInstanceId", serviceEntity.getServiceInstanceId()); + assertEquals("vFW", serviceEntity.getServiceType()); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceInformationTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceInformationTest.java new file mode 100644 index 0000000..45a1114 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceInformationTest.java @@ -0,0 +1,67 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.ServiceInformation; + +public class ServiceInformationTest { + @Test + public void testServiceInformationWithParameters() { + ServiceInformation serviceInformation = new ServiceInformation("serviceId", + "serviceType", + "subscriberName", + "serviceInstanceId"); + assertEquals("serviceId", serviceInformation.getServiceId()); + assertEquals("serviceType", serviceInformation.getServiceType()); + assertEquals("subscriberName", serviceInformation.getSubscriberName()); + assertEquals("serviceInstanceId", serviceInformation.getServiceInstanceId()); + } + + @Test + public void testServiceInformation() { + ServiceInformation serviceInformation = new ServiceInformation(); + serviceInformation.setServiceId("serviceId"); + serviceInformation.setServiceType("serviceType"); + serviceInformation.setSubscriberName("subscriberName"); + serviceInformation.setServiceInstanceId("serviceInstanceId"); + assertEquals("serviceId", serviceInformation.getServiceId()); + assertEquals("serviceType", serviceInformation.getServiceType()); + assertEquals("subscriberName", serviceInformation.getSubscriberName()); + assertEquals("serviceInstanceId", serviceInformation.getServiceInstanceId()); + String serviceInformationString = serviceInformation.toString(); + assertTrue(serviceInformationString + .contains("[serviceId=serviceId,serviceType=serviceType,subscriberName=subscriberName," + + "serviceInstanceId=serviceInstanceId]")); + } + + @Test + public void testServiceInformationIsEqual() { + ServiceInformation serviceInformation1 = new ServiceInformation("serviceId1", + "serviceType1", + "subscriberName1", + "serviceInstanceId1"); + assertTrue(serviceInformation1.equals(serviceInformation1)); + assertTrue(serviceInformation1.hashCode() == -1226728686); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceInstanceTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceInstanceTest.java new file mode 100644 index 0000000..73e839e --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceInstanceTest.java @@ -0,0 +1,148 @@ +/* + * ============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.sdnc.test; + +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.sdnc.model.RelatedToProperty; +import org.onap.pomba.contextbuilder.sdnc.model.Relationship; +import org.onap.pomba.contextbuilder.sdnc.model.RelationshipDatum; +import org.onap.pomba.contextbuilder.sdnc.model.RelationshipList; +import org.onap.pomba.contextbuilder.sdnc.model.ServiceInstance; + +public class ServiceInstanceTest { + @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()); + + } + + @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 listOfRelationship = new ArrayList(); + Relationship relationship = new Relationship("relatedTo", + "relatedLink", + new ArrayList(), + new ArrayList()); + 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()); + + 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)); + assertTrue(serviceInstance1.hashCode() == 535776279); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceStatusTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceStatusTest.java new file mode 100644 index 0000000..ea6a9d6 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/ServiceStatusTest.java @@ -0,0 +1,83 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.ServiceStatus; + +public class ServiceStatusTest { + @Test + public void testServiceStatusWithParameters() { + ServiceStatus serviceStatus = new ServiceStatus("responseTimestamp", + "vnfsdnAction", + "rpcAction", + "rpcName", + "responseCode", + "finalIndicator", + "requestStatus"); + assertEquals("responseTimestamp", serviceStatus.getResponseTimestamp()); + assertEquals("vnfsdnAction", serviceStatus.getVnfsdnAction()); + assertEquals("rpcAction", serviceStatus.getRpcAction()); + assertEquals("rpcName", serviceStatus.getRpcName()); + assertEquals("responseCode", serviceStatus.getResponseCode()); + assertEquals("finalIndicator", serviceStatus.getFinalIndicator()); + assertEquals("requestStatus", serviceStatus.getRequestStatus()); + } + + @Test + public void testServiceStatus() { + ServiceStatus serviceStatus = new ServiceStatus(); + serviceStatus.setResponseTimestamp("responseTimestamp"); + serviceStatus.setVnfsdnAction("vnfsdnAction"); + serviceStatus.setRpcAction("rpcAction"); + serviceStatus.setRpcName("rpcName"); + serviceStatus.setResponseCode("responseCode"); + serviceStatus.setFinalIndicator("finalIndicator"); + serviceStatus.setRequestStatus("requestStatus"); + assertEquals("responseTimestamp", serviceStatus.getResponseTimestamp()); + assertEquals("vnfsdnAction", serviceStatus.getVnfsdnAction()); + assertEquals("rpcAction", serviceStatus.getRpcAction()); + assertEquals("responseCode", serviceStatus.getResponseCode()); + assertEquals("rpcName", serviceStatus.getRpcName()); + assertEquals("finalIndicator", serviceStatus.getFinalIndicator()); + assertEquals("requestStatus", serviceStatus.getRequestStatus()); + String serviceStatusString = serviceStatus.toString(); + assertTrue(serviceStatusString + .contains("[responseTimestamp=responseTimestamp,vnfsdnAction=vnfsdnAction,rpcAction=rpcAction," + + "rpcName=rpcName,responseCode=responseCode,finalIndicator=finalIndicator," + + "requestStatus=requestStatus]")); + } + + @Test + public void testServiceStatusIsEqual() { + ServiceStatus serviceStatus1 = new ServiceStatus("responseTimestamp1", + "vnfsdnAction1", + "rpcAction1", + "rpcName1", + "responseCode1", + "finalIndicator1", + "requestStatus1"); + assertTrue(serviceStatus1.equals(serviceStatus1)); + assertTrue(serviceStatus1.hashCode() == -1947783113); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VfModuleTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VfModuleTest.java new file mode 100644 index 0000000..37b3a0a --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VfModuleTest.java @@ -0,0 +1,149 @@ +/* + * ============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.sdnc.test; + +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.sdnc.model.RelatedToProperty; +import org.onap.pomba.contextbuilder.sdnc.model.Relationship; +import org.onap.pomba.contextbuilder.sdnc.model.RelationshipDatum; +import org.onap.pomba.contextbuilder.sdnc.model.RelationshipList; +import org.onap.pomba.contextbuilder.sdnc.model.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 listOfRelationship = new ArrayList(); + Relationship relationship = new Relationship("relatedTo", + "relatedLink", + new ArrayList(), + new ArrayList()); + 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() ); + + 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() ); + VfModule vfModule2 = new VfModule("vfModuleId2", + "vfModuleName2", + "heatStackId2", + "orchestrationStatus2", + true, + "resourceVersion2", + "modelInvariantId2", + "modelVersionId2", + "modelCustomizationId2", + 1, + new RelationshipList() ); + VfModule vfModule3 = new VfModule("vfModuleId1", + "vfModuleName1", + "heatStackId1", + "orchestrationStatus1", + true, + "resourceVersion1", + "modelInvariantId1", + "modelVersionId1", + "modelCustomizationId1", + 1, + new RelationshipList() ); + + assertTrue(vfModule1.equals(vfModule1)); + assertTrue(!vfModule1.equals(vfModule2)); + assertTrue(vfModule1.equals(vfModule3)); + assertTrue(vfModule1.hashCode() == -1559779341); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VfModulesTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VfModulesTest.java new file mode 100644 index 0000000..5229a9e --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VfModulesTest.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.sdnc.test; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.VfModule; +import org.onap.pomba.contextbuilder.sdnc.model.VfModules; + +public class VfModulesTest { + @Test + public void testVfModules() { + VfModules vfModules = new VfModules(); + + List vfModuleList = new ArrayList(); + vfModuleList.add(new VfModule()); + vfModules.setVfModule(vfModuleList); + + assertTrue(vfModules.getVfModule().get(0) instanceof VfModule); + } + + @Test + public void testVfModulesWithParameters() { + VfModules vfModules = new VfModules(new ArrayList()); + + String vfModulesString = vfModules.toString(); + assertTrue(vfModulesString.contains("[vfModule=")); + } + + @Test + public void testVfModulesEquals() { + VfModules vfModules1 = new VfModules(new ArrayList()); + VfModules vfModules2 = new VfModules(new ArrayList()); + + assertTrue(vfModules1.equals(vfModules1)); + assertTrue(vfModules1.equals(vfModules2)); + assertTrue(vfModules1.hashCode() == 630); + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VmNameTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VmNameTest.java new file mode 100644 index 0000000..ae738ef --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VmNameTest.java @@ -0,0 +1,50 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.VmName; + +public class VmNameTest { + @Test + public void testVmNameWithParameters() { + VmName vmName = new VmName("vmName"); + assertEquals("vmName", vmName.getVmName()); + } + + @Test + public void testVmName() { + VmName vmName = new VmName(); + vmName.setVmName("vmName"); + assertEquals("vmName", vmName.getVmName()); + String vmNameString = vmName.toString(); + assertTrue(vmNameString.contains("[vmName=vmName]")); + } + + @Test + public void testVmNameIsEqual() { + VmName vmName1 = new VmName("vmName1"); + assertTrue(vmName1.equals(vmName1)); + assertTrue(vmName1.hashCode() == 546861742); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VmNetworkTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VmNetworkTest.java new file mode 100644 index 0000000..b6704c4 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VmNetworkTest.java @@ -0,0 +1,81 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.NetworkIp; +import org.onap.pomba.contextbuilder.sdnc.model.NetworkIpV6; +import org.onap.pomba.contextbuilder.sdnc.model.VmNetwork; + +public class VmNetworkTest { + @Test + public void testVmNetworkWithParameters() { + VmNetwork vmNetwork = new VmNetwork("networkRole", + new ArrayList(), + "floatingIp", + "useDhcp", + new ArrayList(), + "floatingIpV6"); + assertEquals("networkRole", vmNetwork.getNetworkRole()); + assertEquals(new ArrayList(), vmNetwork.getNetworkIpsV6()); + assertEquals("floatingIp", vmNetwork.getFloatingIp()); + assertEquals("useDhcp", vmNetwork.getUseDhcp()); + assertEquals(new ArrayList(), vmNetwork.getNetworkIps()); + assertEquals("floatingIpV6", vmNetwork.getFloatingIpV6()); + } + + @Test + public void testVmNetwork() { + VmNetwork vmNetwork = new VmNetwork(); + vmNetwork.setNetworkRole("networkRole"); + vmNetwork.setNetworkIpsV6(new ArrayList()); + vmNetwork.setFloatingIp("floatingIp"); + vmNetwork.setUseDhcp("useDhcp"); + vmNetwork.setNetworkIps(new ArrayList()); + vmNetwork.setFloatingIpV6("floatingIpV6"); + assertEquals("networkRole", vmNetwork.getNetworkRole()); + assertEquals(new ArrayList(), vmNetwork.getNetworkIpsV6()); + assertEquals("floatingIp", vmNetwork.getFloatingIp()); + assertEquals(new ArrayList(), vmNetwork.getNetworkIps()); + assertEquals("useDhcp", vmNetwork.getUseDhcp()); + assertEquals("floatingIpV6", vmNetwork.getFloatingIpV6()); + String vmNetworkString = vmNetwork.toString(); + assertTrue(vmNetworkString.contains("networkRole=networkRole")); + assertTrue(vmNetworkString.contains("floatingIp=floatingIp,useDhcp=useDhcp")); + assertTrue(vmNetworkString.contains("floatingIpV6=floatingIpV6")); + } + + + @Test + public void testVmNetworkIsEqual() { + VmNetwork vmNetwork1 = new VmNetwork("networkRole1", + new ArrayList(), + "floatingIp1", + "useDhcp1", + new ArrayList(), + "floatingIpV61"); + assertTrue(vmNetwork1.equals(vmNetwork1)); + assertTrue(vmNetwork1.hashCode() == -103133323); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfAssignmentsTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfAssignmentsTest.java new file mode 100644 index 0000000..e499d73 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfAssignmentsTest.java @@ -0,0 +1,66 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.AvailabilityZone; +import org.onap.pomba.contextbuilder.sdnc.model.VnfAssignments; +import org.onap.pomba.contextbuilder.sdnc.model.VnfNetwork; +import org.onap.pomba.contextbuilder.sdnc.model.VnfVm; + +public class VnfAssignmentsTest { + @Test + public void testVnfAssignmentsWithParameters() { + VnfAssignments vnfAssignments = new VnfAssignments(new ArrayList(), + new ArrayList(), + new ArrayList()); + assertEquals(new ArrayList(), vnfAssignments.getVnfNetworks()); + assertEquals(new ArrayList(), vnfAssignments.getAvailabilityZones()); + assertEquals(new ArrayList(), vnfAssignments.getVnfVms()); + } + + @Test + public void testVnfAssignments() { + VnfAssignments vnfAssignments = new VnfAssignments(); + vnfAssignments.setVnfNetworks(new ArrayList()); + vnfAssignments.setAvailabilityZones(new ArrayList()); + vnfAssignments.setVnfVms(new ArrayList()); + + assertEquals(new ArrayList(), vnfAssignments.getVnfNetworks()); + assertEquals(new ArrayList(), vnfAssignments.getAvailabilityZones()); + assertEquals(new ArrayList(), vnfAssignments.getVnfVms()); + + String vnfAssignmentsString = vnfAssignments.toString(); + assertTrue(vnfAssignmentsString.contains("vnfNetworks")); + } + + @Test + public void testVnfAssignmentsIsEqual() { + VnfAssignments vnfAssignments1 = new VnfAssignments(new ArrayList(), + new ArrayList(), + new ArrayList()); + assertTrue(vnfAssignments1.equals(vnfAssignments1)); + assertTrue(vnfAssignments1.hashCode() == 30784); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfInstanceTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfInstanceTest.java new file mode 100644 index 0000000..73b8213 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfInstanceTest.java @@ -0,0 +1,253 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.RelationshipList; +import org.onap.pomba.contextbuilder.sdnc.model.VfModules; +import org.onap.pomba.contextbuilder.sdnc.model.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.setInMaint(true); + vnfInstance.setMsoCatalogKey("msoCatalogKey"); + vnfInstance.setProvStatus("ProvStatus"); + 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.getInMaint()); + assertEquals("msoCatalogKey", vnfInstance.getMsoCatalogKey()); + assertEquals("ProvStatus", vnfInstance.getProvStatus()); + 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", + "provStatus", + "licenseKey", + "equipmentRole", + "orchestrationStatus", + "heatStackId", + "msoCatalogKey", + "ipv4OamAddress", + "ipv4Loopback0Address", + "nmLanV6Address", + "managementV6Address", + true, + true, + "resourceVersion", + "modelInvariantId", + "modelVersionId", + "modelCustomizationId", + "nfType", + "nfFunction", + "nfRole", + "nfNamingCode", + new RelationshipList(), + new VfModules()); + + 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.getInMaint()); + assertEquals("msoCatalogKey", vnfInstance.getMsoCatalogKey()); + assertEquals("provStatus", vnfInstance.getProvStatus()); + 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," + + "provStatus=provStatus,licenseKey=licenseKey,equipmentRole=equipmentRole," + + "orchestrationStatus=orchestrationStatus,heatStackId=heatStackId," + + "msoCatalogKey=msoCatalogKey,ipv4OamAddress=ipv4OamAddress," + + "ipv4Loopback0Address=ipv4Loopback0Address,nmLanV6Address=nmLanV6Address," + + "managementV6Address=managementV6Address,inMaint=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", + "ProvStatus1", + "licenseKey1", + "equipmentRole1", + "orchestrationStatus1", + "heatStackId1", + "msoCatalogKey1", + "ipv4OamAddress1", + "ipv4Loopback0Address1", + "nmLanV6Address1", + "managementV6Address1", + true, + true, + "resourceVersion1", + "modelInvariantId1", + "modelVersionId1", + "modelCustomizationId1", + "nfType1", + "nfFunction1", + "nfRole1", + "nfNamingCode1", + new RelationshipList(), + new VfModules()); + VnfInstance vnfInstance2 = new VnfInstance("vnfId2", + "vnfName2", + "vnfName2-2", + "vnfType2", + "serviceId2", + "ProvStatus2", + "licenseKey2", + "equipmentRole2", + "orchestrationStatus2", + "heatStackId2", + "msoCatalogKey2", + "ipv4OamAddress2", + "ipv4Loopback0Address2", + "nmLanV6Address2", + "managementV6Address2", + true, + true, + "resourceVersion2", + "modelInvariantId2", + "modelVersionId2", + "modelCustomizationId2", + "nfType2", + "nfFunction2", + "nfRole2", + "nfNamingCode2", + new RelationshipList(), + new VfModules()); + VnfInstance vnfInstance3 = new VnfInstance("vnfId1", + "vnfName1", + "vnfName2-1", + "vnfType1", + "serviceId1", + "ProvStatus1", + "licenseKey1", + "equipmentRole1", + "orchestrationStatus1", + "heatStackId1", + "msoCatalogKey1", + "ipv4OamAddress1", + "ipv4Loopback0Address1", + "nmLanV6Address1", + "managementV6Address1", + true, + true, + "resourceVersion1", + "modelInvariantId1", + "modelVersionId1", + "modelCustomizationId1", + "nfType1", + "nfFunction1", + "nfRole1", + "nfNamingCode1", + new RelationshipList(), + new VfModules()); + + assertTrue(vnfInstance1.equals(vnfInstance1)); + assertTrue(!vnfInstance1.equals(vnfInstance2)); + assertTrue(vnfInstance1.equals(vnfInstance3)); + assertTrue(vnfInstance1.hashCode() == 677011731); + + } +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfListTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfListTest.java new file mode 100644 index 0000000..60bf199 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfListTest.java @@ -0,0 +1,52 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.Vnf; +import org.onap.pomba.contextbuilder.sdnc.model.VnfList; + +public class VnfListTest { + @Test + public void testVnfListWithParameters() { + VnfList vnfList = new VnfList(new ArrayList()); + assertEquals(new ArrayList(), vnfList.getVnfList()); + } + + @Test + public void testVnfList() { + VnfList vnfList = new VnfList(); + vnfList.setVnfList(new ArrayList()); + assertEquals(new ArrayList(), vnfList.getVnfList()); + String vnfListString = vnfList.toString(); + assertTrue(vnfListString.contains("vnfList")); + } + + @Test + public void testVnfListIsEqual() { + VnfList vnfList1 = new VnfList(new ArrayList()); + assertTrue(vnfList1.equals(vnfList1)); + assertTrue(vnfList1.hashCode() == 32); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfNetworkTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfNetworkTest.java new file mode 100644 index 0000000..4028130 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfNetworkTest.java @@ -0,0 +1,72 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.VnfNetwork; + +public class VnfNetworkTest { + @Test + public void testVnfNetworkWithParameters() { + VnfNetwork vnfNetwork = new VnfNetwork("networkRole", + "contrailNetworkFqdn", + "networkName", + "networkId", + "neutronId"); + assertEquals("networkRole", vnfNetwork.getNetworkRole()); + assertEquals("contrailNetworkFqdn", vnfNetwork.getContrailNetworkFqdn()); + assertEquals("networkName", vnfNetwork.getNetworkName()); + assertEquals("networkId", vnfNetwork.getNetworkId()); + assertEquals("neutronId", vnfNetwork.getNeutronId()); + } + + @Test + public void testVnfNetwork() { + VnfNetwork vnfNetwork = new VnfNetwork(); + vnfNetwork.setNetworkRole("networkRole"); + vnfNetwork.setContrailNetworkFqdn("contrailNetworkFqdn"); + vnfNetwork.setNetworkName("networkName"); + vnfNetwork.setNetworkId("networkId"); + vnfNetwork.setNeutronId("neutronId"); + assertEquals("networkRole", vnfNetwork.getNetworkRole()); + assertEquals("contrailNetworkFqdn", vnfNetwork.getContrailNetworkFqdn()); + assertEquals("networkName", vnfNetwork.getNetworkName()); + assertEquals("networkId", vnfNetwork.getNetworkId()); + assertEquals("neutronId", vnfNetwork.getNeutronId()); + String vnfNetworkString = vnfNetwork.toString(); + assertTrue(vnfNetworkString + .contains("[networkRole=networkRole,contrailNetworkFqdn=contrailNetworkFqdn," + + "networkName=networkName,networkId=networkId,neutronId=neutronId]")); + } + + @Test + public void testVnfNetworkIsEqual() { + VnfNetwork vnfNetwork1 = new VnfNetwork("networkRole1", + "contrailNetworkFqdn1", + "networkName1", + "networkId1", + "neutronId1"); + assertTrue(vnfNetwork1.equals(vnfNetwork1)); + assertTrue(vnfNetwork1.hashCode() == -1838617061); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfParameterTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfParameterTest.java new file mode 100644 index 0000000..58a8399 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfParameterTest.java @@ -0,0 +1,54 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.VnfParameter; + +public class VnfParameterTest { + @Test + public void testVnfParameterWithParameters() { + VnfParameter vnfParamter = new VnfParameter("vnfParameterName", "vnfParameterValue"); + assertEquals("vnfParameterName", vnfParamter.getVnfParameterName()); + assertEquals("vnfParameterValue", vnfParamter.getVnfParameterValue()); + } + + @Test + public void testVnfParameter() { + VnfParameter vnfParamter = new VnfParameter(); + vnfParamter.setVnfParameterName("vnfParameterName"); + vnfParamter.setVnfParameterValue("vnfParameterValue"); + assertEquals("vnfParameterName", vnfParamter.getVnfParameterName()); + assertEquals("vnfParameterValue", vnfParamter.getVnfParameterValue()); + String vnfParamterString = vnfParamter.toString(); + assertTrue(vnfParamterString + .contains("[vnfParameterName=vnfParameterName,vnfParameterValue=vnfParameterValue]")); + } + + @Test + public void testVnfParameterIsEqual() { + VnfParameter vnfParamter1 = new VnfParameter("vnfParameterName1", "vnfParameterValue1"); + assertTrue(vnfParamter1.equals(vnfParamter1)); + assertTrue(vnfParamter1.hashCode() == -1128531727); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfRequestInformationTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfRequestInformationTest.java new file mode 100644 index 0000000..531a4b6 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfRequestInformationTest.java @@ -0,0 +1,93 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.VnfRequestInformation; + +public class VnfRequestInformationTest { + @Test + public void testVnfRequestInformationWithParameters() { + VnfRequestInformation vnfRequestInformation = new VnfRequestInformation("vnfName", + "tenant", + "aicCloudRegion", + "usePreload", + "vnfType", + "vnfId", + "genericVnfType", + "genericVnfName", + "genericVnfId"); + assertEquals("vnfName", vnfRequestInformation.getVnfName()); + assertEquals("tenant", vnfRequestInformation.getTenant()); + assertEquals("aicCloudRegion", vnfRequestInformation.getAicCloudRegion()); + assertEquals("usePreload", vnfRequestInformation.getUsePreload()); + assertEquals("vnfType", vnfRequestInformation.getVnfType()); + assertEquals("vnfId", vnfRequestInformation.getVnfId()); + assertEquals("genericVnfType", vnfRequestInformation.getGenericVnfType()); + assertEquals("genericVnfName", vnfRequestInformation.getGenericVnfName()); + assertEquals("genericVnfId", vnfRequestInformation.getGenericVnfId()); + } + + @Test + public void testVnfRequestInformation() { + VnfRequestInformation vnfRequestInformation = new VnfRequestInformation(); + vnfRequestInformation.setVnfName("vnfName"); + vnfRequestInformation.setTenant("tenant"); + vnfRequestInformation.setAicCloudRegion("aicCloudRegion"); + vnfRequestInformation.setUsePreload("usePreload"); + vnfRequestInformation.setVnfType("vnfType"); + vnfRequestInformation.setVnfId("vnfId"); + vnfRequestInformation.setGenericVnfType("genericVnfType"); + vnfRequestInformation.setGenericVnfName("genericVnfName"); + vnfRequestInformation.setGenericVnfId("genericVnfId"); + assertEquals("vnfName", vnfRequestInformation.getVnfName()); + assertEquals("tenant", vnfRequestInformation.getTenant()); + assertEquals("aicCloudRegion", vnfRequestInformation.getAicCloudRegion()); + assertEquals("usePreload", vnfRequestInformation.getUsePreload()); + assertEquals("vnfType", vnfRequestInformation.getVnfType()); + assertEquals("vnfId", vnfRequestInformation.getVnfId()); + assertEquals("genericVnfType", vnfRequestInformation.getGenericVnfType()); + assertEquals("genericVnfName", vnfRequestInformation.getGenericVnfName()); + assertEquals("genericVnfId", vnfRequestInformation.getGenericVnfId()); + String vnfRequestInformationString = vnfRequestInformation.toString(); + assertTrue(vnfRequestInformationString + .contains("[vnfName=vnfName,tenant=tenant,aicCloudRegion=aicCloudRegion,usePreload=usePreload," + + "vnfType=vnfType,vnfId=vnfId,genericVnfType=genericVnfType," + + "genericVnfName=genericVnfName,genericVnfId=genericVnfId]")); + } + + @Test + public void testVnfRequestInformationIsEqual() { + VnfRequestInformation vnfRequestInformation1 = new VnfRequestInformation("vnfName1", + "tenant1", + "aicCloudRegion1", + "usePreload1", + "vnfType1", + "vnfId1", + "genericVnfType1", + "genericVnfName1", + "genericVnfId1"); + assertTrue(vnfRequestInformation1.equals(vnfRequestInformation1)); + assertTrue(vnfRequestInformation1.hashCode() == 869221953); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfTest.java new file mode 100644 index 0000000..e64804a --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfTest.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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.ServiceData; +import org.onap.pomba.contextbuilder.sdnc.model.ServiceStatus; +import org.onap.pomba.contextbuilder.sdnc.model.Vnf; + +public class VnfTest { + @Test + public void testVnfWithParameters() { + Vnf vnf = new Vnf("vnfId", new ServiceStatus(), new ServiceData()); + assertEquals("vnfId", vnf.getVnfId()); + } + + @Test + public void testVnf() { + Vnf vnf = new Vnf(); + vnf.setVnfId("vnfId"); + vnf.setServiceStatus(new ServiceStatus()); + vnf.setServiceData(new ServiceData()); + assertEquals("vnfId", vnf.getVnfId()); + assertEquals(new ServiceStatus(), vnf.getServiceStatus()); + assertEquals(new ServiceData(), vnf.getServiceData()); + String vnfString = vnf.toString(); + assertTrue(vnfString.contains("vnfId")); + } + + @Test + public void testVnfIsEqual() { + Vnf vnf1 = new Vnf("vnfId", new ServiceStatus(), new ServiceData()); + assertTrue(vnf1.equals(vnf1)); + assertTrue(vnf1.hashCode() == -1891585304); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfTopologyIdentifierTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfTopologyIdentifierTest.java new file mode 100644 index 0000000..a4a36f3 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfTopologyIdentifierTest.java @@ -0,0 +1,72 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.VnfTopologyIdentifier; + +public class VnfTopologyIdentifierTest { + @Test + public void testVnfTopologyIdentifierWithParameters() { + VnfTopologyIdentifier vnfTopologyIdentifier = new VnfTopologyIdentifier("genericVnfType", + "serviceType", + "vnfName", + "genericVnfName", + "vnfType"); + assertEquals("genericVnfType", vnfTopologyIdentifier.getGenericVnfType()); + assertEquals("serviceType", vnfTopologyIdentifier.getServiceType()); + assertEquals("vnfName", vnfTopologyIdentifier.getVnfName()); + assertEquals("genericVnfName", vnfTopologyIdentifier.getGenericVnfName()); + assertEquals("vnfType", vnfTopologyIdentifier.getVnfType()); + } + + @Test + public void testVnfTopologyIdentifier() { + VnfTopologyIdentifier vnfTopologyIdentifier = new VnfTopologyIdentifier(); + vnfTopologyIdentifier.setGenericVnfType("genericVnfType"); + vnfTopologyIdentifier.setServiceType("serviceType"); + vnfTopologyIdentifier.setVnfName("vnfName"); + vnfTopologyIdentifier.setGenericVnfName("genericVnfName"); + vnfTopologyIdentifier.setVnfType("vnfType"); + assertEquals("genericVnfType", vnfTopologyIdentifier.getGenericVnfType()); + assertEquals("serviceType", vnfTopologyIdentifier.getServiceType()); + assertEquals("vnfName", vnfTopologyIdentifier.getVnfName()); + assertEquals("genericVnfName", vnfTopologyIdentifier.getGenericVnfName()); + assertEquals("vnfType", vnfTopologyIdentifier.getVnfType()); + String vnfTopologyIdentifierString = vnfTopologyIdentifier.toString(); + assertTrue(vnfTopologyIdentifierString + .contains("[genericVnfType=genericVnfType,serviceType=serviceType,vnfName=vnfName," + + "genericVnfName=genericVnfName,vnfType=vnfType]")); + } + + @Test + public void testVnfTopologyIdentifierIsEqual() { + VnfTopologyIdentifier vnfTopologyIdentifier1 = new VnfTopologyIdentifier("genericVnfType1", + "serviceType1", + "vnfName1", + "genericVnfName1", + "vnfType1"); + assertTrue(vnfTopologyIdentifier1.equals(vnfTopologyIdentifier1)); + assertTrue(vnfTopologyIdentifier1.hashCode() == 1705030683); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfTopologyInformationTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfTopologyInformationTest.java new file mode 100644 index 0000000..f33d5c4 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfTopologyInformationTest.java @@ -0,0 +1,62 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.VnfAssignments; +import org.onap.pomba.contextbuilder.sdnc.model.VnfParameter; +import org.onap.pomba.contextbuilder.sdnc.model.VnfTopologyIdentifier; +import org.onap.pomba.contextbuilder.sdnc.model.VnfTopologyInformation; + +public class VnfTopologyInformationTest { + @Test + public void testVnfTopologyInformationWithParameters() { + VnfTopologyInformation vnfTopologyInformation = new VnfTopologyInformation(new VnfTopologyIdentifier(), + new VnfAssignments(), + new ArrayList()); + assertEquals(new VnfTopologyIdentifier(), vnfTopologyInformation.getVnfTopologyIdentifier()); + assertEquals(new VnfAssignments(), vnfTopologyInformation.getVnfAssignments()); + assertEquals(new ArrayList(), vnfTopologyInformation.getVnfParameters()); + } + + @Test + public void testVnfTopologyInformation() { + VnfTopologyInformation vnfTopologyInformation = new VnfTopologyInformation(); + vnfTopologyInformation.setVnfTopologyIdentifier(new VnfTopologyIdentifier()); + vnfTopologyInformation.setVnfAssignments(new VnfAssignments()); + vnfTopologyInformation.setVnfParameters(new ArrayList()); + assertEquals(new VnfTopologyIdentifier(), vnfTopologyInformation.getVnfTopologyIdentifier()); + assertEquals(new VnfAssignments(), vnfTopologyInformation.getVnfAssignments()); + assertEquals(new ArrayList(), vnfTopologyInformation.getVnfParameters()); + } + + @Test + public void testVnfTopologyInformationIsEqual() { + VnfTopologyInformation vnfTopologyInformation1 = new VnfTopologyInformation(new VnfTopologyIdentifier(), + new VnfAssignments(), + new ArrayList()); + assertTrue(vnfTopologyInformation1.equals(vnfTopologyInformation1)); + assertTrue(vnfTopologyInformation1.hashCode() == 917116897); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfVmTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfVmTest.java new file mode 100644 index 0000000..f835a41 --- /dev/null +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/test/VnfVmTest.java @@ -0,0 +1,59 @@ +/* + * ============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.sdnc.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import org.junit.Test; +import org.onap.pomba.contextbuilder.sdnc.model.VmName; +import org.onap.pomba.contextbuilder.sdnc.model.VmNetwork; +import org.onap.pomba.contextbuilder.sdnc.model.VnfVm; + +public class VnfVmTest { + @Test + public void testVnfVmWithParameters() { + VnfVm vnfVm = new VnfVm("vmType", new ArrayList(), 1, new ArrayList()); + assertEquals("vmType", vnfVm.getVmType()); + } + + @Test + public void testVnfVm() { + VnfVm vnfVm = new VnfVm(); + vnfVm.setVmType("vmType"); + vnfVm.setVmNetworks(new ArrayList()); + vnfVm.setVmCount(1); + vnfVm.setVmNames(new ArrayList()); + assertEquals("vmType", vnfVm.getVmType()); + assertEquals(new ArrayList(), vnfVm.getVmNetworks()); + assertTrue(vnfVm.getVmCount() == 1); + assertEquals(new ArrayList(), vnfVm.getVmNames()); + String vnfVmString = vnfVm.toString(); + assertTrue(vnfVmString.contains("vmType")); + } + + @Test + public void testVnfVmIsEqual() { + VnfVm vnfVm1 = new VnfVm("vmType", new ArrayList(), 1, new ArrayList()); + assertTrue(vnfVm1.equals(vnfVm1)); + assertTrue(vnfVm1.hashCode() == -1026070735); + } + +} diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/unittest/service/SdncContextBuilderTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/unittest/service/SdncContextBuilderTest.java index 2095169..46c4eb5 100644 --- a/src/test/java/org/onap/pomba/contextbuilder/sdnc/unittest/service/SdncContextBuilderTest.java +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/unittest/service/SdncContextBuilderTest.java @@ -29,10 +29,13 @@ import static org.mockito.Mockito.when; import com.github.jknack.handlebars.internal.Files; import com.github.tomakehurst.wiremock.junit.WireMockRule; import java.io.File; +import java.io.IOException; import java.util.Collections; +import java.util.UUID; +import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import org.junit.After; @@ -40,6 +43,9 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.aai.restclient.client.RestClient; +import org.onap.pomba.contextbuilder.sdnc.Application; +import org.onap.pomba.contextbuilder.sdnc.model.ServiceEntity; import org.onap.pomba.contextbuilder.sdnc.service.rs.RestService; import org.onap.pomba.contextbuilder.sdnc.util.RestUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -50,30 +56,37 @@ 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.aai.restclient.client.RestClient; -import org.onap.pomba.contextbuilder.sdnc.Application; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.UUID; -import org.onap.pomba.contextbuilder.sdnc.model.ServiceEntity; @RunWith(SpringJUnit4ClassRunner.class) @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class}) @WebAppConfiguration @SpringBootTest (classes = Application.class) -@TestPropertySource(properties = {"sdnc.host=localhost", "sdnc.port=30202", - "aai.httpProtocol=http", "aai.serviceName=localhost", "aai.servicePort=9808"}) +@TestPropertySource(properties = {"sdnc.serviceName=localhost", + "sdnc.servicePort=30202", + "aai.httpProtocol=http", + "aai.serviceName=localhost", + "aai.servicePort=9808"}) + public class SdncContextBuilderTest { - private String serviceInstanceId = "7d518257-49bd-40ac-8d17-017a726ec12a"; //match to the test data in junit/queryNodeData-1.json private String testRestHeaders = "testRestHeaders"; - private String customerId = "DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2"; // match to queryNodeData-1.json and customerData-1.json - @Autowired + private String servicePath = "/service-subscriptions/service-subscription/vFW/service-instances/service-instance/"; + private String genericVnfPath = "/aai/v11/network/generic-vnfs/generic-vnf/"; + private String genericResourcePath = "/restconf/config/GENERIC-RESOURCE-API:services/service/"; + private String vnfPath = "/restconf/config/VNF-API:vnfs/vnf-list/"; + private String serviceInstanceIdVfw = "7d518257-49bd-40ac-8d17-017a726ec12a"; // customerData.json + private String serviceInstanceIdVcpe = "68352304-7bba-4609-8551-0d0b819376c3"; // queryNodeDataVcpe.json + private String customerIdVfw = "DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2"; // customerData.json + private String customerIdVcpe = "SDN-ETHERNET-INTERNET"; + private String genericVnfId = "d94daff6-7d5b-4d2e-bc99-c9af0754b59d"; + private String moduleId = "2c3f8902-f278-4ee3-93cf-9d2364cbafca"; + + HttpServletRequest httpServletRequest = mock(HttpServletRequest.class); + + @Autowired RestService service; @Autowired private String sdncCtxBuilderBasicAuthorization; - //AAI related @Autowired private String aaiBasicAuthorization; @@ -108,7 +121,7 @@ public class SdncContextBuilderTest { null, testRestHeaders, sdncCtxBuilderBasicAuthorization); when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl); - Response response = service.getContext(mockHttpHeaders, serviceInstanceId); + Response response = service.getContext(httpServletRequest, mockHttpHeaders, serviceInstanceIdVfw); assertTrue(response.getEntity().toString().contains("Missing header parameter: " + RestUtil.FROM_APP_ID)); // Test with no Authorization @@ -116,15 +129,15 @@ public class SdncContextBuilderTest { "test2", testRestHeaders, null); when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl1); - response = service.getContext(mockHttpHeaders, serviceInstanceId); + response = service.getContext(httpServletRequest, mockHttpHeaders, serviceInstanceIdVfw); assertTrue(response.getEntity().toString().contains("Missing header parameter: " + RestUtil.AUTHORIZATION)); // Test with garbage Authorization final MultivaluedMap multivaluedMapImpl2 = buildHeaders( - "test2", testRestHeaders, "garbage"); + "test3", testRestHeaders, "garbage"); when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl2); - response = service.getContext(mockHttpHeaders, serviceInstanceId); + response = service.getContext(httpServletRequest, mockHttpHeaders, serviceInstanceIdVfw); assertTrue(response.getEntity().toString().contains("Failed Basic " + RestUtil.AUTHORIZATION)); } @@ -135,114 +148,150 @@ public class SdncContextBuilderTest { "testRestParameterServiceInstanceId", "test1", sdncCtxBuilderBasicAuthorization); when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl); - Response response = service.getContext(mockHttpHeaders, null); - assertTrue(response.getEntity().toString().contains("Invalid request URL, missing parameter: serviceInstanceId")); + Response response = service.getContext(httpServletRequest, mockHttpHeaders, null); + assertTrue(response + .getEntity() + .toString() + .contains("Invalid request URL, missing parameter: serviceInstanceId")); } - /*@Test + @Test public void testVerifySdncContextBuilder() throws Exception { - String urlStr = "/restconf/config/GENERIC-RESOURCE-API:services/service/" + serviceInstanceId; - File file = new File(ClassLoader.getSystemResource("sdncResponse.json").getFile()); - String sdResonse = Files.read(file); - this.sdncRule.stubFor(get(urlStr).willReturn(okJson(sdResonse))); HttpHeaders mockHttpHeaders = mock( HttpHeaders.class); final MultivaluedMap multivaluedMapImpl = buildHeaders( "testVerifyServiceDecomposition", "test1", sdncCtxBuilderBasicAuthorization); - when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl); - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); - String customerUrl = aaiPathToCustomerQuery + customerId; - addResponse(customerUrl, "junit/customerData-1.json", aaiEnricherRule); + // First try a vFW service instance + + String queryNodeVfwUrl = aaiPathToSearchNodeQuery + serviceInstanceIdVfw; + addResponse(queryNodeVfwUrl, "junit/queryNodeDataVfw.json", aaiEnricherRule); + + String customerVfwUrl = aaiPathToCustomerQuery + customerIdVfw; + addResponse(customerVfwUrl, "junit/customerData.json", aaiEnricherRule); + + String serviceInstanceUrl = aaiPathToCustomerQuery + + customerIdVfw + + servicePath + + serviceInstanceIdVfw; + addResponse(serviceInstanceUrl, "junit/serviceInstance.json", aaiEnricherRule); + + String vnfApiUrl = vnfPath + moduleId; + addResponse(vnfApiUrl, "junit/vnfApiResponse.json", sdncRule); + + String genericVnfUrl = genericVnfPath + genericVnfId; + addResponse(genericVnfUrl, "junit/genericVnf.json", aaiEnricherRule); + Response response = this.service.getContext(httpServletRequest, mockHttpHeaders, serviceInstanceIdVfw); + assertEquals(Status.OK.getStatusCode(), response.getStatus()); + + // Now try a vCPE service instance + + String queryNodeUrlVcpe = aaiPathToSearchNodeQuery + serviceInstanceIdVcpe; + addResponse(queryNodeUrlVcpe, "junit/queryNodeDataVcpe.json", aaiEnricherRule); - Response response = this.service.getContext(mockHttpHeaders, serviceInstanceId); + String customerVcpeUrl = aaiPathToCustomerQuery + customerIdVcpe; + addResponse(customerVcpeUrl, "junit/customerData.json", aaiEnricherRule); + + + String urlStr = genericResourcePath + serviceInstanceIdVcpe; + addResponse(urlStr, "junit/sdncGenericResponse.json", sdncRule); + + response = this.service.getContext(httpServletRequest, mockHttpHeaders, serviceInstanceIdVcpe); assertEquals(Status.OK.getStatusCode(), response.getStatus()); // Try again with no transcactionId final MultivaluedMap multivaluedMapImpl1 = buildHeaders( "testVerifyServiceDecomposition", null, sdncCtxBuilderBasicAuthorization); - when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl1); - response = this.service.getContext(mockHttpHeaders, serviceInstanceId); + response = this.service.getContext(httpServletRequest, mockHttpHeaders, serviceInstanceIdVcpe); assertEquals(Status.OK.getStatusCode(), response.getStatus()); - }*/ - - private static MultivaluedMap buildHeaders( - String partnerName, String transactionId, String authorization) { - - MultivaluedMap headers = new MultivaluedHashMap<>(); - headers.put(RestUtil.FROM_APP_ID, Collections.singletonList(partnerName)); - headers.put(RestUtil.TRANSACTION_ID, Collections.singletonList(transactionId)); - if (null != authorization) { - headers.put(RestUtil.AUTHORIZATION, Collections.singletonList(authorization)); - } - return headers; } + //AAI related @Test - public void testObtainResouceLinkBasedOnServiceInstanceFromAAI() throws Exception { + public void testObtainResouceLinkBasedOnServiceInstanceFromAai() throws Exception { String transactionId = UUID.randomUUID().toString(); - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); - String customerUrl = aaiPathToCustomerQuery + customerId; - addResponse(customerUrl, "junit/customerData-1.json", aaiEnricherRule); - - ServiceEntity serviceEntity = RestUtil.getServiceEntity(aaiClient,aaiBaseUrl,aaiBasicAuthorization, aaiPathToSearchNodeQuery, aaiPathToCustomerQuery, serviceInstanceId, transactionId); - - assertEquals(serviceInstanceId, serviceEntity.getServiceInstanceId()); - assertEquals("vFW", serviceEntity.getServiceType()); // serviceType is hard-coded in queryNodeData-1.json - assertEquals(customerId, serviceEntity.getCustomerId()); // customerId is hard-coded in queryNodeData-1.json - assertEquals("DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2", serviceEntity.getCustomerName()); // customerName is hard-coded in queryNodeData-1.json - assertEquals("CUST", serviceEntity.getCustomerType()); //customerType is hard-coded in customerData-1.json + String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceIdVfw; + addResponse(queryNodeUrl, "junit/queryNodeDataVfw.json", aaiEnricherRule); + String customerUrl = aaiPathToCustomerQuery + customerIdVfw; + addResponse(customerUrl, "junit/customerData.json", aaiEnricherRule); + + ServiceEntity serviceEntity = RestUtil.getServiceEntity(aaiClient, + aaiBaseUrl, + aaiBasicAuthorization, + aaiPathToSearchNodeQuery, + aaiPathToCustomerQuery, + serviceInstanceIdVfw, + transactionId); + + assertEquals(serviceInstanceIdVfw, serviceEntity.getServiceInstanceId()); + assertEquals("vFW", serviceEntity.getServiceType()); // customerData.json + assertEquals(customerIdVfw, serviceEntity.getCustomerId()); // queryNodeData-1.json + assertEquals("DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2", + serviceEntity.getCustomerName()); // customerData.json + assertEquals("CUST", serviceEntity.getCustomerType()); // customerData.json } @Test - public void testObtainResouceLinkBasedOnServiceInstanceFromAAI_nullResourceLink() throws Exception { + public void testObtainResouceLinkBasedOnServiceInstanceFromAaiNullResourceLink() throws Exception { String transactionId = UUID.randomUUID().toString(); - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; - addResponse(queryNodeUrl, "junit/queryNodeData-nullResourceLink.json", aaiEnricherRule); + String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceIdVfw; + addResponse(queryNodeUrl, "junit/queryNodeDataNullResourceLink.json", aaiEnricherRule); try { - RestUtil.getServiceEntity(aaiClient,aaiBaseUrl,aaiBasicAuthorization, aaiPathToSearchNodeQuery, aaiPathToCustomerQuery, serviceInstanceId, transactionId); + RestUtil.getServiceEntity(aaiClient, + aaiBaseUrl, + aaiBasicAuthorization, + aaiPathToSearchNodeQuery, + aaiPathToCustomerQuery, + serviceInstanceIdVfw, + transactionId); } catch (Exception e) { assertTrue(e.getMessage().contains("JSONObject[\"resource-link\"] not found")); } } @Test - public void testObtainResouceLinkBasedOnServiceInstanceFromAAI_nullCustomerType() throws Exception { + public void testObtainResouceLinkBasedOnServiceInstanceFromAaiNullCustomerType() throws Exception { String transactionId = UUID.randomUUID().toString(); - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); - String customerUrl = aaiPathToCustomerQuery + customerId; - addResponse(customerUrl, "junit/customerData-CustomerIdNotFound.json", aaiEnricherRule); + String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceIdVfw; + addResponse(queryNodeUrl, "junit/queryNodeDataVfw.json", aaiEnricherRule); + String customerUrl = aaiPathToCustomerQuery + customerIdVfw; + addResponse(customerUrl, "junit/customerDataCustomerIdNotFound.json", aaiEnricherRule); try { - RestUtil.getServiceEntity(aaiClient,aaiBaseUrl,aaiBasicAuthorization, aaiPathToSearchNodeQuery, aaiPathToCustomerQuery, serviceInstanceId, transactionId); + RestUtil.getServiceEntity(aaiClient, + aaiBaseUrl, + aaiBasicAuthorization, + aaiPathToSearchNodeQuery, + aaiPathToCustomerQuery, + serviceInstanceIdVfw, + transactionId); } catch (Exception e) { assertTrue(e.getMessage().contains("Customer ID cannot be found from AAI")); } } - private void addResponse(String path, String classpathResource, WireMockRule thisMock) throws IOException { - String payload = readFully(ClassLoader.getSystemResourceAsStream(classpathResource)); - thisMock.stubFor(get(path).willReturn(okJson(payload))); + private void addResponse(String url, String responseFile, WireMockRule thisMock) throws IOException { + File file = new File(ClassLoader.getSystemResource(responseFile).getFile()); + String payload = Files.read(file); + thisMock.stubFor(get(url).willReturn(okJson(payload))); } - private String readFully(InputStream in) throws IOException { - char[] cbuf = new char[1024]; - StringBuilder content = new StringBuilder(); - try (InputStreamReader reader = new InputStreamReader(in, "UTF-8")) { - int count; - while ((count = reader.read(cbuf)) >= 0) { - content.append(cbuf, 0, count); - } + private static MultivaluedMap buildHeaders( + String partnerName, String transactionId, String authorization) { + + MultivaluedMap headers = new MultivaluedHashMap<>(); + headers.put(RestUtil.FROM_APP_ID, Collections.singletonList(partnerName)); + headers.put(RestUtil.TRANSACTION_ID, Collections.singletonList(transactionId)); + if (null != authorization) { + headers.put(RestUtil.AUTHORIZATION, Collections.singletonList(authorization)); } - return content.toString(); + return headers; } + } -- cgit 1.2.3-korg