import org.testng.annotations.BeforeClass;\r
import org.testng.annotations.Test;\r
\r
+import compbio.stat.servlet.util.StatCollection;\r
+import compbio.stat.servlet.util.Totals;\r
import compbio.ws.client.Services;\r
\r
public class StatDBTester {\r
}\r
\r
}\r
+\r
+ @Test\r
+ public void testVerifyJobsCount() {\r
+\r
+ try {\r
+ Calendar cal = Calendar.getInstance();\r
+ cal.add(Calendar.MONTH, -5);\r
+ Timestamp from = new Timestamp(cal.getTimeInMillis());\r
+ cal.add(Calendar.MONTH, 1);\r
+ Timestamp to = new Timestamp(cal.getTimeInMillis());\r
+ StatCollection sc = StatCollection.newStatCollecton(from, to);\r
+ Totals t = Totals.sumStats(sc.getAllStat());\r
+\r
+ System.out.println(sc.getAllStat());\r
+ StatDB db = new StatDB();\r
+ assertEquals(t.getTotal(), db.getTotalJobsCount(from, to));\r
+ assertEquals(t.getAbandoned(), db.getAbandonedCount(from, to));\r
+ assertEquals(t.getCancelled(), db.getCancelledCount(from, to));\r
+ assertEquals(t.getIncomplete(), db.getIncompleteCount(from, to));\r
+\r
+ } catch (SQLException e) {\r
+ e.printStackTrace();\r
+ Assert.fail(e.getLocalizedMessage());\r
+ }\r
+\r
+ }\r
}\r
\r
@Test\r
public void testGetStats() {\r
- Map<Date, StatCollection> stats;\r
+ Map<Date, Totals> stats;\r
Calendar cal = GregorianCalendar.getInstance();\r
- cal.add(Calendar.DAY_OF_MONTH, -25);\r
+ cal.add(Calendar.MONTH, -3);\r
\r
try {\r
stats = StatCollection.getStats(cal.getTime());\r
\r
- // System.out.println(stats);\r
- for (Map.Entry<Date, Totals> a : StatCollection\r
- .getTotalStats(stats).entrySet()) {\r
- System.out.println(a);\r
- }\r
} catch (SQLException e) {\r
e.printStackTrace();\r
Assert.fail(e.getMessage());\r