From aca9c5503b812c9c96aebb408748dc15728f9ad7 Mon Sep 17 00:00:00 2001 From: pvtroshin Date: Thu, 26 May 2011 15:03:23 +0000 Subject: [PATCH] Further work on statistics display 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 | 28 ++++++++++++++++++++ .../stat/servlet/util/StatCollectionTester.java | 9 ++----- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/testsrc/compbio/stat/collector/StatDBTester.java b/testsrc/compbio/stat/collector/StatDBTester.java index 5fcf41a..172a57d 100644 --- a/testsrc/compbio/stat/collector/StatDBTester.java +++ b/testsrc/compbio/stat/collector/StatDBTester.java @@ -13,6 +13,8 @@ import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import compbio.stat.servlet.util.StatCollection; +import compbio.stat.servlet.util.Totals; import compbio.ws.client.Services; public class StatDBTester { @@ -109,4 +111,30 @@ public class StatDBTester { } } + + @Test + public void testVerifyJobsCount() { + + try { + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.MONTH, -5); + Timestamp from = new Timestamp(cal.getTimeInMillis()); + cal.add(Calendar.MONTH, 1); + Timestamp to = new Timestamp(cal.getTimeInMillis()); + StatCollection sc = StatCollection.newStatCollecton(from, to); + Totals t = Totals.sumStats(sc.getAllStat()); + + System.out.println(sc.getAllStat()); + StatDB db = new StatDB(); + assertEquals(t.getTotal(), db.getTotalJobsCount(from, to)); + assertEquals(t.getAbandoned(), db.getAbandonedCount(from, to)); + assertEquals(t.getCancelled(), db.getCancelledCount(from, to)); + assertEquals(t.getIncomplete(), db.getIncompleteCount(from, to)); + + } catch (SQLException e) { + e.printStackTrace(); + Assert.fail(e.getLocalizedMessage()); + } + + } } diff --git a/testsrc/compbio/stat/servlet/util/StatCollectionTester.java b/testsrc/compbio/stat/servlet/util/StatCollectionTester.java index efedb07..830ce05 100644 --- a/testsrc/compbio/stat/servlet/util/StatCollectionTester.java +++ b/testsrc/compbio/stat/servlet/util/StatCollectionTester.java @@ -13,18 +13,13 @@ public class StatCollectionTester { @Test public void testGetStats() { - Map stats; + Map stats; Calendar cal = GregorianCalendar.getInstance(); - cal.add(Calendar.DAY_OF_MONTH, -25); + cal.add(Calendar.MONTH, -3); try { stats = StatCollection.getStats(cal.getTime()); - // System.out.println(stats); - for (Map.Entry a : StatCollection - .getTotalStats(stats).entrySet()) { - System.out.println(a); - } } catch (SQLException e) { e.printStackTrace(); Assert.fail(e.getMessage()); -- 1.7.10.2