2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
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=========================================================
21 package org.onap.policy.aai;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertNotEquals;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
29 import org.junit.AfterClass;
30 import org.junit.BeforeClass;
31 import org.junit.Test;
32 import org.onap.policy.aai.util.Serialization;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 public class PnfInstanceTest {
37 private static final Logger logger = LoggerFactory.getLogger(PnfInstanceTest.class);
40 public static void setUpBeforeClass() throws Exception {}
43 public static void tearDownAfterClass() throws Exception {}
47 PnfInstance pnfInstance = new PnfInstance();
48 pnfInstance.setPnfInstanceName("pnf-instance-name-test");
49 pnfInstance.setPnfName("pnf-name-test");
50 pnfInstance.setPnfType(PnfType.ENODEB);
51 pnfInstance.setPnfSerial("pnf-serial-test");
52 assertNotNull(pnfInstance);
53 assertEquals("pnf-instance-name-test", pnfInstance.getPnfInstanceName());
55 PnfInstance pnfInstanceNull = new PnfInstance(null);
56 assertNotNull(pnfInstanceNull);
58 PnfInstance pnfInstanceClone = new PnfInstance(pnfInstance);
59 assertNotNull(pnfInstanceClone);
61 assertEquals("pnf-name-test", pnfInstanceClone.getPnfName());
62 assertEquals(PnfType.ENODEB, pnfInstanceClone.getPnfType());
63 assertEquals("pnf-serial-test", pnfInstanceClone.getPnfSerial());
65 assertEquals("PNFInstance [PNFName=pnf-name-test, PNFInstanceName=pnf-instance-name-test, PNFType=eNodeB, "
66 + "PNFSerial=pnf-serial-test]", pnfInstanceClone.toString());
67 assertNotEquals(0, pnfInstanceClone.hashCode());
68 assertNotEquals(0, new Pnf().hashCode());
70 PnfInstance pnfInstanceOther0 = new PnfInstance();
71 pnfInstanceOther0.setPnfName("pnf-name-test");
73 PnfInstance pnfInstanceOther1 = new PnfInstance(pnfInstance);
74 pnfInstanceOther1.setPnfName("pnf-name-test-diff");
76 PnfInstance pnfInstanceOther2 = new PnfInstance(pnfInstance);
77 pnfInstanceOther2.setPnfInstanceName("pnf-instance-name-test-diff");
79 PnfInstance pnfInstanceOther3 = new PnfInstance(pnfInstance);
80 pnfInstanceOther3.setPnfName(null);
82 PnfInstance pnfInstanceOther4 = new PnfInstance(pnfInstance);
83 pnfInstanceOther4.setPnfSerial(null);
85 PnfInstance pnfInstanceOther5 = new PnfInstance(pnfInstance);
86 pnfInstanceOther5.setPnfSerial("pnf-serial-test-diff");
88 assertTrue(pnfInstance.equals(pnfInstance));
89 assertFalse(pnfInstance.equals(null));
90 assertFalse(pnfInstance.equals("hello"));
91 assertTrue(pnfInstance.equals(pnfInstanceClone));
92 assertFalse(pnfInstance.equals(new Pnf()));
93 assertFalse(new Pnf().equals(pnfInstance));
94 assertFalse(new Pnf().equals(pnfInstanceOther0));
95 assertFalse(pnfInstanceOther0.equals(pnfInstance));
96 assertFalse(pnfInstanceOther1.equals(pnfInstance));
97 assertFalse(pnfInstanceOther2.equals(pnfInstance));
98 assertFalse(pnfInstanceOther3.equals(pnfInstance));
99 assertFalse(pnfInstanceOther4.equals(pnfInstance));
100 assertFalse(pnfInstanceOther5.equals(pnfInstance));
102 logger.info(Serialization.gsonPretty.toJson(pnfInstance));