Fix sonar issue affecting in drools-applications
[policy/models.git] / models-interactions / model-impl / aai / src / test / java / org / onap / policy / aai / PnfInstanceTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * aai
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20 */
21
22 package org.onap.policy.aai;
23
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;
29
30 import org.junit.Test;
31 import org.onap.policy.aai.util.Serialization;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34
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);
38
39     @Test
40     public void test() {
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());
48
49         PnfInstance pnfInstanceNull = new PnfInstance(null);
50         assertNotNull(pnfInstanceNull);
51
52         PnfInstance pnfInstanceClone = new PnfInstance(pnfInstance);
53         assertNotNull(pnfInstanceClone);
54
55         assertEquals(PNF_NAME_TEST, pnfInstanceClone.getPnfName());
56         assertEquals(PnfType.ENODEB, pnfInstanceClone.getPnfType());
57         assertEquals("pnf-serial-test", pnfInstanceClone.getPnfSerial());
58
59         assertNotNull(pnfInstanceClone.toString());
60         assertNotEquals(0, pnfInstanceClone.hashCode());
61         assertNotEquals(0, new Pnf().hashCode());
62
63         PnfInstance pnfInstanceOther0 = new PnfInstance();
64         pnfInstanceOther0.setPnfName(PNF_NAME_TEST);
65
66         PnfInstance pnfInstanceOther1 = new PnfInstance(pnfInstance);
67         pnfInstanceOther1.setPnfName("pnf-name-test-diff");
68
69         PnfInstance pnfInstanceOther2 = new PnfInstance(pnfInstance);
70         pnfInstanceOther2.setPnfInstanceName("pnf-instance-name-test-diff");
71
72         PnfInstance pnfInstanceOther3 = new PnfInstance(pnfInstance);
73         pnfInstanceOther3.setPnfName(null);
74
75         PnfInstance pnfInstanceOther4 = new PnfInstance(pnfInstance);
76         pnfInstanceOther4.setPnfSerial(null);
77
78         PnfInstance pnfInstanceOther5 = new PnfInstance(pnfInstance);
79         pnfInstanceOther5.setPnfSerial("pnf-serial-test-diff");
80
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);
94
95         logger.info(Serialization.gsonPretty.toJson(pnfInstance));
96     }
97
98 }