Merge "Add debugging of REST call"
[policy/drools-applications.git] / controlloop / common / 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  * ================================================================================
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.sdnr;
22
23 import static org.junit.Assert.assertFalse;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertNull;
26 import static org.junit.Assert.assertTrue;
27
28 import org.junit.Test;
29
30 public class PciResponseTest {
31
32     Status status = new Status(0, "");
33
34     String responsePayload = "";
35     String requestPayload = "";
36
37
38     @Test
39     public void testHashCode() {
40         PciResponse response = new PciResponse();
41         assertTrue(response.hashCode() != 0);
42         response.setCommonHeader(new PciCommonHeader());
43         assertTrue(response.hashCode() != 0);
44         response.setPayload(responsePayload);
45         assertTrue(response.hashCode() != 0);
46         response.setStatus(null);
47         assertTrue(response.hashCode() != 0);
48     }
49
50     @Test
51     public void testPciResponse() {
52         PciResponse response = new PciResponse();
53         assertNull(response.getCommonHeader());
54         assertNull(response.getPayload());
55         assertNotNull(response.getStatus());
56     }
57
58     @Test
59     public void testToString() {
60         PciResponse response = new PciResponse();
61         assertFalse(response.toString().isEmpty());
62     }
63
64     @Test
65     public void testEqualsObject() {
66         PciResponse response = new PciResponse();
67         assertTrue(response.equals(response));
68         assertFalse(response.equals(null));
69         assertFalse(response.equals(new Object()));
70
71         PciResponse response2 = new PciResponse();
72         assertTrue(response.equals(response2));
73
74         response.setCommonHeader(new PciCommonHeader());
75         assertFalse(response.equals(response2));
76         response2.setCommonHeader(response.getCommonHeader());
77         assertTrue(response.equals(response2));
78
79         response.setPayload(responsePayload);
80         assertFalse(response.equals(response2));
81         response2.setPayload(response.getPayload());
82         assertTrue(response.equals(response2));
83
84         response.setCommonHeader(null);
85         assertFalse(response.equals(response2));
86         response2.setCommonHeader(null);
87         assertTrue(response.equals(response2));
88
89         response.setPayload(null);
90         assertFalse(response.equals(response2));
91         response2.setPayload(response.getPayload());
92         assertTrue(response.equals(response2));
93
94         response.setStatus(null);
95         assertFalse(response.equals(response2));
96         response2.setStatus(response.getStatus());
97         assertTrue(response.equals(response2));
98
99         Status status = new Status();
100         status.setCode(5);
101         response.setStatus(status);
102         response2.setStatus(new Status());
103         assertFalse(response.equals(response2));
104     }
105
106     @Test
107     public void testResponseRequest() {
108         PciRequest request = new PciRequest();
109         request.setCommonHeader(new PciCommonHeader());
110         request.setPayload(requestPayload);
111
112         PciResponse response = new PciResponse(request);
113
114         assertTrue(response.getCommonHeader().equals(request.getCommonHeader()));
115     }
116
117 }