TimeLineAuditDBHelper extends AuditDBHelper { public int getTimeGroup() { return timeGroup; } TimeLineAuditDBHelper(ClientConfig config, String startTime,
                               String endTime); @Override String getSelectStmtForRetrieve(Filter filter, GroupBy groupBy); int getTimeGroup(); static final String TIMEBUCKET; static final SimpleDateFormat auditDateFormatter; }
@Test public void testTimeGroup() { ClientConfig conf = ClientConfig.loadFromClasspath(AuditDBConstants.FEEDER_CONF_FILE); TimeLineAuditDBHelper helper = new TimeLineAuditDBHelper(conf, "01-01-2014-00:00", "03-01-2014-00:00"); Assert.assertEquals(60 * 60000, helper.getTimeGroup()); helper = new TimeLineAuditDBHelper(conf, "01-01-2014-00:00", "06-01-2014-00:00"); Assert.assertEquals(120 * 60000, helper.getTimeGroup()); helper = new TimeLineAuditDBHelper(conf, "01-01-2014-00:00", "13-01-2014-00:00"); Assert.assertEquals(240 * 60000, helper.getTimeGroup()); helper = new TimeLineAuditDBHelper(conf, "01-01-2014-00:00", "20-01-2014-00:00"); Assert.assertEquals(360 * 60000, helper.getTimeGroup()); helper = new TimeLineAuditDBHelper(conf, "01-01-2014-00:00", "27-01-2014-00:00"); Assert.assertEquals(480 * 60000, helper.getTimeGroup()); helper = new TimeLineAuditDBHelper(conf, "01-01-2014-00:00", "15-02-2014-00:00"); Assert.assertEquals(720 * 60000, helper.getTimeGroup()); helper = new TimeLineAuditDBHelper(conf, "01-01-2014-00:00", "03-03-2014-00:00"); Assert.assertEquals(1440 * 60000, helper.getTimeGroup()); conf.set(TimeLineAuditDBHelper.TIMEBUCKET, "180"); helper = new TimeLineAuditDBHelper(conf, "01-01-2014-00:00", "06-01-2014-00:00"); Assert.assertEquals(180 * 60000, helper.getTimeGroup()); helper = new TimeLineAuditDBHelper(conf, "01-01-2014-00:00", "23-01-2014-00:00"); Assert.assertEquals(480 * 60000, helper.getTimeGroup()); conf.set(TimeLineAuditDBHelper.TIMEBUCKET, "60"); helper = new TimeLineAuditDBHelper(conf, "01/01/2014-00:00", "23-01-2014-00:00"); Assert.assertNotNull(helper.getTimeGroup()); Assert.assertEquals(60 * 60000, helper.getTimeGroup()); }