aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dt5972@att.com>2018-08-24 19:29:14 +0000
committerGerrit Code Review <gerrit@onap.org>2018-08-24 19:29:14 +0000
commitabbe24de644c755ec883b85bbb72d74bc2ef412f (patch)
treeebd068cb3eab635ff2a38de70ce0e0b73caef9a2
parent2445fbdffde4d5125778360db55dbfd5c9fcff8d (diff)
parent344d3c36402b1342059a15e49ae7d6485e4de39d (diff)
Merge "Epic-231 cbr junit testcase of SDNC-263"
Former-commit-id: ddae2ce39b40e04fba13b9d99c39fad02b10e20e
-rw-r--r--configbackuprestore/vnfconfigreportsservice/src/test/java/com/onap/sdnc/vnfreportsservice/service/VnfReportsServiceImplTest.java87
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));
+
+ }
+}
+
+