From: Sudarshan Kumar Date: Mon, 4 Feb 2019 17:18:30 +0000 (+0530) Subject: Additional test case added ResponseContext.java X-Git-Tag: 1.5.0~297 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=appc.git;a=commitdiff_plain;h=6d90b168b366e90a0b13d1589830b2c3c83164bd Additional test case added ResponseContext.java Additional junit test case added for ResponseContext.java Issue-ID: APPC-1372 Change-Id: Iaa9455d80e84c46c39ffce066abe3aedfb56a58d Signed-off-by: Sudarshan Kumar --- diff --git a/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestResponseContext.java b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestResponseContext.java index ffa80b490..1b6fa4b05 100644 --- a/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestResponseContext.java +++ b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestResponseContext.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright 2018 TechMahindra *================================================================================= -* Modifications Copyright 2018 IBM. +* Modifications Copyright 2019 IBM. *================================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,9 +21,6 @@ */ package org.onap.appc.domainmodel.lcm; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; - import java.util.HashMap; import java.util.Map; @@ -34,15 +31,21 @@ import org.junit.Test; public class TestResponseContext { private ResponseContext responseContext; private Map testadditionalContext; + private CommonHeader commonHeader; + private Status status; @Before public void setUp() { responseContext = new ResponseContext(); + commonHeader = new CommonHeader(); + commonHeader.setOriginatorId("originatorId"); + status = new Status(); + status.setCode(0); } @Test - public void testgetAdditionalContext() { - testadditionalContext=new HashMap(); + public void testgetAdditionalContext() { + testadditionalContext = new HashMap(); testadditionalContext.put("A", "a"); responseContext.setAdditionalContext(testadditionalContext); Assert.assertNotNull(responseContext.getAdditionalContext()); @@ -54,33 +57,45 @@ public class TestResponseContext { public void testGetPayload() { responseContext.setPayload("ABC:2000"); Assert.assertNotNull(responseContext.getPayload()); - Assert.assertEquals(responseContext.getPayload(), "ABC:2000"); + Assert.assertEquals("ABC:2000",responseContext.getPayload()); } @Test public void testToString_ReturnNonEmptyString() { - assertNotEquals(responseContext.toString(), ""); - assertNotEquals(responseContext.toString(), null); + Assert.assertNotEquals("",responseContext.toString()); + Assert.assertNotEquals(null,responseContext.toString()); } @Test public void testToString_ContainsString() { - assertTrue(responseContext.toString().contains("ResponseContext{commonHeader")); + Assert.assertTrue(responseContext.toString().contains("ResponseContext{commonHeader")); } - + @Test public void testAddKeyValueToAdditionalContext() { - String key="key1"; - String value="value1"; + String key = "key1"; + String value = "value1"; responseContext.addKeyValueToAdditionalContext(key, value); - Map additionalContext= responseContext.getAdditionalContext(); + Map additionalContext = responseContext.getAdditionalContext(); Assert.assertEquals("value1", additionalContext.get("key1")); } - + @Test public void testGetPayloadObject() { responseContext.setPayloadObject("ABC:2000"); Assert.assertEquals("ABC:2000", responseContext.getPayloadObject()); } + @Test + public void testGetCommonHeader() { + responseContext.setCommonHeader(commonHeader); + Assert.assertEquals("originatorId", responseContext.getCommonHeader().getOriginatorId()); + } + + @Test + public void testGetStatus() { + responseContext.setStatus(status); + Assert.assertEquals(0, responseContext.getStatus().getCode()); + } + }