move actors code in drools-applications to policy/models
[policy/models.git] / models-interactions / model-impl / appclcm / src / test / java / org / onap / policy / appclcm / LcmResponseTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * appclcm
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.assertFalse;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertNull;
27 import static org.junit.Assert.assertTrue;
28
29 import org.junit.Test;
30
31 public class LcmResponseTest {
32
33     private static final String PAYLOAD = "payload";
34
35     @Test
36     public void testHashCode() {
37         LcmResponse response = new LcmResponse();
38         assertTrue(response.hashCode() != 0);
39         response.setCommonHeader(new LcmCommonHeader());
40         assertTrue(response.hashCode() != 0);
41         response.setPayload(PAYLOAD);
42         assertTrue(response.hashCode() != 0);
43         response.setStatus(null);
44         assertTrue(response.hashCode() != 0);
45     }
46
47     @Test
48     public void testLcmResponse() {
49         LcmResponse response = new LcmResponse();
50         assertNull(response.getCommonHeader());
51         assertNull(response.getPayload());
52         assertNotNull(response.getStatus());
53     }
54
55     @Test
56     public void testToString() {
57         LcmResponse response = new LcmResponse();
58         assertFalse(response.toString().isEmpty());
59     }
60
61     @Test
62     public void testEqualsObject() {
63         LcmResponse response = new LcmResponse();
64         assertTrue(response.equals(response));
65         assertFalse(response.equals(null));
66         assertFalse(response.equals(new Object()));
67
68         LcmResponse response2 = new LcmResponse();
69         assertTrue(response.equals(response2));
70
71         response.setCommonHeader(new LcmCommonHeader());
72         assertFalse(response.equals(response2));
73         response2.setCommonHeader(response.getCommonHeader());
74         assertTrue(response.equals(response2));
75
76         response.setPayload(PAYLOAD);
77         assertFalse(response.equals(response2));
78         response2.setPayload(response.getPayload());
79         assertTrue(response.equals(response2));
80
81         response.setCommonHeader(null);
82         assertFalse(response.equals(response2));
83         response2.setCommonHeader(null);
84         assertTrue(response.equals(response2));
85
86         response.setPayload(null);
87         assertFalse(response.equals(response2));
88         response2.setPayload(response.getPayload());
89         assertTrue(response.equals(response2));
90
91         response.setStatus(null);
92         assertFalse(response.equals(response2));
93         response2.setStatus(response.getStatus());
94         assertTrue(response.equals(response2));
95
96         LcmResponseStatus status = new LcmResponseStatus();
97         status.setCode(5);
98         response.setStatus(status);
99         response2.setStatus(new LcmResponseStatus());
100         assertFalse(response.equals(response2));
101     }
102
103     @Test
104     public void testResponseRequest() {
105         LcmRequest request = new LcmRequest();
106         request.setCommonHeader(new LcmCommonHeader());
107         request.setPayload(PAYLOAD);
108
109         LcmResponse response = new LcmResponse(request);
110
111         assertTrue(response.getPayload().equals(PAYLOAD));
112     }
113
114 }