2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Nordix Foundation.
7 * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.sdnr;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertNull;
28 import static org.junit.Assert.assertTrue;
30 import org.junit.Test;
32 public class PciResponseTest {
34 Status status = new Status(0, "");
36 String responsePayload = "";
37 String requestPayload = "";
41 public void testHashCode() {
42 PciResponse response = new PciResponse();
43 assertTrue(response.hashCode() != 0);
44 response.setCommonHeader(new PciCommonHeader());
45 assertTrue(response.hashCode() != 0);
46 response.setPayload(responsePayload);
47 assertTrue(response.hashCode() != 0);
48 response.setStatus(null);
49 assertTrue(response.hashCode() != 0);
53 public void testPciResponse() {
54 PciResponse response = new PciResponse();
55 assertNull(response.getCommonHeader());
56 assertNull(response.getPayload());
57 assertNotNull(response.getStatus());
61 public void testToString() {
62 PciResponse response = new PciResponse();
63 assertFalse(response.toString().isEmpty());
67 public void testEqualsObject() {
68 PciResponse response = new PciResponse();
69 assertTrue(response.equals(response));
70 assertFalse(response.equals(null));
71 assertFalse(response.equals(new Object()));
73 PciResponse response2 = new PciResponse();
74 assertTrue(response.equals(response2));
76 response.setCommonHeader(new PciCommonHeader());
77 assertFalse(response.equals(response2));
78 response2.setCommonHeader(response.getCommonHeader());
79 assertTrue(response.equals(response2));
81 response.setPayload(responsePayload);
82 assertFalse(response.equals(response2));
83 response2.setPayload(response.getPayload());
84 assertTrue(response.equals(response2));
86 response.setCommonHeader(null);
87 assertFalse(response.equals(response2));
88 response2.setCommonHeader(null);
89 assertTrue(response.equals(response2));
91 response.setPayload(null);
92 assertFalse(response.equals(response2));
93 response2.setPayload(response.getPayload());
94 assertTrue(response.equals(response2));
96 response.setStatus(null);
97 assertFalse(response.equals(response2));
98 response2.setStatus(response.getStatus());
99 assertTrue(response.equals(response2));
101 Status stat = new Status();
103 response.setStatus(stat);
104 response2.setStatus(new Status());
105 assertFalse(response.equals(response2));
109 public void testResponseRequest() {
110 PciRequest request = new PciRequest();
111 request.setCommonHeader(new PciCommonHeader());
112 request.setPayload(requestPayload);
114 PciResponse response = new PciResponse(request);
116 assertTrue(response.getCommonHeader().equals(request.getCommonHeader()));