2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T 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.appclcm;
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 LcmResponseTest {
32 private static final String PAYLOAD = "payload";
35 public void testHashCode() {
36 LcmResponse response = new LcmResponse();
37 assertTrue(response.hashCode() != 0);
38 response.setCommonHeader(new LcmCommonHeader());
39 assertTrue(response.hashCode() != 0);
40 response.setPayload(PAYLOAD);
41 assertTrue(response.hashCode() != 0);
42 response.setStatus(null);
43 assertTrue(response.hashCode() != 0);
47 public void testLcmResponse() {
48 LcmResponse response = new LcmResponse();
49 assertNull(response.getCommonHeader());
50 assertNull(response.getPayload());
51 assertNotNull(response.getStatus());
55 public void testToString() {
56 LcmResponse response = new LcmResponse();
57 assertFalse(response.toString().isEmpty());
61 public void testEqualsObject() {
62 LcmResponse response = new LcmResponse();
63 assertTrue(response.equals(response));
64 assertFalse(response.equals(null));
65 assertFalse(response.equals(new Object()));
67 LcmResponse response2 = new LcmResponse();
68 assertTrue(response.equals(response2));
70 response.setCommonHeader(new LcmCommonHeader());
71 assertFalse(response.equals(response2));
72 response2.setCommonHeader(response.getCommonHeader());
73 assertTrue(response.equals(response2));
75 response.setPayload(PAYLOAD);
76 assertFalse(response.equals(response2));
77 response2.setPayload(response.getPayload());
78 assertTrue(response.equals(response2));
80 response.setCommonHeader(null);
81 assertFalse(response.equals(response2));
82 response2.setCommonHeader(null);
83 assertTrue(response.equals(response2));
85 response.setPayload(null);
86 assertFalse(response.equals(response2));
87 response2.setPayload(response.getPayload());
88 assertTrue(response.equals(response2));
90 response.setStatus(null);
91 assertFalse(response.equals(response2));
92 response2.setStatus(response.getStatus());
93 assertTrue(response.equals(response2));
95 LcmResponseStatus status = new LcmResponseStatus();
97 response.setStatus(status);
98 response2.setStatus(new LcmResponseStatus());
99 assertFalse(response.equals(response2));
103 public void testResponseRequest() {
104 LcmRequest request = new LcmRequest();
105 request.setCommonHeader(new LcmCommonHeader());
106 request.setPayload(PAYLOAD);
108 LcmResponse response = new LcmResponse(request);
110 assertTrue(response.getPayload().equals(PAYLOAD));