Unit test coverage 29/31929/2
authorshubhada <SV00449682@techmahindra.com>
Fri, 16 Feb 2018 10:15:24 +0000 (15:45 +0530)
committerPatrick Brady <pb071s@att.com>
Fri, 16 Feb 2018 20:29:47 +0000 (20:29 +0000)
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>
appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestCommonHeader.java [new file with mode: 0644]
appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestFlags.java [new file with mode: 0644]
appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestRequestContext.java [new file with mode: 0644]
appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestResponseContext.java [new file with mode: 0644]
appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestRuntimeContext.java [new file with mode: 0644]

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 (file)
index 0000000..9f63a50
--- /dev/null
@@ -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 (file)
index 0000000..1d6b66f
--- /dev/null
@@ -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 (file)
index 0000000..9aee8e1
--- /dev/null
@@ -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 (file)
index 0000000..18eaf8a
--- /dev/null
@@ -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 (file)
index 0000000..87c545e
--- /dev/null
@@ -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"));
+    }
+}