f05f50e67b8503b8f0816bddc1a0f1cebde25bd0
[policy/models.git] / models-interactions / model-impl / sdnr / src / test / java / org / onap / policy / sdnr / PciWrapperTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * sdnr
4  * ================================================================================
5  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nordix Foundation.
7  * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.sdnr;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertFalse;
27 import static org.junit.Assert.assertNotEquals;
28 import static org.junit.Assert.assertNotNull;
29 import static org.junit.Assert.assertTrue;
30
31 import org.junit.Test;
32
33 public class PciWrapperTest {
34
35     private static final String YELLOW_BRICK_ROAD = "YellowBrickRoad";
36     private static final String TORNADO = "Tornado";
37     private static final String THE_EMERALD_CITY = "The Emerald City";
38     private static final String MUNCHKIN = "Munchkin";
39     private static final String VERSION_19 = "19.3.9";
40
41     @Test
42     public void testPciWrapper() {
43         PciWrapper wrapper = new PciWrapper();
44         assertNotNull(wrapper);
45         assertNotEquals(0, wrapper.hashCode());
46
47         wrapper.setVersion(VERSION_19);
48         assertEquals(VERSION_19, wrapper.getVersion());
49
50         wrapper.setCambriaPartition(THE_EMERALD_CITY);
51         assertEquals(THE_EMERALD_CITY, wrapper.getCambriaPartition());
52
53         wrapper.setRpcName(TORNADO);
54         assertEquals(TORNADO, wrapper.getRpcName());
55
56         wrapper.setCorrelationId(YELLOW_BRICK_ROAD);
57         assertEquals(YELLOW_BRICK_ROAD, wrapper.getCorrelationId());
58
59         wrapper.setType(MUNCHKIN);
60         assertEquals(MUNCHKIN, wrapper.getType());
61
62         assertNotEquals(0, wrapper.hashCode());
63
64         assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46));
65
66         PciWrapper copiedPciWrapper = new PciWrapper();
67         copiedPciWrapper.setVersion(wrapper.getVersion());
68         copiedPciWrapper.setCambriaPartition(wrapper.getCambriaPartition());
69         copiedPciWrapper.setRpcName(wrapper.getRpcName());
70         copiedPciWrapper.setCorrelationId(wrapper.getCorrelationId());
71         copiedPciWrapper.setType(wrapper.getType());
72
73         assertTrue(wrapper.equals(wrapper));
74         assertTrue(wrapper.equals(copiedPciWrapper));
75         assertFalse(wrapper.equals(null));
76         assertFalse(wrapper.equals("Hello"));
77
78         wrapper.setVersion(null);
79         assertFalse(wrapper.equals(copiedPciWrapper));
80         copiedPciWrapper.setVersion(null);
81         assertTrue(wrapper.equals(copiedPciWrapper));
82         wrapper.setVersion(VERSION_19);
83         assertFalse(wrapper.equals(copiedPciWrapper));
84         copiedPciWrapper.setVersion(VERSION_19);
85         assertTrue(wrapper.equals(copiedPciWrapper));
86
87         wrapper.setCambriaPartition(null);
88         assertFalse(wrapper.equals(copiedPciWrapper));
89         copiedPciWrapper.setCambriaPartition(null);
90         assertTrue(wrapper.equals(copiedPciWrapper));
91         wrapper.setCambriaPartition(THE_EMERALD_CITY);
92         assertFalse(wrapper.equals(copiedPciWrapper));
93         copiedPciWrapper.setCambriaPartition(THE_EMERALD_CITY);
94         assertTrue(wrapper.equals(copiedPciWrapper));
95
96         wrapper.setRpcName(null);
97         assertFalse(wrapper.equals(copiedPciWrapper));
98         copiedPciWrapper.setRpcName(null);
99         assertTrue(wrapper.equals(copiedPciWrapper));
100         wrapper.setRpcName(TORNADO);
101         assertFalse(wrapper.equals(copiedPciWrapper));
102         copiedPciWrapper.setRpcName(TORNADO);
103         assertTrue(wrapper.equals(copiedPciWrapper));
104
105         wrapper.setCorrelationId(null);
106         assertFalse(wrapper.equals(copiedPciWrapper));
107         copiedPciWrapper.setCorrelationId(null);
108         assertTrue(wrapper.equals(copiedPciWrapper));
109         wrapper.setCorrelationId(YELLOW_BRICK_ROAD);
110         assertFalse(wrapper.equals(copiedPciWrapper));
111         copiedPciWrapper.setCorrelationId(YELLOW_BRICK_ROAD);
112         assertTrue(wrapper.equals(copiedPciWrapper));
113
114         wrapper.setType(null);
115         assertFalse(wrapper.equals(copiedPciWrapper));
116         copiedPciWrapper.setType(null);
117         assertTrue(wrapper.equals(copiedPciWrapper));
118         wrapper.setType(MUNCHKIN);
119         assertFalse(wrapper.equals(copiedPciWrapper));
120         copiedPciWrapper.setType(MUNCHKIN);
121         assertTrue(wrapper.equals(copiedPciWrapper));
122     }
123 }