c1a78e10a7741186ea5ff425c9e443571c3f0676
[policy/drools-applications.git] / controlloop / common / model-impl / appclcm / src / test / java / org / onap / policy / appclcm / LcmResponseStatusTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * appc
4  * ================================================================================
5  * Copyright (C) 2017-2018 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.policy.appclcm;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertNotEquals;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
28
29 import org.junit.Test;
30
31 public class LcmResponseStatusTest {
32
33     @Test
34     public void testResonseStatus() {
35         LcmResponseStatus status = new LcmResponseStatus();
36         assertNotNull(status);
37         assertNotEquals(0, status.hashCode());
38
39         status.setCode(1234);
40         assertEquals(1234, status.getCode());
41
42         status.setMessage("The wonderful land of Oz");
43         assertEquals("The wonderful land of Oz", status.getMessage());
44
45         assertEquals("ResponseStatus [code=1234, message=The wonderfu", status.toString().substring(0, 47));
46
47         LcmResponseStatus copiedStatus = new LcmResponseStatus();
48         copiedStatus.setCode(status.getCode());
49         copiedStatus.setMessage(status.getMessage());
50
51         assertTrue(status.equals(status));
52         assertTrue(status.equals(copiedStatus));
53         assertFalse(status.equals(null));
54         assertFalse(status.equals("Hello"));
55
56         status.setCode(-1);
57         assertFalse(status.equals(copiedStatus));
58         copiedStatus.setCode(-1);
59         assertTrue(status.equals(copiedStatus));
60         status.setCode(1234);
61         assertFalse(status.equals(copiedStatus));
62         copiedStatus.setCode(1234);
63         assertTrue(status.equals(copiedStatus));
64
65         status.setMessage(null);
66         assertFalse(status.equals(copiedStatus));
67         copiedStatus.setMessage(null);
68         assertTrue(status.equals(copiedStatus));
69         status.setMessage("The wonderful land of Oz");
70         assertFalse(status.equals(copiedStatus));
71         copiedStatus.setMessage("The wonderful land of Oz");
72         assertTrue(status.equals(copiedStatus));
73     }
74 }