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.*;
26 import org.junit.Assert;
27 import org.junit.Before;
28 import org.junit.Test;
30 import java.util.HashMap;
33 public class TestRequestContext {
34 private RequestContext requestContext;
35 private Map<String, String> testadditionalContext;
39 requestContext = new RequestContext();
43 public void testGetActionLevel_ValidEnumConstant() {
44 requestContext.setActionLevel(ActionLevel.VM);
45 Assert.assertNotNull(requestContext. getActionLevel());
46 Assert.assertEquals(requestContext. getActionLevel(),ActionLevel.VM);
50 public void testgetAdditionalContext() {
51 testadditionalContext=new HashMap<String, String>();
52 testadditionalContext.put("A", "a");
53 requestContext.setAdditionalContext(testadditionalContext);
54 Assert.assertNotNull(requestContext.getAdditionalContext());
55 Assert.assertTrue(requestContext.getAdditionalContext().containsKey("A"));
56 Assert.assertTrue(requestContext.getAdditionalContext().containsValue("a"));
60 public void testAddKeyValueToAdditionalContext() {
62 String value="value1";
63 requestContext.addKeyValueToAdditionalContext(key, value);
64 Map<String, String> additionalContext= requestContext.getAdditionalContext();
65 Assert.assertEquals("value1", additionalContext.get("key1"));
69 public void testGetPayload() {
70 requestContext.setPayload("ABC:2000");
71 Assert.assertNotNull(requestContext.getPayload());
72 Assert.assertEquals(requestContext.getPayload(), "ABC:2000");
76 public void testToString_ReturnNonEmptyString() {
77 assertNotEquals(requestContext.toString(), "");
78 assertNotEquals(requestContext.toString(), null);
82 public void testToString_ContainsString() {
83 assertTrue(requestContext.toString().contains("RequestContext{commonHeader"));
87 public void testGetSetCommonHeader()
89 CommonHeader commonHeader = new CommonHeader();
90 requestContext.setCommonHeader(commonHeader);
91 assertEquals(commonHeader, requestContext.getCommonHeader());
95 public void testGetSetActionIdentifiers()
97 ActionIdentifiers actionIdentifiers= new ActionIdentifiers();
98 requestContext.setActionIdentifiers(actionIdentifiers);
99 assertEquals(actionIdentifiers, requestContext.getActionIdentifiers());
103 public void testGetSetAction()
105 VNFOperation action= VNFOperation.ActionStatus;
106 requestContext.setAction(action);
107 assertEquals(action, requestContext.getAction());