summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/test/java/org/onap/appc/domainmodel/TestVnfc.java114
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));
}
}