aboutsummaryrefslogtreecommitdiffstats
path: root/appc-dispatcher/appc-dispatcher-common
diff options
context:
space:
mode:
authorshubhada <SV00449682@techmahindra.com>2018-02-16 15:45:24 +0530
committerPatrick Brady <pb071s@att.com>2018-02-16 20:29:47 +0000
commita8d7d8cf46b7673d22ee0b95d805a88ae1e8da6c (patch)
tree7a170ee012a76911a8c1def195c10aa17d002ceb /appc-dispatcher/appc-dispatcher-common
parentc09c2057f5090f65d33caceaf55a4ede3f43d21a (diff)
Unit test coverage
Unit test coverage for 1.CommonHeader.java 2.Flags.java 3.RequestContext.java 4.ResponseContext.java 5.RuntimeContext.java Sonar Link: https://sonar.onap.org/code?id=org.onap.appc%3Aappc&selected=org.onap.appc%3Adomain-model-lib%3Asrc%2Fmain%2Fjava%2Forg%2Fonap%2Fappc%2Fdomainmodel%2Flcm Change-Id: I275495faa8c34f4b2174e93a56071298450c354b Issue-ID: APPC-640 Signed-off-by: shubhada <SV00449682@techmahindra.com>
Diffstat (limited to 'appc-dispatcher/appc-dispatcher-common')
-rw-r--r--appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestCommonHeader.java91
-rw-r--r--appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestFlags.java81
-rw-r--r--appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestRequestContext.java75
-rw-r--r--appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestResponseContext.java69
-rw-r--r--appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestRuntimeContext.java53
5 files changed, 369 insertions, 0 deletions
diff --git a/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestCommonHeader.java b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestCommonHeader.java
new file mode 100644
index 000000000..9f63a5022
--- /dev/null
+++ b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestCommonHeader.java
@@ -0,0 +1,91 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+package org.onap.appc.domainmodel.lcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.appc.domainmodel.lcm.Flags.Mode;
+
+public class TestCommonHeader {
+ private CommonHeader commonHeader;
+
+ @Before
+ public void setUp() {
+ commonHeader =new CommonHeader();
+ }
+
+ @Test
+ public void testgetRpcName() {
+ commonHeader.setApiVer("2.0");
+ Assert.assertNotNull(commonHeader.getApiVer());
+ Assert.assertEquals(commonHeader.getApiVer(), "2.0");
+ }
+
+ @Test
+ public void testGetOriginatorId() {
+ commonHeader.setOriginatorId("AAAA");
+ Assert.assertNotNull(commonHeader.getOriginatorId());
+ Assert.assertEquals(commonHeader.getOriginatorId(), "AAAA");
+ }
+
+ @Test
+ public void testGetRequestId() {
+ commonHeader.setRequestId("1111ABCD");
+ Assert.assertNotNull(commonHeader.getRequestId());
+ Assert.assertEquals(commonHeader.getRequestId(), "1111ABCD");
+ }
+
+ @Test
+ public void testGetSubRequestId() {
+ commonHeader.setSubRequestId("1111");
+ Assert.assertNotNull(commonHeader.getSubRequestId());
+ Assert.assertEquals(commonHeader.getSubRequestId(), "1111");
+ }
+
+ @Test
+ public void testGetFlags() {
+ Flags flags=new Flags();
+ flags.setTtl(60);
+ Mode mode=Mode.EXCLUSIVE;
+ flags.setMode(mode);
+ flags.setForce(false);
+ commonHeader.setFlags(flags);
+ Assert.assertNotNull(commonHeader.getFlags());
+ Assert.assertEquals(60,commonHeader.getFlags().getTtl());
+ Assert.assertEquals(Mode.EXCLUSIVE,commonHeader.getFlags().getMode());
+ Assert.assertEquals(false,commonHeader.getFlags().isForce());
+
+ }
+ @Test
+ public void testToString_ReturnNonEmptyString() {
+ assertNotEquals(commonHeader.toString(), "");
+ assertNotEquals(commonHeader.toString(), null);
+ }
+
+ @Test
+ public void testToString_ContainsString() {
+ assertTrue(commonHeader.toString().contains("CommonHeader{flags"));
+ }
+
+}
diff --git a/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestFlags.java b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestFlags.java
new file mode 100644
index 000000000..1d6b66f1b
--- /dev/null
+++ b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestFlags.java
@@ -0,0 +1,81 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+package org.onap.appc.domainmodel.lcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.appc.domainmodel.lcm.Flags.Mode;
+
+public class TestFlags {
+ private Flags flags;
+
+ @Before
+ public void setUp() {
+ flags = new Flags();
+ }
+
+ @Test
+ public void testIsForce() {
+ flags.setForce(true);
+ Assert.assertNotNull(flags.isForce());
+ Assert.assertEquals(flags.isForce(), true);
+ }
+
+ @Test
+ public void testGetTtl() {
+ flags.setTtl(1);
+ Assert.assertNotNull(flags.getTtl());
+ Assert.assertEquals(flags.getTtl(), 1);
+ }
+
+ @Test
+ public void testGetMode() {
+ flags.setMode(Mode.EXCLUSIVE);
+ Assert.assertNotNull(flags.getMode());
+ Assert.assertEquals(flags.getMode(),Mode.EXCLUSIVE);
+ }
+
+ @Test
+ public void testGetMode_ValidEnumConstant() {
+ flags.setMode("EXCLUSIVE");
+ Assert.assertNotNull(flags.getMode());
+ Assert.assertEquals(flags.getMode(),Mode.EXCLUSIVE);
+ }
+
+ @Test(expected=java.lang.IllegalArgumentException.class)
+ public void testGetMode_InvalidEnumConstant() {
+ flags.setMode("EXCLUSIVEEEE");
+ Assert.assertNotEquals(flags.getMode(),Mode.EXCLUSIVE);
+ }
+
+ @Test
+ public void testToString_ReturnNonEmptyString() {
+ assertNotEquals(flags.toString(), "");
+ assertNotEquals(flags.toString(), null);
+ }
+
+ @Test
+ public void testToString_ContainsString() {
+ assertTrue(flags.toString().contains("Flags{force"));
+ }
+}
diff --git a/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestRequestContext.java b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestRequestContext.java
new file mode 100644
index 000000000..9aee8e10f
--- /dev/null
+++ b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestRequestContext.java
@@ -0,0 +1,75 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+package org.onap.appc.domainmodel.lcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class TestRequestContext {
+ private RequestContext requestContext;
+ private Map<String, String> testadditionalContext;
+
+ @Before
+ public void setUp() {
+ requestContext = new RequestContext();
+ }
+
+ @Test
+ public void testGetActionLevel_ValidEnumConstant() {
+ requestContext.setActionLevel(ActionLevel.VM);
+ Assert.assertNotNull(requestContext. getActionLevel());
+ Assert.assertEquals(requestContext. getActionLevel(),ActionLevel.VM);
+ }
+
+ @Test
+ public void testgetAdditionalContext() {
+ testadditionalContext=new HashMap<String, String>();
+ testadditionalContext.put("A", "a");
+ requestContext.setAdditionalContext(testadditionalContext);
+ Assert.assertNotNull(requestContext.getAdditionalContext());
+ Assert.assertTrue(requestContext.getAdditionalContext().containsKey("A"));
+ Assert.assertTrue(requestContext.getAdditionalContext().containsValue("a"));
+ }
+
+ @Test
+ public void testGetPayload() {
+ requestContext.setPayload("ABC:2000");
+ Assert.assertNotNull(requestContext.getPayload());
+ Assert.assertEquals(requestContext.getPayload(), "ABC:2000");
+ }
+
+ @Test
+ public void testToString_ReturnNonEmptyString() {
+ assertNotEquals(requestContext.toString(), "");
+ assertNotEquals(requestContext.toString(), null);
+ }
+
+ @Test
+ public void testToString_ContainsString() {
+ assertTrue(requestContext.toString().contains("RequestContext{commonHeader"));
+ }
+
+}
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
new file mode 100644
index 000000000..18eaf8a86
--- /dev/null
+++ b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestResponseContext.java
@@ -0,0 +1,69 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+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;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestResponseContext {
+ private ResponseContext responseContext;
+ private Map<String, String> testadditionalContext;
+
+ @Before
+ public void setUp() {
+ responseContext = new ResponseContext();
+ }
+
+ @Test
+ public void testgetAdditionalContext() {
+ testadditionalContext=new HashMap<String, String>();
+ testadditionalContext.put("A", "a");
+ responseContext.setAdditionalContext(testadditionalContext);
+ Assert.assertNotNull(responseContext.getAdditionalContext());
+ Assert.assertTrue(responseContext.getAdditionalContext().containsKey("A"));
+ Assert.assertTrue(responseContext.getAdditionalContext().containsValue("a"));
+ }
+
+ @Test
+ public void testGetPayload() {
+ responseContext.setPayload("ABC:2000");
+ Assert.assertNotNull(responseContext.getPayload());
+ Assert.assertEquals(responseContext.getPayload(), "ABC:2000");
+ }
+
+ @Test
+ public void testToString_ReturnNonEmptyString() {
+ assertNotEquals(responseContext.toString(), "");
+ assertNotEquals(responseContext.toString(), null);
+ }
+
+ @Test
+ public void testToString_ContainsString() {
+ assertTrue(responseContext.toString().contains("ResponseContext{commonHeader"));
+ }
+
+}
diff --git a/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestRuntimeContext.java b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestRuntimeContext.java
new file mode 100644
index 000000000..87c545ee3
--- /dev/null
+++ b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestRuntimeContext.java
@@ -0,0 +1,53 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+package org.onap.appc.domainmodel.lcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestRuntimeContext {
+ private RuntimeContext runtimeContext;
+
+ @Before
+ public void setUp() {
+ runtimeContext =new RuntimeContext();
+ }
+
+ @Test
+ public void testGetRpcName() {
+ runtimeContext.setRpcName("ABC");
+ Assert.assertNotNull(runtimeContext.getRpcName());
+ Assert.assertEquals(runtimeContext.getRpcName(), "ABC");
+ }
+
+ @Test
+ public void testToString_ReturnNonEmptyString() {
+ assertNotEquals(runtimeContext.toString(), "");
+ assertNotEquals(runtimeContext.toString(), null);
+ }
+
+ @Test
+ public void testToString_ContainsString() {
+ assertTrue(runtimeContext.toString().contains("RuntimeContext{requestContext"));
+ }
+}