move actors code in drools-applications to policy/models
[policy/models.git] / models-interactions / model-impl / appc / src / test / java / org / onap / policy / appc / ResponseStatusTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * appc
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21
22 package org.onap.policy.appc;
23
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;
29
30 import org.junit.Test;
31
32 public class ResponseStatusTest {
33
34     @Test
35     public void testResonseStatus() {
36         ResponseStatus status = new ResponseStatus();
37         assertNotNull(status);
38         assertNotEquals(0, status.hashCode());
39
40         status.setCode(1234);
41         assertEquals(1234, status.getCode());
42
43         status.setDescription("The wonderful land of Oz");
44         assertEquals("The wonderful land of Oz", status.getDescription());
45
46         status.setValue("There's no place like home");
47         assertEquals("There's no place like home", status.getValue());
48         assertNotEquals(0, status.hashCode());
49
50         assertEquals("ResponseStatus [Code=1234, Value=There's no pla", status.toString().substring(0, 47));
51
52         ResponseStatus copiedStatus = new ResponseStatus();
53         copiedStatus.setCode(status.getCode());
54         copiedStatus.setDescription(status.getDescription());
55         copiedStatus.setValue(status.getValue());
56
57         assertTrue(status.equals(status));
58         assertTrue(status.equals(copiedStatus));
59         assertFalse(status.equals(null));
60         assertFalse(status.equals("Hello"));
61
62         status.setCode(-1);
63         assertFalse(status.equals(copiedStatus));
64         copiedStatus.setCode(-1);
65         assertTrue(status.equals(copiedStatus));
66         status.setCode(1234);
67         assertFalse(status.equals(copiedStatus));
68         copiedStatus.setCode(1234);
69         assertTrue(status.equals(copiedStatus));
70
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));
79
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));
88     }
89 }