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 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.assertFalse;
27 import static org.junit.Assert.assertNotEquals;
28 import static org.junit.Assert.assertNotNull;
29 import static org.junit.Assert.assertTrue;
31 import org.junit.Test;
33 public class PciWrapperTest {
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";
42 public void testPciWrapper() {
43 PciWrapper wrapper = new PciWrapper();
44 assertNotNull(wrapper);
45 assertNotEquals(0, wrapper.hashCode());
47 wrapper.setVersion(VERSION_19);
48 assertEquals(VERSION_19, wrapper.getVersion());
50 wrapper.setCambriaPartition(THE_EMERALD_CITY);
51 assertEquals(THE_EMERALD_CITY, wrapper.getCambriaPartition());
53 wrapper.setRpcName(TORNADO);
54 assertEquals(TORNADO, wrapper.getRpcName());
56 wrapper.setCorrelationId(YELLOW_BRICK_ROAD);
57 assertEquals(YELLOW_BRICK_ROAD, wrapper.getCorrelationId());
59 wrapper.setType(MUNCHKIN);
60 assertEquals(MUNCHKIN, wrapper.getType());
62 assertNotEquals(0, wrapper.hashCode());
64 assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46));
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());
73 assertTrue(wrapper.equals(wrapper));
74 assertTrue(wrapper.equals(copiedPciWrapper));
75 assertFalse(wrapper.equals(null));
76 assertFalse(wrapper.equals("Hello"));
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));
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));
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));
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));
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));