summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShailendra Borale <sb8915@att.com>2018-03-23 13:53:50 -0400
committerRanda Maher <rx196w@att.com>2018-03-23 19:32:16 +0000
commitaa98a7dc8eb827599f8d8bccd44a8bb268acd4dd (patch)
treec49afd3275bdb8011ec991c5fff669f16e06c24b
parent0b760e28aac46e6a1122706b68e77e6cbb151f60 (diff)
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 <sb8915@att.com>
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/test/java/org/onap/appc/domainmodel/TestVnf.java20
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/test/java/org/onap/appc/domainmodel/TestVnfc.java85
2 files changed, 105 insertions, 0 deletions
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<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);
+ 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<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);
+ 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<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);
+ 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");
+ }
}