summaryrefslogtreecommitdiffstats
path: root/appc-dg
diff options
context:
space:
mode:
authorshubhada <SV00449682@techmahindra.com>2018-03-21 15:59:56 +0530
committershubhada <SV00449682@techmahindra.com>2018-03-21 15:59:56 +0530
commitf9b6ffd65bce160c6887c8c8b586f6d59f20d201 (patch)
treebb8110e156f09e0201819d0b0d9108b352444651 /appc-dg
parentf5b15b97160bef94e5ec309c92ac5cbf59d9ca49 (diff)
Unit Test Coverage
Unit Tests for: 1. Constants.java 2. DataReaderException.java 3. DgResolverException.java 4. FlowKey.java 5. VnfExecutionInternalException.java Sonar-Link: https://sonar.onap.org/code?id=org.onap.appc%3Aappc&selected=org.onap.appc%3Aappc-dg-common%3Asrc%2Fmain%2Fjava%2Forg%2Fonap%2Fappc%2Fdg%2Fcommon%2Fimpl Change-Id: Ib3839ce2eb44b6f2e8b530696f4e4354e61df3d4 Issue-ID: APPC-756 Signed-off-by: shubhada <SV00449682@techmahindra.com>
Diffstat (limited to 'appc-dg')
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestConstants.java70
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestDataReaderException.java45
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestDgResolverException.java44
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestFlowKey.java49
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVnfExecutionInternalException.java36
5 files changed, 244 insertions, 0 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestConstants.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestConstants.java
new file mode 100644
index 000000000..871cd9b3b
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestConstants.java
@@ -0,0 +1,70 @@
+/*
+* ============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.dg.common.impl;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.appc.dg.common.impl.Constants.LCMAttributes;
+import org.onap.appc.dg.common.impl.Constants.LegacyAttributes;
+
+public class TestConstants {
+ private Constants constants=new Constants();
+ private LegacyAttributes legacyAttributes=LegacyAttributes.ACTION;
+ private LCMAttributes lCMAttributes=LCMAttributes.ACTION;
+
+ @Test
+ public void testConstants() {
+ Assert.assertNotNull(constants);
+ Assert.assertEquals("org.onap.appc.dg.error",constants.DG_ERROR_FIELD_NAME);
+ }
+
+ @Test
+ public void testLegacyAttributes_Name() {
+ Assert.assertEquals("ACTION",legacyAttributes.name());
+ }
+
+ @Test
+ public void test_getValue_LegacyAttributes() {
+ Assert.assertEquals("org.onap.appc.action",legacyAttributes.getValue());
+ }
+
+ @Test
+ public void testEquals_for_LegacyAttributes() {
+ Assert.assertTrue(legacyAttributes.equals(LegacyAttributes.ACTION));
+ Assert.assertFalse(legacyAttributes.equals(null));
+ }
+
+ @Test
+ public void testLCMAttributes_Name() {
+ Assert.assertEquals("ACTION",lCMAttributes.name());
+ }
+
+ @Test
+ public void test_getValue_LCMAttributes() {
+ Assert.assertEquals("input.action",lCMAttributes.getValue());
+ }
+
+ @Test
+ public void testEquals_for_LCMAttributes() {
+ Assert.assertTrue(lCMAttributes.equals(LCMAttributes.ACTION));
+ Assert.assertFalse(lCMAttributes.equals(null));
+ }
+
+} \ No newline at end of file
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestDataReaderException.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestDataReaderException.java
new file mode 100644
index 000000000..f8aec7bf3
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestDataReaderException.java
@@ -0,0 +1,45 @@
+/*
+* ============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.dg.common.impl;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestDataReaderException {
+
+ @Test
+ public void testConstructorWithThrowable() throws Exception {
+ String message = "testing message";
+ Throwable throwable = new Throwable(message);
+ DataReaderException dataReaderException = new DataReaderException(throwable);
+ Assert.assertEquals(throwable, dataReaderException.getCause());
+ Assert.assertTrue(dataReaderException.getLocalizedMessage().contains(message));
+ Assert.assertTrue(dataReaderException.getMessage().contains(message));
+ }
+
+ @Test
+ public void testConstructorWithMessage() throws Exception {
+ String message = "testing message";
+ DataReaderException dataReaderException = new DataReaderException(message);
+ Assert.assertTrue(dataReaderException.getCause() == null);
+ Assert.assertEquals(message,dataReaderException.getLocalizedMessage());
+ Assert.assertEquals(message, dataReaderException.getMessage());
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestDgResolverException.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestDgResolverException.java
new file mode 100644
index 000000000..0daabbd87
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestDgResolverException.java
@@ -0,0 +1,44 @@
+/*
+* ============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.dg.common.impl;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestDgResolverException {
+ @Test
+ public void testConstructorWithMessage() throws Exception {
+ String message = "testing message";
+ DgResolverException dgResolverException = new DgResolverException(message);
+ Assert.assertTrue(dgResolverException.getCause() == null);
+ Assert.assertEquals(message,dgResolverException.getLocalizedMessage());
+ Assert.assertEquals(message, dgResolverException.getMessage());
+ }
+
+ @Test
+ public void testConstructorWithThrowable() throws Exception {
+ String message = "testing message";
+ Throwable throwable = new Throwable(message);
+ DgResolverException dgResolverException = new DgResolverException(throwable);
+ Assert.assertEquals(throwable, dgResolverException.getCause());
+ Assert.assertTrue(dgResolverException.getLocalizedMessage().contains(message));
+ Assert.assertTrue(dgResolverException.getMessage().contains(message));
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestFlowKey.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestFlowKey.java
new file mode 100644
index 000000000..d5f4c1e84
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestFlowKey.java
@@ -0,0 +1,49 @@
+/*
+* ============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.dg.common.impl;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestFlowKey {
+ private FlowKey flowkKey;
+
+ @Before
+ public void SetUp() {
+ flowkKey=new FlowKey("ONAP","1.0","APPC");
+ }
+ @Test
+ public void test_ConstructorWithThreeArguments() {
+ Assert.assertEquals("ONAP",flowkKey.name());
+ Assert.assertEquals("1.0",flowkKey.version());
+ Assert.assertEquals("APPC",flowkKey.module());
+ }
+
+ @Test
+ public void testToString_ReturnNonEmptyString() {
+ Assert.assertNotEquals(flowkKey.toString(), "");
+ Assert.assertNotEquals(flowkKey.toString(), null);
+ }
+ @Test
+ public void testToString_ContainsString() {
+ Assert.assertTrue(flowkKey.toString().contains("name"));
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVnfExecutionInternalException.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVnfExecutionInternalException.java
new file mode 100644
index 000000000..3aebdc7ac
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVnfExecutionInternalException.java
@@ -0,0 +1,36 @@
+/*
+* ============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.dg.common.impl;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestVnfExecutionInternalException {
+
+ @Test
+ public void testConstructorWithThrowable() throws Exception {
+ String message = "testing message";
+ Throwable throwable = new Throwable(message);
+ VnfExecutionInternalException vnfExecutionInternalException = new VnfExecutionInternalException(throwable);
+ Assert.assertEquals(throwable, vnfExecutionInternalException.getCause());
+ Assert.assertTrue(vnfExecutionInternalException.getLocalizedMessage().contains(message));
+ Assert.assertTrue(vnfExecutionInternalException.getMessage().contains(message));
+ }
+}