2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T 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.appclcm;
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 LcmResponseTest {
33 private static final String PAYLOAD = "payload";
36 public void testHashCode() {
37 LcmResponse response = new LcmResponse();
38 assertTrue(response.hashCode() != 0);
39 response.setCommonHeader(new LcmCommonHeader());
40 assertTrue(response.hashCode() != 0);
41 response.setPayload(PAYLOAD);
42 assertTrue(response.hashCode() != 0);
43 response.setStatus(null);
44 assertTrue(response.hashCode() != 0);
48 public void testLcmResponse() {
49 LcmResponse response = new LcmResponse();
50 assertNull(response.getCommonHeader());
51 assertNull(response.getPayload());
52 assertNotNull(response.getStatus());
56 public void testToString() {
57 LcmResponse response = new LcmResponse();
58 assertFalse(response.toString().isEmpty());
62 public void testEqualsObject() {
63 LcmResponse response = new LcmResponse();
64 assertTrue(response.equals(response));
65 assertFalse(response.equals(null));
66 assertFalse(response.equals(new Object()));
68 LcmResponse response2 = new LcmResponse();
69 assertTrue(response.equals(response2));
71 response.setCommonHeader(new LcmCommonHeader());
72 assertFalse(response.equals(response2));
73 response2.setCommonHeader(response.getCommonHeader());
74 assertTrue(response.equals(response2));
76 response.setPayload(PAYLOAD);
77 assertFalse(response.equals(response2));
78 response2.setPayload(response.getPayload());
79 assertTrue(response.equals(response2));
81 response.setCommonHeader(null);
82 assertFalse(response.equals(response2));
83 response2.setCommonHeader(null);
84 assertTrue(response.equals(response2));
86 response.setPayload(null);
87 assertFalse(response.equals(response2));
88 response2.setPayload(response.getPayload());
89 assertTrue(response.equals(response2));
91 response.setStatus(null);
92 assertFalse(response.equals(response2));
93 response2.setStatus(response.getStatus());
94 assertTrue(response.equals(response2));
96 LcmResponseStatus status = new LcmResponseStatus();
98 response.setStatus(status);
99 response2.setStatus(new LcmResponseStatus());
100 assertFalse(response.equals(response2));
104 public void testResponseRequest() {
105 LcmRequest request = new LcmRequest();
106 request.setCommonHeader(new LcmCommonHeader());
107 request.setPayload(PAYLOAD);
109 LcmResponse response = new LcmResponse(request);
111 assertTrue(response.getPayload().equals(PAYLOAD));