Improved statistics tests.

This commit is contained in:
Christian P. MOMON 2018-05-16 10:55:35 +02:00
parent cf119c5b92
commit f5b34cdc27
3 changed files with 373 additions and 23 deletions

View File

@ -18,11 +18,16 @@
*/
package org.april.hebdobot.model.stats;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class ReviewStatReporter.
*/
public class ReviewStatsReporter
{
private static final Logger logger = LoggerFactory.getLogger(ReviewStatsReporter.class);
/**
* Instantiates a new review stat reporter.
*/
@ -93,7 +98,7 @@ public class ReviewStatsReporter
{
board.add(data.getDuration());
}
System.out.println("Duration board: " + board.toString());
logger.debug("Duration board: " + board.toString());
IntegerStat stat = board.get(currentDuration);
int total = board.getCountSum();
@ -154,7 +159,7 @@ public class ReviewStatsReporter
{
board.add(data.getUserCount());
}
System.out.println("User count board: " + board.toString());
logger.debug("User count board: " + board.toString());
IntegerStat stat = board.get(currentUserCount);
int total = board.getCountSum();

View File

@ -22,30 +22,25 @@ package org.april.hebdobot.reviewstats;
import java.io.File;
import java.time.LocalDateTime;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.BasicConfigurator;
import org.april.hebdobot.model.stats.ReviewData;
import org.april.hebdobot.model.stats.ReviewDatas;
import org.april.hebdobot.model.stats.ReviewDatasFile;
import org.april.hebdobot.model.stats.ReviewStatsReporter;
import org.junit.Before;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class BotMock.
* The Class ReviewStatsTest.
*/
public class ReviewStatsTest
{
private static final Logger logger = LoggerFactory.getLogger(ReviewStatsTest.class);
@Before
public void init()
{
BasicConfigurator.configure();
logger.info("Basic log configuration done.");
}
/**
* Test load.
*
@ -56,7 +51,7 @@ public class ReviewStatsTest
public void testLoad() throws Exception
{
System.out.println("================");
ReviewDatas datas = ReviewDatasFile.load(new File("resources/reviewstats.csv"));
ReviewDatas datas = ReviewDatasFile.load(new File("test/org/april/hebdobot/reviewstats/reviewstats.csv"));
for (ReviewData data : datas)
{
@ -74,29 +69,53 @@ public class ReviewStatsTest
public void testReportDuration() throws Exception
{
System.out.println("================");
ReviewDatas datas = ReviewDatasFile.load(new File("resources/reviewstats.csv"));
ReviewDatas datas = ReviewDatasFile.load(new File("test/org/april/hebdobot/reviewstats/reviewstats.csv"));
datas.clean();
System.out.println("File loaded.");
logger.debug("File loaded.");
ReviewData currentReview = new ReviewData(LocalDateTime.now(), 12, 17);
datas.add(currentReview);
System.out.println(ReviewStatsReporter.reportDuration(datas, currentReview.getDuration()));
String report = ReviewStatsReporter.reportDuration(datas, currentReview.getDuration());
logger.debug("Report=" + report);
Assert.assertTrue(StringUtils.contains(report,
"Statistiques sur la durée de la revue (17 mn) : position 3 (min=14 mn,moy=17,2 mn,max=20 mn), fréquence 7/14 (50 %)"));
}
/**
* Test report new max user count.
* Test report new max user count 01.
*
* @throws Exception
* the exception
*/
@Test
public void testReportNewMaxUserCount() throws Exception
public void testReportNewMaxUserCount01() throws Exception
{
System.out.println("================");
ReviewDatas datas = ReviewDatasFile.load(new File("resources/reviewstats.csv"));
ReviewDatas datas = ReviewDatasFile.load(new File("test/org/april/hebdobot/reviewstats/reviewstats.csv"));
datas.clean();
System.out.println("File loaded.");
logger.debug("File loaded.");
ReviewData currentReview = new ReviewData(LocalDateTime.now(), 12, 17);
System.out.println(ReviewStatsReporter.reportNewMaxUserCount(datas, currentReview.getUserCount()));
String report = ReviewStatsReporter.reportNewMaxUserCount(datas, currentReview.getUserCount());
logger.debug("Report=" + report);
Assert.assertTrue(StringUtils.startsWith(report, "Pas de nouveau record"));
}
/**
* Test report new max user count 02.
*
* @throws Exception
* the exception
*/
@Test
public void testReportNewMaxUserCount02() throws Exception
{
System.out.println("================");
ReviewDatas datas = ReviewDatasFile.load(new File("test/org/april/hebdobot/reviewstats/reviewstats.csv"));
datas.clean();
logger.debug("File loaded.");
ReviewData currentReview = new ReviewData(LocalDateTime.now(), 42000, 17);
String report = ReviewStatsReporter.reportNewMaxUserCount(datas, currentReview.getUserCount());
logger.debug("Report=" + report);
Assert.assertTrue(StringUtils.startsWith(report, "Nouveau record"));
}
/**
@ -109,11 +128,24 @@ public class ReviewStatsTest
public void testReportUserCount() throws Exception
{
System.out.println("================");
ReviewDatas datas = ReviewDatasFile.load(new File("resources/reviewstats.csv"));
ReviewDatas datas = ReviewDatasFile.load(new File("test/org/april/hebdobot/reviewstats/reviewstats.csv"));
datas.clean();
System.out.println("File loaded.");
logger.debug("File loaded.");
ReviewData currentReview = new ReviewData(LocalDateTime.now(), 12, 17);
datas.add(currentReview);
System.out.println(ReviewStatsReporter.reportUserCount(datas, currentReview.getUserCount()));
String report = ReviewStatsReporter.reportUserCount(datas, currentReview.getUserCount());
logger.debug("Report=" + report);
Assert.assertTrue(StringUtils.equals(report,
"Statistiques sur le nombre de participants (12) : position 3 (min=2,moy=6,6,max=14), fréquence 4/312 (1 %)"));
}
/**
* Inits the.
*/
@BeforeClass
public static void init()
{
BasicConfigurator.configure();
logger.info("Basic log configuration done.");
}
}

View File

@ -0,0 +1,313 @@
20110930-12h00 6
20111007-12h00 6
20111014-12h00 8
20111021-12h00 5
20111028-12h00 10
20111104-12h00 8
20111111-12h00 3
20111118-12h00 7
20111125-12h00 7
20111202-12h00 7
20111209-12h00 3
20111216-12h00 7
20111223-12h00 7
20111230-12h00 7
20120106-12h00 8
20120113-12h00 6
20120120-12h00 7
20120217-12h00 8
20120302-12h00 10
20120309-12h00 8
20120316-12h00 3
20120323-12h00 6
20120330-12h00 6
20120406-12h00 7
20120413-12h00 7
20120420-12h00 5
20120504-12h00 8
20120511-12h00 6
20120518-12h00 4
20120525-12h00 7
20120601-12h00 3
20120608-12h00 6
20120615-12h00 7
20120622-12h00 9
20120629-12h00 4
20120706-12h00 6
20120720-12h00 8
20120727-12h00 5
20120803-12h00 6
20120810-12h00 6
20120817-12h00 6
20120824-12h00 8
20120831-12h00 10
20120907-12h00 12
20120914-12h00 8
20120921-12h00 4
20120928-12h00 8
20121012-12h00 6
20121019-12h00 7
20121026-12h00 7
20121102-12h00 8
20121109-12h00 7
20121116-12h00 8
20121123-12h00 5
20121130-12h00 13
20121207-12h00 10
20121214-12h00 14
20121221-12h00 10
20121228-12h00 4
20130104-12h00 7
20130111-12h00 6
20130118-12h00 10
20130125-12h00 10
20130201-12h00 8
20130208-12h00 11
20130215-12h00 6
20130222-12h00 7
20130301-12h00 8
20130308-12h00 4
20130315-12h00 6
20130322-12h00 4
20130329-12h00 7
20130405-12h00 10
20130412-12h00 8
20130419-12h00 6
20130426-12h00 5
20130503-12h00 8
20130510-12h00 3
20130517-12h00 8
20130524-12h00 9
20130531-12h00 7
20130607-12h00 8
20130614-12h00 9
20130628-12h00 9
20130705-12h00 9
20130712-12h00 7
20130719-12h00 11
20130726-12h00 7
20130802-12h00 11
20130809-12h00 10
20130816-12h00 6
20130823-12h00 6
20130830-12h00 6
20130906-12h00 11
20130913-12h00 8
20130920-12h00 6
20130927-12h00 6
20131004-12h00 3
20131011-12h00 5
20131018-12h00 5
20131025-12h00 3
20131101-12h00 6
20131108-12h00 4
20131115-12h00 3
20131122-12h00 6
20131129-12h00 2
20131206-12h00 6
20131213-12h00 5
20131220-12h00 2
20131227-12h00 5
20140103-12h00 4
20140110-12h00 5
20140117-12h00 8
20140124-12h00 6
20140131-12h00 7
20140207-12h00 5
20140214-12h00 6
20140221-12h00 6
20140228-12h00 8
20140307-12h00 5
20140314-12h00 6
20140321-12h00 5
20140328-12h00 6
20140404-12h00 6
20140411-12h00 5
20140418-12h00 6
20140425-12h00 5
20140502-12h00 5
20140509-12h00 6
20140516-12h00 4
20140523-12h00 2
20140613-12h00 6
20140620-12h00 4
20140627-12h00 5
20140704-12h00 6
20140711-12h00 7
20140718-12h00 7
20140725-12h00 3
20140801-12h00 6
20140808-12h00 5
20140822-12h00 4
20140829-12h00 7
20140905-12h00 6
20140912-12h00 5
20140919-12h00 5
20140926-12h00 3
20141010-12h00 5
20141017-12h00 7
20141024-12h00 6
20141031-12h00 6
20141107-12h00 3
20141114-12h00 7
20141121-12h00 7
20141128-12h00 6
20141205-12h00 7
20141212-12h00 7
20141219-12h00 6
20150109-12h00 4
20150116-12h00 1
20150123-12h00 4
20150130-12h00 6
20150206-12h00 4
20150213-12h00 2
20150220-12h00 7
20150227-12h00 4
20150306-12h00 11
20150313-12h00 10
20150320-12h00 8
20150327-12h00 5
20150403-12h00 6
20150410-12h00 8
20150417-12h00 4
20150424-12h00 3
20150507-12h00 5
20150515-12h00 8
20150522-12h00 7
20150529-12h00 5
20150605-12h00 10
20150612-12h00 6
20150619-12h00 3
20150626-12h00 5
20150703-12h00 5
20150710-12h00 5
20150717-12h00 6
20150724-12h00 7
20150731-12h00 5
20150807-12h00 4
20150814-12h00 4
20150828-12h00 5
20150904-12h00 5
20150918-12h00 6
20150925-12h00 5
20151002-12h00 7
20151009-12h00 5
20151016-12h00 8
20151023-12h00 6
20151030-12h00 8
20151106-12h00 5
20151113-12h00 9
20151120-12h00 9
20151127-12h00 7
20151204-12h00 10
20151211-12h00 7
20151218-12h00 10
20160108-12h00 8
20160219-12h00 6
20160226-12h00 9
20160318-12h00 6
20160401-12h00 6
20160408-12h00 8
20160415-12h00 6
20160422-12h00 7
20160429-12h00 7
20160506-12h00 7
20160513-12h00 6
20160520-12h00 6
20160527-12h00 8
20160603-12h00 3
20160610-12h00 4
20160617-12h00 7
20160624-12h00 6
20160701-12h00 6
20160708-12h00 7
20160715-12h00 4
20160722-12h00 6
20160805-12h00 4
20160812-12h00 3
20160819-12h00 4
20160826-12h00 4
20160902-12h00 6
20160909-12h00 7
20160916-12h00 7
20160923-12h00 7
20160930-12h00 4
20161007-12h00 6
20161021-12h00 7
20161028-12h00 6
20161104-12h00 7
20161110-12h00 7
20161118-12h00 7
20161125-12h00 7
20161202-12h00 4
20161209-12h00 7
20161216-12h00 9
20161223-12h00 5
20170106-12h00 7
20170113-12h00 4
20170120-12h00 8
20170127-12h00 7
20170203-12h00 6
20170210-12h00 6
20170217-12h00 8
20170224-12h00 8
20170303-12h00 7
20170310-12h00 7
20170317-12h00 4
20170324-12h00 6
20170331-12h00 5
20170407-12h00 4
20170414-12h00 4
20170421-12h00 9
20170428-12h00 7
20170505-12h00 6
20170512-12h00 7
20170519-12h00 6
20170526-12h00 5
20170602-12h00 8
20170609-12h00 10
20170616-12h00 9
20170623-12h00 7
20170630-12h00 5
20170707-12h00 12
20170713-12h00 4
20170721-12h00 6
20170727-12h00 6
20170818-12h00 5
20170825-12h00 3
20170901-12h00 6
20170908-12h00 5
20170915-12h00 7
20170922-12h00 5
20170929-12h00 10
20171006-12h00 9
20171013-12h00 9
20171020-12h00 7
20171027-12h00 8
20171103-12h00 10
20171110-12h00 10
20171117-12h00 8
20171124-12h00 8
20171201-12h00 9
20171208-12h00 10
20171215-12h00 11
20171222-12h00 7
20180105-12h00 7
20180112-12h00 10
20180118-12h00 1
20180119-12h00 12
20180126-12h00 10
20180202-12h00 9
20180209-12h00 8 17
20180216-12h00 8 16
20180223-12h00 5 14
20180302-12h00 6 19
20180309-12h00 11 20
20180316-12h00 9 19
20180323-12h00 9 17
20180330-12h00 10 19
20180406-12h00 9 17
20180413-12h00 11 15
20180420-12h00 6 17
20180427-12h00 7 17
20180504-12h00 7 17
Can't render this file because it has a wrong number of fields in line 62.