2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.appclcm;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertNotEquals;
27 import static org.junit.Assert.assertNotNull;
28 import static org.junit.Assert.assertTrue;
30 import org.junit.Test;
32 public class LcmResponseStatusTest {
34 private static final String THE_WONDERFUL_LAND_OF_OZ = "The wonderful land of Oz";
37 public void testResonseStatus() {
38 LcmResponseStatus status = new LcmResponseStatus();
39 assertNotNull(status);
40 assertNotEquals(0, status.hashCode());
43 assertEquals(1234, status.getCode());
45 status.setMessage(THE_WONDERFUL_LAND_OF_OZ);
46 assertEquals(THE_WONDERFUL_LAND_OF_OZ, status.getMessage());
48 assertEquals("ResponseStatus [code=1234, message=The wonderfu", status.toString().substring(0, 47));
50 LcmResponseStatus copiedStatus = new LcmResponseStatus();
51 copiedStatus.setCode(status.getCode());
52 copiedStatus.setMessage(status.getMessage());
54 assertTrue(status.equals(status));
55 assertTrue(status.equals(copiedStatus));
56 assertFalse(status.equals(null));
57 assertFalse(status.equals("Hello"));
60 assertFalse(status.equals(copiedStatus));
61 copiedStatus.setCode(-1);
62 assertTrue(status.equals(copiedStatus));
64 assertFalse(status.equals(copiedStatus));
65 copiedStatus.setCode(1234);
66 assertTrue(status.equals(copiedStatus));
68 status.setMessage(null);
69 assertFalse(status.equals(copiedStatus));
70 copiedStatus.setMessage(null);
71 assertTrue(status.equals(copiedStatus));
72 status.setMessage(THE_WONDERFUL_LAND_OF_OZ);
73 assertFalse(status.equals(copiedStatus));
74 copiedStatus.setMessage(THE_WONDERFUL_LAND_OF_OZ);
75 assertTrue(status.equals(copiedStatus));