2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright 2018 TechMahindra
6 *=================================================================================
7 * Modifications Copyright 2018 IBM.
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=========================================================
22 package org.onap.appc.domainmodel.lcm;
24 import static org.junit.Assert.assertNotEquals;
25 import static org.junit.Assert.assertTrue;
27 import java.util.HashMap;
30 import org.junit.Assert;
31 import org.junit.Before;
32 import org.junit.Test;
34 public class TestResponseContext {
35 private ResponseContext responseContext;
36 private Map<String, String> testadditionalContext;
40 responseContext = new ResponseContext();
44 public void testgetAdditionalContext() {
45 testadditionalContext=new HashMap<String, String>();
46 testadditionalContext.put("A", "a");
47 responseContext.setAdditionalContext(testadditionalContext);
48 Assert.assertNotNull(responseContext.getAdditionalContext());
49 Assert.assertTrue(responseContext.getAdditionalContext().containsKey("A"));
50 Assert.assertTrue(responseContext.getAdditionalContext().containsValue("a"));
54 public void testGetPayload() {
55 responseContext.setPayload("ABC:2000");
56 Assert.assertNotNull(responseContext.getPayload());
57 Assert.assertEquals(responseContext.getPayload(), "ABC:2000");
61 public void testToString_ReturnNonEmptyString() {
62 assertNotEquals(responseContext.toString(), "");
63 assertNotEquals(responseContext.toString(), null);
67 public void testToString_ContainsString() {
68 assertTrue(responseContext.toString().contains("ResponseContext{commonHeader"));
72 public void testAddKeyValueToAdditionalContext() {
74 String value="value1";
75 responseContext.addKeyValueToAdditionalContext(key, value);
76 Map<String, String> additionalContext= responseContext.getAdditionalContext();
77 Assert.assertEquals("value1", additionalContext.get("key1"));
81 public void testGetPayloadObject() {
82 responseContext.setPayloadObject("ABC:2000");
83 Assert.assertEquals("ABC:2000", responseContext.getPayloadObject());