2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.aai;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertNotEquals;
27 import static org.junit.Assert.assertNotNull;
28 import static org.junit.Assert.assertTrue;
30 import org.junit.Test;
31 import org.onap.policy.aai.util.Serialization;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
35 public class PnfInstanceTest {
36 private static final String PNF_NAME_TEST = "pnf-name-test";
37 private static final Logger logger = LoggerFactory.getLogger(PnfInstanceTest.class);
41 PnfInstance pnfInstance = new PnfInstance();
42 pnfInstance.setPnfInstanceName("pnf-instance-name-test");
43 pnfInstance.setPnfName(PNF_NAME_TEST);
44 pnfInstance.setPnfType(PnfType.ENODEB);
45 pnfInstance.setPnfSerial("pnf-serial-test");
46 assertNotNull(pnfInstance);
47 assertEquals("pnf-instance-name-test", pnfInstance.getPnfInstanceName());
49 PnfInstance pnfInstanceNull = new PnfInstance(null);
50 assertNotNull(pnfInstanceNull);
52 PnfInstance pnfInstanceClone = new PnfInstance(pnfInstance);
53 assertNotNull(pnfInstanceClone);
55 assertEquals(PNF_NAME_TEST, pnfInstanceClone.getPnfName());
56 assertEquals(PnfType.ENODEB, pnfInstanceClone.getPnfType());
57 assertEquals("pnf-serial-test", pnfInstanceClone.getPnfSerial());
59 assertNotNull(pnfInstanceClone.toString());
60 assertNotEquals(0, pnfInstanceClone.hashCode());
61 assertNotEquals(0, new Pnf().hashCode());
63 PnfInstance pnfInstanceOther0 = new PnfInstance();
64 pnfInstanceOther0.setPnfName(PNF_NAME_TEST);
66 PnfInstance pnfInstanceOther1 = new PnfInstance(pnfInstance);
67 pnfInstanceOther1.setPnfName("pnf-name-test-diff");
69 PnfInstance pnfInstanceOther2 = new PnfInstance(pnfInstance);
70 pnfInstanceOther2.setPnfInstanceName("pnf-instance-name-test-diff");
72 PnfInstance pnfInstanceOther3 = new PnfInstance(pnfInstance);
73 pnfInstanceOther3.setPnfName(null);
75 PnfInstance pnfInstanceOther4 = new PnfInstance(pnfInstance);
76 pnfInstanceOther4.setPnfSerial(null);
78 PnfInstance pnfInstanceOther5 = new PnfInstance(pnfInstance);
79 pnfInstanceOther5.setPnfSerial("pnf-serial-test-diff");
81 assertEquals(pnfInstance, pnfInstance);
82 assertNotEquals(null, pnfInstance);
83 assertNotEquals("hello", pnfInstance);
84 assertEquals(pnfInstance, pnfInstanceClone);
85 assertNotEquals(pnfInstance, new Pnf());
86 assertNotEquals(new Pnf(), pnfInstance);
87 assertNotEquals(new Pnf(), pnfInstanceOther0);
88 assertNotEquals(pnfInstanceOther0, pnfInstance);
89 assertNotEquals(pnfInstanceOther1, pnfInstance);
90 assertNotEquals(pnfInstanceOther2, pnfInstance);
91 assertNotEquals(pnfInstanceOther3, pnfInstance);
92 assertNotEquals(pnfInstanceOther4, pnfInstance);
93 assertNotEquals(pnfInstanceOther5, pnfInstance);
95 logger.info(Serialization.gsonPretty.toJson(pnfInstance));