@Test
public void getContribStatsSingleTarget() {
PersonDAO personDAO = seam.autowire(PersonDAO.class);
// Initial state = needReview
HTextFlowTarget target = textFlowTargetDAO.findById(2L);
int wordCount = target.getTextFlow().getWordCount().intValue();
String todayDate = formatter.format(today);
String username = "demo";
HPerson demoPerson = personDAO.findByUsername(username);
ContributionStatistics initialStats =
statisticsService.getContributionStatistics(
"sample-project", "1.0", username, todayDate + ".."
+ todayDate);
BaseTranslationCount stats =
initialStats.get(username).get(target.getLocaleId());
// Should have no stats for user on today
assertNull(stats);
// needReview -> approved
ContributionStatistics expectedStats = new ContributionStatistics();
expectedStats.put(username, buildStats(target.getLocaleId(), 0, 0, 0,
wordCount, 0));
target = executeStateChangeTest(target, "test1", ContentState.Approved,
demoPerson, expectedStats);
// approved -> approved
target = executeStateChangeTest(target, "test2", ContentState.Approved,
demoPerson, expectedStats);
// approved -> approved
target = executeStateChangeTest(target, "test3", ContentState.Approved,
demoPerson, expectedStats);
// approved -> needReview
expectedStats.put(username, buildStats(target.getLocaleId(), 0,
wordCount, 0, wordCount, 0));
target = executeStateChangeTest(target, "test4",
ContentState.NeedReview, demoPerson, expectedStats);
// needReview -> new
expectedStats.put(username, buildStats(target.getLocaleId(), wordCount,
wordCount, 0, wordCount, 0));
target = executeStateChangeTest(target, "", ContentState.New,
demoPerson, expectedStats);
}