From b01f8d28203f7d9b505b0fa5a17467b37ab91f07 Mon Sep 17 00:00:00 2001 From: shubhada Date: Tue, 13 Feb 2018 14:56:18 +0530 Subject: Unit test coverage Unit test coverage for 1.Status.java, 2.TransactionRecord.java 3.VNFContext.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: I38421c753d215ddab49431a2124c6a74056b3bf1 Issue-ID: APPC-617 Signed-off-by: shubhada --- .../org/onap/appc/domainmodel/lcm/TestStatus.java | 60 ++++++++++ .../domainmodel/lcm/TestTransactionRecord.java | 130 +++++++++++++++++++++ .../onap/appc/domainmodel/lcm/TestVNFContext.java | 75 ++++++++++++ 3 files changed, 265 insertions(+) create mode 100644 appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestStatus.java create mode 100644 appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestTransactionRecord.java create mode 100644 appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestVNFContext.java (limited to 'appc-dispatcher/appc-dispatcher-common') diff --git a/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestStatus.java b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestStatus.java new file mode 100644 index 000000000..4a3bf576d --- /dev/null +++ b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestStatus.java @@ -0,0 +1,60 @@ +/* +* ============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 TestStatus { + private Status status; + + @Before + public void setUp() { + status = new Status(); + } + + @Test + public void testGetCode() { + status.setCode(200); + Assert.assertNotNull(status.getCode()); + Assert.assertEquals(status.getCode(), 200); + } + + @Test + public void testGetMessage() { + status.setMessage("SUCCESS"); + Assert.assertNotNull(status.getMessage()); + Assert.assertEquals(status.getMessage(), "SUCCESS"); + } + + @Test + public void testToString_ReturnNonEmptyString() { + assertNotEquals(status.toString(), ""); + assertNotEquals(status.toString(), null); + } + + @Test + public void testToString_ContainsString() { + assertTrue(status.toString().contains("Status{code")); + } +} diff --git a/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestTransactionRecord.java b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestTransactionRecord.java new file mode 100644 index 000000000..b39c51440 --- /dev/null +++ b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestTransactionRecord.java @@ -0,0 +1,130 @@ +/* +* ============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 TestTransactionRecord { + + private TransactionRecord transactionRecord; + + @Before + public void setUp() { + transactionRecord = new TransactionRecord(); + } + + @Test + public void testGetTransactionId() { + transactionRecord.setTransactionId("1234"); + Assert.assertNotNull(transactionRecord.getTransactionId()); + Assert.assertEquals(transactionRecord.getTransactionId(), "1234"); + } + + @Test + public void testGetRequestId() { + transactionRecord.setRequestId("1298ABC"); + Assert.assertNotNull(transactionRecord.getRequestId()); + Assert.assertEquals(transactionRecord.getRequestId(), "1298ABC"); + } + + @Test + public void testGetSubRequestId() { + transactionRecord.setSubRequestId("1298"); + Assert.assertNotNull(transactionRecord.getSubRequestId()); + Assert.assertEquals(transactionRecord.getSubRequestId(), "1298"); + } + + @Test + public void testGetOriginatorId() { + transactionRecord.setOriginatorId("1111"); + Assert.assertNotNull(transactionRecord.getOriginatorId()); + Assert.assertEquals(transactionRecord.getOriginatorId(), "1111"); + } + + @Test + public void testGetTargetId() { + transactionRecord.setTargetId("2222"); + Assert.assertNotNull(transactionRecord.getTargetId()); + Assert.assertEquals(transactionRecord.getTargetId(), "2222"); + } + + @Test + public void testGetTargetType() { + transactionRecord.setTargetType("A"); + Assert.assertNotNull(transactionRecord.getTargetType()); + Assert.assertEquals(transactionRecord.getTargetType(), "A"); + } + + @Test + public void testGetResultCode() { + transactionRecord.setResultCode(200); + Assert.assertNotNull(transactionRecord.getResultCode()); + Assert.assertEquals(transactionRecord.getResultCode(), 200); + } + + @Test + public void testGetDescription() { + transactionRecord.setDescription("SUCCESS"); + Assert.assertNotNull(transactionRecord.getDescription()); + Assert.assertEquals(transactionRecord.getDescription(), "SUCCESS"); + } + + @Test + public void testGetServiceInstanceId() { + transactionRecord.setServiceInstanceId("A1"); + Assert.assertNotNull(transactionRecord.getServiceInstanceId()); + Assert.assertEquals(transactionRecord.getServiceInstanceId(), "A1"); + } + + @Test + public void testGetVnfcName() { + transactionRecord.setVnfcName("Vnf1"); + Assert.assertNotNull(transactionRecord.getVnfcName()); + Assert.assertEquals(transactionRecord.getVnfcName(), "Vnf1"); + } + + @Test + public void testGetVserverId() { + transactionRecord.setVserverId("V1"); + Assert.assertNotNull(transactionRecord.getVserverId()); + Assert.assertEquals(transactionRecord.getVserverId(), "V1"); + } + + @Test + public void testGetVfModuleId() { + transactionRecord.setVfModuleId("M1"); + Assert.assertNotNull(transactionRecord.getVfModuleId()); + Assert.assertEquals(transactionRecord.getVfModuleId(), "M1"); + } + + @Test + public void testToString_ReturnNonEmptyString() { + assertNotEquals(transactionRecord.toString(), ""); + assertNotEquals(transactionRecord.toString(), null); + } + + @Test + public void testToString_ContainsString() { + assertTrue(transactionRecord.toString().contains("TransactionRecord{transactionId")); + } +} diff --git a/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestVNFContext.java b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestVNFContext.java new file mode 100644 index 000000000..0c4999e20 --- /dev/null +++ b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/test/java/org/onap/appc/domainmodel/lcm/TestVNFContext.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; + +public class TestVNFContext { + + private VNFContext vNFContext; + + @Before + public void setUp() { + vNFContext = new VNFContext(); + } + + @Test + public void testGetId() { + vNFContext.setId("1234AB56"); + Assert.assertNotNull(vNFContext.getId()); + Assert.assertEquals(vNFContext.getId(), "1234AB56"); + } + + @Test + public void testGetType() { + vNFContext.setType("abc"); + Assert.assertNotNull(vNFContext.getType()); + Assert.assertEquals(vNFContext.getType(), "abc"); + } + + @Test + public void testGetVersion() { + vNFContext.setVersion("2.0"); + Assert.assertNotNull(vNFContext.getVersion()); + Assert.assertEquals(vNFContext.getVersion(), "2.0"); + } + + @Test + public void testGetStatus() { + vNFContext.setStatus("200"); + Assert.assertNotNull(vNFContext.getStatus()); + Assert.assertEquals(vNFContext.getStatus(), "200"); + } + + @Test + public void testToString_ReturnNonEmptyString() { + assertNotEquals(vNFContext.toString(), ""); + assertNotEquals(vNFContext.toString(), null); + } + + @Test + public void testToString_ContainsString() { + assertTrue(vNFContext.toString().contains("VNFContext{id")); + } +} -- cgit 1.2.3-korg