2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.sdnr;
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;
28 import org.junit.Test;
30 public class PciResponseTest {
32 Status status = new Status(0, "");
34 String responsePayload = "";
35 String requestPayload = "";
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);
51 public void testPciResponse() {
52 PciResponse response = new PciResponse();
53 assertNull(response.getCommonHeader());
54 assertNull(response.getPayload());
55 assertNotNull(response.getStatus());
59 public void testToString() {
60 PciResponse response = new PciResponse();
61 assertFalse(response.toString().isEmpty());
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()));
71 PciResponse response2 = new PciResponse();
72 assertTrue(response.equals(response2));
74 response.setCommonHeader(new PciCommonHeader());
75 assertFalse(response.equals(response2));
76 response2.setCommonHeader(response.getCommonHeader());
77 assertTrue(response.equals(response2));
79 response.setPayload(responsePayload);
80 assertFalse(response.equals(response2));
81 response2.setPayload(response.getPayload());
82 assertTrue(response.equals(response2));
84 response.setCommonHeader(null);
85 assertFalse(response.equals(response2));
86 response2.setCommonHeader(null);
87 assertTrue(response.equals(response2));
89 response.setPayload(null);
90 assertFalse(response.equals(response2));
91 response2.setPayload(response.getPayload());
92 assertTrue(response.equals(response2));
94 response.setStatus(null);
95 assertFalse(response.equals(response2));
96 response2.setStatus(response.getStatus());
97 assertTrue(response.equals(response2));
99 Status status = new Status();
101 response.setStatus(status);
102 response2.setStatus(new Status());
103 assertFalse(response.equals(response2));
107 public void testResponseRequest() {
108 PciRequest request = new PciRequest();
109 request.setCommonHeader(new PciCommonHeader());
110 request.setPayload(requestPayload);
112 PciResponse response = new PciResponse(request);
114 assertTrue(response.getCommonHeader().equals(request.getCommonHeader()));