2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright 2018 TechMahindra
6 *=================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.appc.domainmodel;
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertNotEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertTrue;
27 import java.util.LinkedList;
28 import java.util.List;
30 import org.junit.Before;
31 import org.junit.Test;
33 public class TestVnf {
42 public void testGetVnfId() {
44 assertNotNull(vnf.getVnfId());
45 assertEquals(vnf.getVnfId(),"Z");
49 public void testGetvnfType() {
51 assertNotNull(vnf.getVnfType());
52 assertEquals(vnf.getVnfType(),"A");
56 public void testGetVnfVersion() {
57 vnf.setVnfVersion("1.0");
58 assertNotNull(vnf.getVnfVersion());
59 assertEquals(vnf.getVnfVersion(),"1.0");
63 public void testList() {
64 List<Vserver> vservers = new LinkedList<>();
65 vnf.setVservers(vservers);
66 assertNotNull(vnf.getVservers());
67 assertEquals(vnf.getVservers(),vservers);
72 public void testToString_ReturnNonEmptyString() {
73 assertNotEquals(vnf.toString(), "");
74 assertNotEquals(vnf.toString(), null);
78 public void testToString_ContainsString() {
79 assertTrue(vnf.toString().contains("vnfId"));
83 public void testetVnfcs() {
84 Vnfc vnfc = new Vnfc();
85 vnfc.setVnfcName("A");
86 vnfc.setVnfcType("B");
87 vnfc.setResilienceType("RS1");
88 vnfc.setMandatory(true);
89 List<Vserver> vserverList=new LinkedList<>();
90 Vserver vserver = new Vserver();
92 vserver.setName("V1-Name");
93 vserver.setRelatedLink("V1-relatedlink");
94 vserver.setTenantId("V1-T1");
95 vserver.setUrl("http://v1.net");
96 vserver.setVnfc(vnfc);
97 vserverList.add(vserver);
98 vnfc.addVservers(vserverList);
99 vnf.setVservers(vserverList);
100 assertTrue(vnf.getVnfcs()!=null);