From 344d3c36402b1342059a15e49ae7d6485e4de39d Mon Sep 17 00:00:00 2001 From: Soumendu Sekhar Acharya Date: Tue, 7 Aug 2018 17:19:35 +0530 Subject: Epic-231 cbr junit testcase of SDNC-263 JUNIT Testcase for vnfconfigreportsservice Change-Id: I20d92c1514c97e9239b865e0bd3f8e015d538153 Issue-ID: SDNC-413 Signed-off-by: Soumendu Sekhar Acharya Former-commit-id: f88e26e83a56d1db9c105e430cb9c000b95cde9b --- .../service/VnfReportsServiceImplTest.java | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 configbackuprestore/vnfconfigreportsservice/src/test/java/com/onap/sdnc/vnfreportsservice/service/VnfReportsServiceImplTest.java diff --git a/configbackuprestore/vnfconfigreportsservice/src/test/java/com/onap/sdnc/vnfreportsservice/service/VnfReportsServiceImplTest.java b/configbackuprestore/vnfconfigreportsservice/src/test/java/com/onap/sdnc/vnfreportsservice/service/VnfReportsServiceImplTest.java new file mode 100644 index 00000000..e40fb054 --- /dev/null +++ b/configbackuprestore/vnfconfigreportsservice/src/test/java/com/onap/sdnc/vnfreportsservice/service/VnfReportsServiceImplTest.java @@ -0,0 +1,87 @@ +package com.onap.sdnc.vnfreportsservice.service; + +import static org.junit.Assert.*; + +import java.sql.Date; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.onap.sdnc.vnfreportsservice.dao.VnfReportsServiceRepo; +import com.onap.sdnc.vnfreportsservice.model.VnfConfigDetailsDB; + +@RunWith(MockitoJUnitRunner.class) +public class VnfReportsServiceImplTest { + + private static final Logger LOGGER = LoggerFactory.getLogger(VnfReportsServiceImplTest.class); + + @Mock + VnfReportsServiceRepo vnfRepo; + + @InjectMocks + VnfReportsServiceImpl Vnfreportsservice; + + @Test + public void getVnfConfigDetailsBetweenDatesTest() throws Exception{ + VnfConfigDetailsDB db = new VnfConfigDetailsDB(); + db.setId(123); + db.setVnfid("Vnfid"); + db.setVnfname("vnfname"); + db.setVnfversion("vnfversion"); + + Date sDate = new Date(2018, 5, 7); + Date eDate = new Date(2018, 7, 7); + db.setCreationdate(sDate); + db.setLastupdated(eDate); + db.setStatus("status"); + db.setConfiginfo("configinfo"); + + List list = new ArrayList(); + list.add(db); + LOGGER.info("List of vnf config details::" + list); + + + Mockito.when(vnfRepo.findByLastupdatedBetween(sDate, eDate)).thenReturn(list); + + Vnfreportsservice.getVnfConfigDetailsBetweenDates(sDate, eDate); + assertEquals(list, Vnfreportsservice.getVnfConfigDetailsBetweenDates(sDate, eDate)); + + } + + @Test + public void getVnfIdDetailsBetweenDatesTest() throws Exception{ + VnfConfigDetailsDB db = new VnfConfigDetailsDB(); + db.setId(123); + db.setVnfid("Vnfid"); + db.setVnfname("vnfname"); + db.setVnfversion("vnfversion"); + + Date sDate = new Date(2018, 5, 7); + Date eDate = new Date(2018, 7, 7); + db.setCreationdate(sDate); + db.setLastupdated(eDate); + db.setStatus("status"); + db.setConfiginfo("configinfo"); + + List list = new ArrayList(); + list.add(db); + LOGGER.info("List of vnf config details::" + list); + + + Mockito.when(vnfRepo.findByVnfidAndLastupdatedBetween("vnfid",sDate, eDate)).thenReturn(list); + + Vnfreportsservice.getVnfIdDetailsBetweenDates("vnfid" ,sDate, eDate); + assertEquals(list, Vnfreportsservice.getVnfIdDetailsBetweenDates("vnfid",sDate, eDate)); + + } +} + + -- cgit 1.2.3-korg