a4d1bc6d1225c99be259a674beec5b7085f37171
[policy/models.git] /
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.appclcm;
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 LcmResponseStatusTest {
33
34     private static final String THE_WONDERFUL_LAND_OF_OZ = "The wonderful land of Oz";
35
36     @Test
37     public void testResonseStatus() {
38         LcmResponseStatus status = new LcmResponseStatus();
39         assertNotNull(status);
40         assertNotEquals(0, status.hashCode());
41
42         status.setCode(1234);
43         assertEquals(1234, status.getCode());
44
45         status.setMessage(THE_WONDERFUL_LAND_OF_OZ);
46         assertEquals(THE_WONDERFUL_LAND_OF_OZ, status.getMessage());
47
48         assertEquals("ResponseStatus [code=1234, message=The wonderfu", status.toString().substring(0, 47));
49
50         LcmResponseStatus copiedStatus = new LcmResponseStatus();
51         copiedStatus.setCode(status.getCode());
52         copiedStatus.setMessage(status.getMessage());
53
54         assertTrue(status.equals(status));
55         assertTrue(status.equals(copiedStatus));
56         assertFalse(status.equals(null));
57         assertFalse(status.equals("Hello"));
58
59         status.setCode(-1);
60         assertFalse(status.equals(copiedStatus));
61         copiedStatus.setCode(-1);
62         assertTrue(status.equals(copiedStatus));
63         status.setCode(1234);
64         assertFalse(status.equals(copiedStatus));
65         copiedStatus.setCode(1234);
66         assertTrue(status.equals(copiedStatus));
67
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));
76     }
77 }