move actors code in drools-applications to policy/models
[policy/models.git] / models-interactions / model-impl / sdnr / src / test / java / org / onap / policy / sdnr / PciResponseTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * sdnr
4  * ================================================================================
5  * Copyright (C) 2018 Wipro Limited 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.sdnr;
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 PciResponseTest {
32
33     Status status = new Status(0, "");
34
35     String responsePayload = "";
36     String requestPayload = "";
37
38
39     @Test
40     public void testHashCode() {
41         PciResponse response = new PciResponse();
42         assertTrue(response.hashCode() != 0);
43         response.setCommonHeader(new PciCommonHeader());
44         assertTrue(response.hashCode() != 0);
45         response.setPayload(responsePayload);
46         assertTrue(response.hashCode() != 0);
47         response.setStatus(null);
48         assertTrue(response.hashCode() != 0);
49     }
50
51     @Test
52     public void testPciResponse() {
53         PciResponse response = new PciResponse();
54         assertNull(response.getCommonHeader());
55         assertNull(response.getPayload());
56         assertNotNull(response.getStatus());
57     }
58
59     @Test
60     public void testToString() {
61         PciResponse response = new PciResponse();
62         assertFalse(response.toString().isEmpty());
63     }
64
65     @Test
66     public void testEqualsObject() {
67         PciResponse response = new PciResponse();
68         assertTrue(response.equals(response));
69         assertFalse(response.equals(null));
70         assertFalse(response.equals(new Object()));
71
72         PciResponse response2 = new PciResponse();
73         assertTrue(response.equals(response2));
74
75         response.setCommonHeader(new PciCommonHeader());
76         assertFalse(response.equals(response2));
77         response2.setCommonHeader(response.getCommonHeader());
78         assertTrue(response.equals(response2));
79
80         response.setPayload(responsePayload);
81         assertFalse(response.equals(response2));
82         response2.setPayload(response.getPayload());
83         assertTrue(response.equals(response2));
84
85         response.setCommonHeader(null);
86         assertFalse(response.equals(response2));
87         response2.setCommonHeader(null);
88         assertTrue(response.equals(response2));
89
90         response.setPayload(null);
91         assertFalse(response.equals(response2));
92         response2.setPayload(response.getPayload());
93         assertTrue(response.equals(response2));
94
95         response.setStatus(null);
96         assertFalse(response.equals(response2));
97         response2.setStatus(response.getStatus());
98         assertTrue(response.equals(response2));
99
100         Status status = new Status();
101         status.setCode(5);
102         response.setStatus(status);
103         response2.setStatus(new Status());
104         assertFalse(response.equals(response2));
105     }
106
107     @Test
108     public void testResponseRequest() {
109         PciRequest request = new PciRequest();
110         request.setCommonHeader(new PciCommonHeader());
111         request.setPayload(requestPayload);
112
113         PciResponse response = new PciResponse(request);
114
115         assertTrue(response.getCommonHeader().equals(request.getCommonHeader()));
116     }
117
118 }