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.appc;
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 ResponseStatusTest {
35 public void testResonseStatus() {
36 ResponseStatus status = new ResponseStatus();
37 assertNotNull(status);
38 assertNotEquals(0, status.hashCode());
41 assertEquals(1234, status.getCode());
43 status.setDescription("The wonderful land of Oz");
44 assertEquals("The wonderful land of Oz", status.getDescription());
46 status.setValue("There's no place like home");
47 assertEquals("There's no place like home", status.getValue());
48 assertNotEquals(0, status.hashCode());
50 assertEquals("ResponseStatus [Code=1234, Value=There's no pla", status.toString().substring(0, 47));
52 ResponseStatus copiedStatus = new ResponseStatus();
53 copiedStatus.setCode(status.getCode());
54 copiedStatus.setDescription(status.getDescription());
55 copiedStatus.setValue(status.getValue());
57 assertTrue(status.equals(status));
58 assertTrue(status.equals(copiedStatus));
59 assertFalse(status.equals(null));
60 assertFalse(status.equals("Hello"));
63 assertFalse(status.equals(copiedStatus));
64 copiedStatus.setCode(-1);
65 assertTrue(status.equals(copiedStatus));
67 assertFalse(status.equals(copiedStatus));
68 copiedStatus.setCode(1234);
69 assertTrue(status.equals(copiedStatus));
71 status.setDescription(null);
72 assertFalse(status.equals(copiedStatus));
73 copiedStatus.setDescription(null);
74 assertTrue(status.equals(copiedStatus));
75 status.setDescription("The wonderful land of Oz");
76 assertFalse(status.equals(copiedStatus));
77 copiedStatus.setDescription("The wonderful land of Oz");
78 assertTrue(status.equals(copiedStatus));
80 status.setValue(null);
81 assertFalse(status.equals(copiedStatus));
82 copiedStatus.setValue(null);
83 assertTrue(status.equals(copiedStatus));
84 status.setValue("There's no place like home");
85 assertFalse(status.equals(copiedStatus));
86 copiedStatus.setValue("There's no place like home");
87 assertTrue(status.equals(copiedStatus));