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-2020 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.assertEquals;
26 import static org.junit.Assert.assertFalse;
27 import static org.junit.Assert.assertNotEquals;
28 import static org.junit.Assert.assertNotNull;
29 import static org.junit.Assert.assertNull;
31 import org.junit.Test;
33 public class PciResponseTest {
35 Status status = new Status(0, "");
37 String responsePayload = "";
38 String requestPayload = "";
42 public void testHashCode() {
43 PciResponse response = new PciResponse();
44 assertNotEquals(0, response.hashCode());
45 response.setCommonHeader(new PciCommonHeader());
46 assertNotEquals(0, response.hashCode());
47 response.setPayload(responsePayload);
48 assertNotEquals(0, response.hashCode());
49 response.setStatus(null);
50 assertNotEquals(0, response.hashCode());
54 public void testPciResponse() {
55 PciResponse response = new PciResponse();
56 assertNull(response.getCommonHeader());
57 assertNull(response.getPayload());
58 assertNotNull(response.getStatus());
62 public void testToString() {
63 PciResponse response = new PciResponse();
64 assertFalse(response.toString().isEmpty());
68 public void testEqualsObject() {
69 PciResponse response = new PciResponse();
70 assertEquals(response, response);
71 assertNotEquals(response, null);
72 assertNotEquals(response, new Object());
74 PciResponse response2 = new PciResponse();
75 assertEquals(response, response2);
77 response.setCommonHeader(new PciCommonHeader());
78 assertNotEquals(response, response2);
79 response2.setCommonHeader(response.getCommonHeader());
80 assertEquals(response, response2);
82 response.setPayload(responsePayload);
83 assertNotEquals(response, response2);
84 response2.setPayload(response.getPayload());
85 assertEquals(response, response2);
87 response.setCommonHeader(null);
88 assertNotEquals(response, response2);
89 response2.setCommonHeader(null);
90 assertEquals(response, response2);
92 response.setPayload(null);
93 assertNotEquals(response, response2);
94 response2.setPayload(response.getPayload());
95 assertEquals(response, response2);
97 response.setStatus(null);
98 assertNotEquals(response, response2);
99 response2.setStatus(response.getStatus());
100 assertEquals(response, response2);
102 Status stat = new Status();
104 response.setStatus(stat);
105 response2.setStatus(new Status());
106 assertNotEquals(response, response2);
110 public void testResponseRequest() {
111 PciRequest request = new PciRequest();
112 request.setCommonHeader(new PciCommonHeader());
113 request.setPayload(requestPayload);
115 PciResponse response = new PciResponse(request);
117 assertEquals(response.getCommonHeader(), request.getCommonHeader());