2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright 2018 TechMahindra
6 *=================================================================================
7 * Modifications Copyright 2018 IBM.
8 *=================================================================================
9 * Modifications Copyright 2019 AT&T Intellectual Property
10 *=================================================================================
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
22 * ============LICENSE_END=========================================================
24 package org.onap.appc.domainmodel.lcm;
26 import static org.junit.Assert.*;
28 import org.junit.Assert;
29 import org.junit.Before;
30 import org.junit.Test;
32 import java.util.HashMap;
35 public class TestRequestContext {
36 private RequestContext requestContext;
37 private Map<String, String> testadditionalContext;
41 requestContext = new RequestContext();
45 public void testGetActionLevel_ValidEnumConstant() {
46 requestContext.setActionLevel(ActionLevel.VM);
47 Assert.assertNotNull(requestContext.getActionLevel());
48 Assert.assertEquals(requestContext.getActionLevel(), ActionLevel.VM);
52 public void testgetAdditionalContext() {
53 testadditionalContext = new HashMap<String, String>();
54 testadditionalContext.put("A", "a");
55 requestContext.setAdditionalContext(testadditionalContext);
56 Assert.assertNotNull(requestContext.getAdditionalContext());
57 Assert.assertTrue(requestContext.getAdditionalContext().containsKey("A"));
58 Assert.assertTrue(requestContext.getAdditionalContext().containsValue("a"));
62 public void testAddKeyValueToAdditionalContext() {
64 String value = "value1";
65 requestContext.addKeyValueToAdditionalContext(key, value);
66 Map<String, String> additionalContext = requestContext.getAdditionalContext();
67 Assert.assertEquals("value1", additionalContext.get("key1"));
71 public void testGetPayload() {
72 requestContext.setPayload("ABC:2000");
73 Assert.assertNotNull(requestContext.getPayload());
74 Assert.assertEquals(requestContext.getPayload(), "ABC:2000");
78 public void testToString_ReturnNonEmptyString() {
79 assertNotEquals(requestContext.toString(), "");
80 assertNotEquals(requestContext.toString(), null);
84 public void testToString_ContainsString() {
85 assertTrue(requestContext.toString().contains("RequestContext{commonHeader"));
89 public void testGetSetCommonHeader() {
90 CommonHeader commonHeader = new CommonHeader();
91 requestContext.setCommonHeader(commonHeader);
92 assertEquals(commonHeader, requestContext.getCommonHeader());
96 public void testGetSetActionIdentifiers() {
97 ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
98 requestContext.setActionIdentifiers(actionIdentifiers);
99 assertEquals(actionIdentifiers, requestContext.getActionIdentifiers());
103 public void testGetSetAction() {
104 VNFOperation action = VNFOperation.ActionStatus;
105 requestContext.setAction(action);
106 assertEquals(action, requestContext.getAction());