Further work on statistics display
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Thu, 26 May 2011 15:03:23 +0000 (15:03 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Thu, 26 May 2011 15:03:23 +0000 (15:03 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4174 e3abac25-378b-4346-85de-24260fe3988d

testsrc/compbio/stat/collector/StatDBTester.java
testsrc/compbio/stat/servlet/util/StatCollectionTester.java

index 5fcf41a..172a57d 100644 (file)
@@ -13,6 +13,8 @@ import org.testng.Assert;
 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
@@ -109,4 +111,30 @@ public class StatDBTester {
                }\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
index efedb07..830ce05 100644 (file)
@@ -13,18 +13,13 @@ public class StatCollectionTester {
 \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