d25be8340aa20fcd97b5e014d015782e94860086
[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-2020 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.assertNotEquals;
27 import static org.junit.Assert.assertNotNull;
28
29 import org.junit.Test;
30
31 public class PciWrapperTest {
32
33     private static final String YELLOW_BRICK_ROAD = "YellowBrickRoad";
34     private static final String TORNADO = "Tornado";
35     private static final String THE_EMERALD_CITY = "The Emerald City";
36     private static final String MUNCHKIN = "Munchkin";
37     private static final String VERSION_19 = "19.3.9";
38
39     @Test
40     public void testPciWrapper() {
41         PciWrapper wrapper = new PciWrapper();
42         assertNotNull(wrapper);
43         assertNotEquals(0, wrapper.hashCode());
44
45         wrapper.setVersion(VERSION_19);
46         assertEquals(VERSION_19, wrapper.getVersion());
47
48         wrapper.setCambriaPartition(THE_EMERALD_CITY);
49         assertEquals(THE_EMERALD_CITY, wrapper.getCambriaPartition());
50
51         wrapper.setRpcName(TORNADO);
52         assertEquals(TORNADO, wrapper.getRpcName());
53
54         wrapper.setCorrelationId(YELLOW_BRICK_ROAD);
55         assertEquals(YELLOW_BRICK_ROAD, wrapper.getCorrelationId());
56
57         wrapper.setType(MUNCHKIN);
58         assertEquals(MUNCHKIN, wrapper.getType());
59
60         assertNotEquals(0, wrapper.hashCode());
61
62         assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46));
63
64         PciWrapper copiedPciWrapper = new PciWrapper();
65         copiedPciWrapper.setVersion(wrapper.getVersion());
66         copiedPciWrapper.setCambriaPartition(wrapper.getCambriaPartition());
67         copiedPciWrapper.setRpcName(wrapper.getRpcName());
68         copiedPciWrapper.setCorrelationId(wrapper.getCorrelationId());
69         copiedPciWrapper.setType(wrapper.getType());
70
71         assertEquals(wrapper, wrapper);
72         assertEquals(wrapper, copiedPciWrapper);
73         assertNotEquals(wrapper, null);
74         assertNotEquals(wrapper, "Hello");
75
76         wrapper.setVersion(null);
77         assertNotEquals(wrapper, copiedPciWrapper);
78         copiedPciWrapper.setVersion(null);
79         assertEquals(wrapper, copiedPciWrapper);
80         wrapper.setVersion(VERSION_19);
81         assertNotEquals(wrapper, copiedPciWrapper);
82         copiedPciWrapper.setVersion(VERSION_19);
83         assertEquals(wrapper, copiedPciWrapper);
84
85         wrapper.setCambriaPartition(null);
86         assertNotEquals(wrapper, copiedPciWrapper);
87         copiedPciWrapper.setCambriaPartition(null);
88         assertEquals(wrapper, copiedPciWrapper);
89         wrapper.setCambriaPartition(THE_EMERALD_CITY);
90         assertNotEquals(wrapper, copiedPciWrapper);
91         copiedPciWrapper.setCambriaPartition(THE_EMERALD_CITY);
92         assertEquals(wrapper, copiedPciWrapper);
93
94         wrapper.setRpcName(null);
95         assertNotEquals(wrapper, copiedPciWrapper);
96         copiedPciWrapper.setRpcName(null);
97         assertEquals(wrapper, copiedPciWrapper);
98         wrapper.setRpcName(TORNADO);
99         assertNotEquals(wrapper, copiedPciWrapper);
100         copiedPciWrapper.setRpcName(TORNADO);
101         assertEquals(wrapper, copiedPciWrapper);
102
103         wrapper.setCorrelationId(null);
104         assertNotEquals(wrapper, copiedPciWrapper);
105         copiedPciWrapper.setCorrelationId(null);
106         assertEquals(wrapper, copiedPciWrapper);
107         wrapper.setCorrelationId(YELLOW_BRICK_ROAD);
108         assertNotEquals(wrapper, copiedPciWrapper);
109         copiedPciWrapper.setCorrelationId(YELLOW_BRICK_ROAD);
110         assertEquals(wrapper, copiedPciWrapper);
111
112         wrapper.setType(null);
113         assertNotEquals(wrapper, copiedPciWrapper);
114         copiedPciWrapper.setType(null);
115         assertEquals(wrapper, copiedPciWrapper);
116         wrapper.setType(MUNCHKIN);
117         assertNotEquals(wrapper, copiedPciWrapper);
118         copiedPciWrapper.setType(MUNCHKIN);
119         assertEquals(wrapper, copiedPciWrapper);
120     }
121 }