diff options
author | Soumendu Sekhar Acharya <SA00498080@techmahindra.com> | 2018-08-07 17:19:35 +0530 |
---|---|---|
committer | Soumendu Sekhar Acharya <SA00498080@techmahindra.com> | 2018-08-24 14:32:40 +0000 |
commit | 344d3c36402b1342059a15e49ae7d6485e4de39d (patch) | |
tree | 935d6511e899b7089afced4afcba8f39ed71703a /configbackuprestore | |
parent | 46cb2d3a105021fe4aeed8aa462c31ce50bad39f (diff) |
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 <SA00498080@techmahindra.com>
Former-commit-id: f88e26e83a56d1db9c105e430cb9c000b95cde9b
Diffstat (limited to 'configbackuprestore')
-rw-r--r-- | configbackuprestore/vnfconfigreportsservice/src/test/java/com/onap/sdnc/vnfreportsservice/service/VnfReportsServiceImplTest.java | 87 |
1 files changed, 87 insertions, 0 deletions
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<VnfConfigDetailsDB> list = new ArrayList<VnfConfigDetailsDB>(); + 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<VnfConfigDetailsDB> list = new ArrayList<VnfConfigDetailsDB>(); + 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)); + + } +} + + |