diff options
author | Sandeep J <sandeejh@in.ibm.com> | 2018-08-14 14:23:43 +0530 |
---|---|---|
committer | Patrick Brady <pb071s@att.com> | 2018-08-17 16:13:37 +0000 |
commit | 58296da28e654d53f0d48f67bcb61187a2b603d3 (patch) | |
tree | f01e148767a12f0f27d4ad8d7f88ea0d8caba053 /appc-dg | |
parent | 261bd4b9808506773cef3014eb791ca8a94b764d (diff) |
added test case to TestVnfc.java
to increase code coverage
Issue-ID: APPC-1086
Change-Id: I67c5f3aa03ee7b5fdd333bda71008605bcc71d6b
Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
Diffstat (limited to 'appc-dg')
-rw-r--r-- | appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/test/java/org/onap/appc/domainmodel/TestVnfc.java | 114 |
1 files changed, 83 insertions, 31 deletions
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 2259b92a6..21936ac47 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 @@ -4,6 +4,8 @@ * ================================================================================ * Copyright 2018 TechMahindra *================================================================================= +* Modifications Copyright 2018 IBM. +*================================================================================= * 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 @@ -21,9 +23,6 @@ package org.onap.appc.domainmodel; import static org.junit.Assert.*; - - - import java.util.LinkedList; import java.util.List; @@ -32,50 +31,52 @@ import org.junit.Test; public class TestVnfc { private Vnfc vnfc; - + private Vnfc vnfc1; + private Vnfc vnfc2; @Before public void SetUp() { - vnfc=new Vnfc(); + vnfc = new Vnfc(); + vnfc1 = new Vnfc(); + vnfc2 = new Vnfc(); } @Test public void testGetVnfcType() { vnfc.setVnfcType("1"); assertNotNull(vnfc.getVnfcType()); - assertEquals(vnfc.getVnfcType(),"1"); + assertEquals(vnfc.getVnfcType(), "1"); } @Test public void testGetResilienceType() { vnfc.setResilienceType("resilienceType"); assertNotNull(vnfc.getResilienceType()); - assertEquals(vnfc.getResilienceType(),"resilienceType"); + assertEquals(vnfc.getResilienceType(), "resilienceType"); } @Test public void testGetVnfcName() { vnfc.setVnfcName("vnfcName"); assertNotNull(vnfc.getVnfcName()); - assertEquals(vnfc.getVnfcName(),"vnfcName"); + assertEquals(vnfc.getVnfcName(), "vnfcName"); } @Test public void testGetvserverList() { - List<Vserver> vserverList=new LinkedList<>(); + List<Vserver> vserverList = new LinkedList<>(); vnfc.setVserverList(vserverList); assertNotNull(vnfc.getVserverList()); - assertEquals(vnfc.getVserverList(),vserverList); + assertEquals(vnfc.getVserverList(), vserverList); } @Test public void testIsMandatory() { vnfc.setMandatory(false); assertNotNull(vnfc.isMandatory()); - assertEquals(vnfc.isMandatory(),false); + assertEquals(vnfc.isMandatory(), false); } - @Test public void testToStringWithASingleVserver() { vnfc.setVnfcName("A"); @@ -89,20 +90,20 @@ public class TestVnfc { 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"); + + 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<Vserver> vserverList=new LinkedList<>(); + List<Vserver> vserverList = new LinkedList<>(); Vserver vserver = new Vserver(); vserver.setId("V1"); vserver.setName("V1-Name"); @@ -114,9 +115,9 @@ public class TestVnfc { vnfc.addVservers(vserverList); System.out.println("ok vnfc hashcode = " + vnfc.hashCode()); - assertTrue(vnfc.hashCode() == 81141437); + assertTrue(vnfc.hashCode() == 81141437); } - + @Test public void testCompareVnfc() { Vnfc vnfc1 = new Vnfc(); @@ -130,17 +131,16 @@ public class TestVnfc { vnfc.setResilienceType("RS1"); vnfc.setMandatory(true); - - - assertFalse(vnfc.equals(vnfc1)); + + assertFalse(vnfc.equals(vnfc1)); } - + @Test public void testToStringWithVserverList() { vnfc.setVnfcName("A"); vnfc.setVnfcType("B"); vnfc.setMandatory(false); - List<Vserver> vserverList=new LinkedList<>(); + List<Vserver> vserverList = new LinkedList<>(); Vserver vserver = new Vserver(); vserver.setId("V1"); vserver.setName("V1-Name"); @@ -150,10 +150,62 @@ public class TestVnfc { 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"); + + 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"); + } + + @Test + public void testEquals() { + vnfc1.setMandatory(true); + vnfc1.setResilienceType("RS1"); + vnfc1.setVnfcName("A"); + vnfc1.setVnfcType("testType"); + List<Vserver> 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); + vnfc1.setVserverList(vserverList); + + vnfc2.setMandatory(true); + vnfc2.setResilienceType("RS1"); + vnfc2.setVnfcName("A"); + vnfc2.setVnfcType("testType"); + vnfc2.setVserverList(vserverList); + + assertTrue(vnfc1.equals(vnfc2)); + } + + @Test + public void testEqualsforDifferentObjects() { + vnfc1.setMandatory(true); + vnfc1.setResilienceType("RS1"); + vnfc1.setVnfcName("A"); + vnfc1.setVnfcType("testType"); + List<Vserver> 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); + vnfc1.setVserverList(vserverList); + + vnfc2.setMandatory(true); + vnfc2.setResilienceType("RS2"); + vnfc2.setVnfcName("C"); + vnfc2.setVnfcType("testType1"); + vnfc2.setVserverList(vserverList); + + assertFalse(vnfc1.equals(vnfc2)); } } |