2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 package org.onap.policy.sdnr;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotEquals;
27 import static org.junit.Assert.assertNotNull;
29 import org.junit.Test;
31 public class PciWrapperTest {
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";
40 public void testPciWrapper() {
41 PciWrapper wrapper = new PciWrapper();
42 assertNotNull(wrapper);
43 assertNotEquals(0, wrapper.hashCode());
45 wrapper.setVersion(VERSION_19);
46 assertEquals(VERSION_19, wrapper.getVersion());
48 wrapper.setCambriaPartition(THE_EMERALD_CITY);
49 assertEquals(THE_EMERALD_CITY, wrapper.getCambriaPartition());
51 wrapper.setRpcName(TORNADO);
52 assertEquals(TORNADO, wrapper.getRpcName());
54 wrapper.setCorrelationId(YELLOW_BRICK_ROAD);
55 assertEquals(YELLOW_BRICK_ROAD, wrapper.getCorrelationId());
57 wrapper.setType(MUNCHKIN);
58 assertEquals(MUNCHKIN, wrapper.getType());
60 assertNotEquals(0, wrapper.hashCode());
62 assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46));
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());
71 assertEquals(wrapper, (Object) wrapper);
72 assertEquals(wrapper, copiedPciWrapper);
73 assertNotEquals(wrapper, null);
74 assertNotEquals(wrapper, (Object) "Hello");
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);
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);
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);
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);
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);