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 PciStatusTest {
33 private static final String THE_WONDERFUL_LAND_OF_OZ = "The wonderful land of Oz";
36 public void testResponseStatus() {
37 Status status = new Status();
38 assertNotNull(status);
39 assertNotEquals(0, status.hashCode());
42 assertEquals(1234, status.getCode());
44 status.setValue(THE_WONDERFUL_LAND_OF_OZ);
45 assertEquals(THE_WONDERFUL_LAND_OF_OZ, status.getValue());
47 assertEquals("Status [code = 1234, value = The wonderfu", status.toString().substring(0, 41));
49 Status copiedStatus = new Status();
50 copiedStatus.setCode(status.getCode());
51 copiedStatus.setValue(status.getValue());
54 * Disabling sonar to test equals().
56 assertEquals(status, status); // NOSONAR
57 assertEquals(status, copiedStatus);
58 assertNotEquals(status, null);
59 assertNotEquals(status, "Hello"); // NOSONAR
62 assertNotEquals(status, copiedStatus);
63 copiedStatus.setCode(-1);
64 assertEquals(status, copiedStatus);
66 assertNotEquals(status, copiedStatus);
67 copiedStatus.setCode(1234);
68 assertEquals(status, copiedStatus);
70 status.setValue(null);
71 assertNotEquals(status, copiedStatus);
72 copiedStatus.setValue(null);
73 assertEquals(status, copiedStatus);
74 status.setValue(THE_WONDERFUL_LAND_OF_OZ);
75 assertNotEquals(status, copiedStatus);
76 copiedStatus.setValue(THE_WONDERFUL_LAND_OF_OZ);
77 assertEquals(status, copiedStatus);