2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.appclcm;
23 import static org.junit.Assert.*;
25 import org.junit.Test;
27 public class TestLCMWrapper {
30 public void testLCMWrapper() {
31 LCMWrapper wrapper = new LCMWrapper();
32 assertNotNull(wrapper);
33 assertNotEquals(0, wrapper.hashCode());
35 wrapper.setVersion("19.3.9");
36 assertEquals("19.3.9", wrapper.getVersion());
38 wrapper.setCambriaPartition("The Emerald City");
39 assertEquals("The Emerald City", wrapper.getCambriaPartition());
41 wrapper.setRpcName("Tornado");
42 assertEquals("Tornado", wrapper.getRpcName());
44 wrapper.setCorrelationId("YellowBrickRoad");
45 assertEquals("YellowBrickRoad", wrapper.getCorrelationId());
47 wrapper.setType("Munchkin");
48 assertEquals("Munchkin", wrapper.getType());
50 assertNotEquals(0, wrapper.hashCode());
52 assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46));
54 LCMWrapper copiedLCMWrapper = new LCMWrapper();
55 copiedLCMWrapper.setVersion(wrapper.getVersion());
56 copiedLCMWrapper.setCambriaPartition(wrapper.getCambriaPartition());
57 copiedLCMWrapper.setRpcName(wrapper.getRpcName());
58 copiedLCMWrapper.setCorrelationId(wrapper.getCorrelationId());
59 copiedLCMWrapper.setType(wrapper.getType());
61 assertTrue(wrapper.equals(wrapper));
62 assertTrue(wrapper.equals(copiedLCMWrapper));
63 assertFalse(wrapper.equals(null));
64 assertFalse(wrapper.equals("Hello"));
66 wrapper.setVersion(null);
67 assertFalse(wrapper.equals(copiedLCMWrapper));
68 copiedLCMWrapper.setVersion(null);
69 assertTrue(wrapper.equals(copiedLCMWrapper));
70 wrapper.setVersion("19.3.9");
71 assertFalse(wrapper.equals(copiedLCMWrapper));
72 copiedLCMWrapper.setVersion("19.3.9");
73 assertTrue(wrapper.equals(copiedLCMWrapper));
75 wrapper.setCambriaPartition(null);
76 assertFalse(wrapper.equals(copiedLCMWrapper));
77 copiedLCMWrapper.setCambriaPartition(null);
78 assertTrue(wrapper.equals(copiedLCMWrapper));
79 wrapper.setCambriaPartition("The Emerald City");
80 assertFalse(wrapper.equals(copiedLCMWrapper));
81 copiedLCMWrapper.setCambriaPartition("The Emerald City");
82 assertTrue(wrapper.equals(copiedLCMWrapper));
84 wrapper.setRpcName(null);
85 assertFalse(wrapper.equals(copiedLCMWrapper));
86 copiedLCMWrapper.setRpcName(null);
87 assertTrue(wrapper.equals(copiedLCMWrapper));
88 wrapper.setRpcName("Tornado");
89 assertFalse(wrapper.equals(copiedLCMWrapper));
90 copiedLCMWrapper.setRpcName("Tornado");
91 assertTrue(wrapper.equals(copiedLCMWrapper));
93 wrapper.setCorrelationId(null);
94 assertFalse(wrapper.equals(copiedLCMWrapper));
95 copiedLCMWrapper.setCorrelationId(null);
96 assertTrue(wrapper.equals(copiedLCMWrapper));
97 wrapper.setCorrelationId("YellowBrickRoad");
98 assertFalse(wrapper.equals(copiedLCMWrapper));
99 copiedLCMWrapper.setCorrelationId("YellowBrickRoad");
100 assertTrue(wrapper.equals(copiedLCMWrapper));
102 wrapper.setType(null);
103 assertFalse(wrapper.equals(copiedLCMWrapper));
104 copiedLCMWrapper.setType(null);
105 assertTrue(wrapper.equals(copiedLCMWrapper));
106 wrapper.setType("Munchkin");
107 assertFalse(wrapper.equals(copiedLCMWrapper));
108 copiedLCMWrapper.setType("Munchkin");
109 assertTrue(wrapper.equals(copiedLCMWrapper));