From 7c6cab072dc153b5b3b00cadf50525605410f91e Mon Sep 17 00:00:00 2001
From: Aditya Bhansali <adityab3@illinois.edu>
Date: Thu, 19 Nov 2020 06:09:11 -0600
Subject: [PATCH] [tests] Added tests for new time method in DiagnosisDAO

---
 .../unit/dao/officevisit/OVDiagnosesTest.java | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/iTrust/test/edu/ncsu/csc/itrust/unit/dao/officevisit/OVDiagnosesTest.java b/iTrust/test/edu/ncsu/csc/itrust/unit/dao/officevisit/OVDiagnosesTest.java
index 69ef1e5..85071d5 100644
--- a/iTrust/test/edu/ncsu/csc/itrust/unit/dao/officevisit/OVDiagnosesTest.java
+++ b/iTrust/test/edu/ncsu/csc/itrust/unit/dao/officevisit/OVDiagnosesTest.java
@@ -168,6 +168,50 @@ public class OVDiagnosesTest extends TestCase {
             fail("Expected exception.");
         } catch (IllegalArgumentException e) { }
     }
+
+    public void testGetCountForWeekBeforeRolling() throws Exception {
+        TestDataGenerator gen = new TestDataGenerator();
+        gen.malaria_epidemic2();
+
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(new SimpleDateFormat("MM/dd/yyyy").parse("11/01/2000"));
+
+        gen.malaria_epidemic2();
+        System.out.println(cal.getTime());
+        assertEquals(0, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.DATE, 1);
+        System.out.println(cal.getTime());
+        assertEquals(1, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(2, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(3, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(4, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(5, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(6, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(7, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(7, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(7, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(7, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(7, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(7, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(7, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(7, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+        assertEquals(6, diagDAO.getCountForWeekBefore("84.5", "27606", cal.getTime()).getRegionStats());
+        cal.add(Calendar.HOUR, 24);
+    }
 	
 	/**
 	 * testMalaria
-- 
GitLab