@Test
 public void testPurgeTablesCumul() throws Exception {
   MockConnection connexion = factory.getMockConnection();
   SilverStatisticsManagerDAO.purgeTablesCumul(connexion, typeofStat, config);
   module.verifyAllStatementsClosed();
   Calendar calend = Calendar.getInstance();
   calend.add(Calendar.YEAR, -10);
   String date =
       SilverStatisticsManagerDAO.getRequestDate(
           calend.get(Calendar.YEAR), calend.get(Calendar.MONTH) + 1);
   List<?> statements = module.getPreparedStatements();
   assertNotNull(statements);
   assertThat(statements, hasSize(1));
   MockPreparedStatement pstmt = module.getPreparedStatement(0);
   assertThat(pstmt.getSQL(), is("DELETE FROM SB_Stat_SizeDirCumul WHERE dateStat<" + date));
   Map parameters = pstmt.getParameterMap();
   assertThat(parameters.size(), is(0));
 }
 @Test
 public void testDeleteTablesOfTheDay() throws Exception {
   MockConnection connexion = factory.getMockConnection();
   SilverStatisticsManagerDAO.deleteTablesOfTheDay(connexion, typeofStat, config);
   module.verifyAllStatementsClosed();
   List<?> statements = module.getPreparedStatements();
   assertNotNull(statements);
   assertThat(statements, hasSize(1));
   MockPreparedStatement pstmt = module.getPreparedStatement(0);
   assertThat(pstmt.getSQL(), is("DELETE FROM SB_Stat_SizeDir"));
   Map parameters = pstmt.getParameterMap();
   assertThat(parameters.size(), is(0));
 }
 @Test
 public void testInsertDataCumul() throws Exception {
   MockConnection connexion = factory.getMockConnection();
   List<String> data = Arrays.asList("2011-04-17", "/var/data/silverpeas/kmelia72", "262");
   SilverStatisticsManagerDAO.insertDataStatsCumul(connexion, typeofStat, data, config);
   module.verifyAllStatementsClosed();
   List<?> statements = module.getPreparedStatements();
   assertNotNull(statements);
   assertThat(statements, hasSize(1));
   MockPreparedStatement pstmt = module.getPreparedStatement(0);
   assertThat(
       pstmt.getSQL(),
       is("INSERT INTO SB_Stat_SizeDirCumul(dateStat,fileDir,sizeDir) " + "VALUES(?,?,?)"));
   Map parameters = pstmt.getParameterMap();
   assertThat(parameters.size(), is(3));
   assertThat((String) parameters.get(1), is("2011-04-01"));
   assertThat((String) parameters.get(2), is("/var/data/silverpeas/kmelia72"));
   assertThat((Long) parameters.get(3), is(262L));
 }
 @Test
 public void testMakeStatCumulWithoutExistingData() throws Exception {
   MockConnection connexion = factory.getMockConnection();
   StatementResultSetHandler statementHandler = connexion.getStatementResultSetHandler();
   statementHandler.setExactMatch(true);
   MockResultSet result = statementHandler.createResultSet();
   result.addColumn("dateStat", new Object[] {"2011-04-17"});
   result.addColumn("fileDir", new Object[] {"/var/data/silverpeas/kmelia36"});
   result.addColumn("sizeDir", new Object[] {543L});
   statementHandler.prepareResultSet("SELECT * FROM SB_Stat_SizeDir", result);
   MockResultSet cumulResult = statementHandler.createResultSet();
   statementHandler.prepareResultSet(
       "SELECT dateStat,fileDir,sizeDir FROM SB_Stat_SizeDirCumul "
           + "WHERE dateStat='2011-04-01' AND fileDir='/var/data/silverpeas/kmelia36'",
       cumulResult);
   SilverStatisticsManagerDAO.makeStatCumul(connexion, typeofStat, config);
   module.verifyAllStatementsClosed();
   List<?> statements = module.getExecutedSQLStatements();
   assertNotNull(statements);
   assertThat(statements.size(), is(3));
   List<?> preparedStatements = module.getPreparedStatements();
   assertNotNull(preparedStatements);
   assertThat(preparedStatements, hasSize(2));
   MockPreparedStatement pstmt = module.getPreparedStatement(0);
   assertThat(
       pstmt.getSQL(),
       is(
           "UPDATE SB_Stat_SizeDirCumul SET sizeDir=?  WHERE "
               + "dateStat='2011-04-01' AND fileDir='/var/data/silverpeas/kmelia36'"));
   Map parameters = pstmt.getParameterMap();
   assertThat(parameters.size(), is(0));
   pstmt = module.getPreparedStatement(1);
   assertThat(
       pstmt.getSQL(),
       is("INSERT INTO SB_Stat_SizeDirCumul(dateStat,fileDir,sizeDir) " + "VALUES(?,?,?)"));
   parameters = pstmt.getParameterMap();
   assertThat(parameters.size(), is(3));
   assertThat((String) parameters.get(1), is("2011-04-01"));
   assertThat((String) parameters.get(2), is("/var/data/silverpeas/kmelia36"));
   assertThat((Long) parameters.get(3), is(543L));
 }