2 * ============LICENSE_START=======================================================
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.policy.sdnr;
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;
29 import org.junit.Test;
31 public class PciResponseTest {
33 Status status = new Status(0, "");
35 String responsePayload = "";
36 String requestPayload = "";
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);
52 public void testPciResponse() {
53 PciResponse response = new PciResponse();
54 assertNull(response.getCommonHeader());
55 assertNull(response.getPayload());
56 assertNotNull(response.getStatus());
60 public void testToString() {
61 PciResponse response = new PciResponse();
62 assertFalse(response.toString().isEmpty());
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()));
72 PciResponse response2 = new PciResponse();
73 assertTrue(response.equals(response2));
75 response.setCommonHeader(new PciCommonHeader());
76 assertFalse(response.equals(response2));
77 response2.setCommonHeader(response.getCommonHeader());
78 assertTrue(response.equals(response2));
80 response.setPayload(responsePayload);
81 assertFalse(response.equals(response2));
82 response2.setPayload(response.getPayload());
83 assertTrue(response.equals(response2));
85 response.setCommonHeader(null);
86 assertFalse(response.equals(response2));
87 response2.setCommonHeader(null);
88 assertTrue(response.equals(response2));
90 response.setPayload(null);
91 assertFalse(response.equals(response2));
92 response2.setPayload(response.getPayload());
93 assertTrue(response.equals(response2));
95 response.setStatus(null);
96 assertFalse(response.equals(response2));
97 response2.setStatus(response.getStatus());
98 assertTrue(response.equals(response2));
100 Status status = new Status();
102 response.setStatus(status);
103 response2.setStatus(new Status());
104 assertFalse(response.equals(response2));
108 public void testResponseRequest() {
109 PciRequest request = new PciRequest();
110 request.setCommonHeader(new PciCommonHeader());
111 request.setPayload(requestPayload);
113 PciResponse response = new PciResponse(request);
115 assertTrue(response.getCommonHeader().equals(request.getCommonHeader()));