From aa98a7dc8eb827599f8d8bccd44a8bb268acd4dd Mon Sep 17 00:00:00 2001 From: Shailendra Borale Date: Fri, 23 Mar 2018 13:53:50 -0400 Subject: Add junit coverage to Appc-Domain-model Introduce junit-tests for Vnf, Vnfc classses Replaced tabs with spaces. Change-Id: I45baf5aa20391b375fae667ff7fdeed8cfd845b8 Issue-ID: APPC-783 Signed-off-by: Shailendra Borale --- .../java/org/onap/appc/domainmodel/TestVnf.java | 20 +++++ .../java/org/onap/appc/domainmodel/TestVnfc.java | 85 ++++++++++++++++++++++ 2 files changed, 105 insertions(+) (limited to 'appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/test/java') diff --git a/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/test/java/org/onap/appc/domainmodel/TestVnf.java b/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/test/java/org/onap/appc/domainmodel/TestVnf.java index 08b70ba52..bace7cd83 100644 --- a/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/test/java/org/onap/appc/domainmodel/TestVnf.java +++ b/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/test/java/org/onap/appc/domainmodel/TestVnf.java @@ -79,4 +79,24 @@ public class TestVnf { assertTrue(vnf.toString().contains("vnfId")); } + @Test + public void testetVnfcs() { + Vnfc vnfc = new Vnfc(); + vnfc.setVnfcName("A"); + vnfc.setVnfcType("B"); + vnfc.setResilienceType("RS1"); + vnfc.setMandatory(true); + List vserverList=new LinkedList<>(); + Vserver vserver = new Vserver(); + vserver.setId("V1"); + vserver.setName("V1-Name"); + vserver.setRelatedLink("V1-relatedlink"); + vserver.setTenantId("V1-T1"); + vserver.setUrl("http://v1.net"); + vserver.setVnfc(vnfc); + vserverList.add(vserver); + vnfc.addVservers(vserverList); + vnf.setVservers(vserverList); + assertTrue(vnf.getVnfcs()!=null); + } } diff --git a/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/test/java/org/onap/appc/domainmodel/TestVnfc.java b/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/test/java/org/onap/appc/domainmodel/TestVnfc.java index dd67a5fdd..2259b92a6 100644 --- a/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/test/java/org/onap/appc/domainmodel/TestVnfc.java +++ b/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/test/java/org/onap/appc/domainmodel/TestVnfc.java @@ -21,6 +21,9 @@ package org.onap.appc.domainmodel; import static org.junit.Assert.*; + + + import java.util.LinkedList; import java.util.List; @@ -30,6 +33,7 @@ import org.junit.Test; public class TestVnfc { private Vnfc vnfc; + @Before public void SetUp() { vnfc=new Vnfc(); @@ -71,4 +75,85 @@ public class TestVnfc { assertEquals(vnfc.isMandatory(),false); } + + @Test + public void testToStringWithASingleVserver() { + vnfc.setVnfcName("A"); + vnfc.setVnfcType("B"); + vnfc.setMandatory(false); + Vserver vserver = new Vserver(); + vserver.setId("V1"); + vserver.setName("V1-Name"); + vserver.setRelatedLink("V1-relatedlink"); + vserver.setTenantId("V1-T1"); + vserver.setUrl("http://v1.net"); + vserver.setVnfc(vnfc); + vnfc.addVserver(vserver); + + + System.out.println("ok vnfc = " + vnfc.toString()); + + assertEquals(vnfc.toString(),"Vnfc : vnfcType = B, vnfcName = A, resilienceType = null, mandatory = falseVserver : url = http://v1.net, tenantId = V1-T1, id = V1 ,relatedLink = V1-relatedlink , name = V1-Name, \n"); + } + + @Test + public void testHashCode() { + vnfc.setVnfcName("A"); + vnfc.setVnfcType("B"); + vnfc.setResilienceType("RS1"); + vnfc.setMandatory(true); + List vserverList=new LinkedList<>(); + Vserver vserver = new Vserver(); + vserver.setId("V1"); + vserver.setName("V1-Name"); + vserver.setRelatedLink("V1-relatedlink"); + vserver.setTenantId("V1-T1"); + vserver.setUrl("http://v1.net"); + vserver.setVnfc(vnfc); + vserverList.add(vserver); + vnfc.addVservers(vserverList); + System.out.println("ok vnfc hashcode = " + vnfc.hashCode()); + + assertTrue(vnfc.hashCode() == 81141437); + } + + @Test + public void testCompareVnfc() { + Vnfc vnfc1 = new Vnfc(); + vnfc1.setVnfcName("A"); + vnfc1.setVnfcType("B"); + vnfc1.setMandatory(false); + vnfc1.setResilienceType("RS1"); + + vnfc.setVnfcName("A"); + vnfc.setVnfcType("B"); + vnfc.setResilienceType("RS1"); + + vnfc.setMandatory(true); + + + assertFalse(vnfc.equals(vnfc1)); + } + + @Test + public void testToStringWithVserverList() { + vnfc.setVnfcName("A"); + vnfc.setVnfcType("B"); + vnfc.setMandatory(false); + List vserverList=new LinkedList<>(); + Vserver vserver = new Vserver(); + vserver.setId("V1"); + vserver.setName("V1-Name"); + vserver.setRelatedLink("V1-relatedlink"); + vserver.setTenantId("V1-T1"); + vserver.setUrl("http://v1.net"); + vserver.setVnfc(vnfc); + vserverList.add(vserver); + vnfc.setVserverList(vserverList); + + + System.out.println("vnfc = " + vnfc.toString()); + + assertEquals(vnfc.toString(),"Vnfc : vnfcType = B, vnfcName = A, resilienceType = null, mandatory = falseVserver : url = http://v1.net, tenantId = V1-T1, id = V1 ,relatedLink = V1-relatedlink , name = V1-Name, \n"); + } } -- cgit 1.2.3-korg