use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.
the class AbstractEventRepositoryTest method testUserHitCount.
/**
* TDD.
*/
@Test
public void testUserHitCount() throws InterruptedException {
long start = System.currentTimeMillis();
// When
for (int i = 0; i < 8; i++) {
Event e1 = new Event(SOURCE_JAVA, TARGET_FEATURE, "f1", ACTION_CHECK_OK);
e1.setUser("JOHN");
repo.saveEvent(e1);
Thread.sleep(100);
Event e2 = new Event(SOURCE_JAVA, TARGET_FEATURE, "f1", ACTION_CHECK_OK);
e2.setUser("BOB");
repo.saveEvent(e2);
Thread.sleep(100);
}
Thread.sleep(200);
// Then
EventQueryDefinition testQuery = new EventQueryDefinition(start - 20, System.currentTimeMillis());
Map<String, MutableHitCount> mapOfHit = repo.getUserHitCount(testQuery);
Assert.assertEquals(2, mapOfHit.size());
Assert.assertTrue(mapOfHit.containsKey("JOHN"));
Assert.assertTrue(mapOfHit.containsKey("BOB"));
Assert.assertEquals(8, mapOfHit.get("BOB").get());
}
use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.
the class AbstractEventRepositoryTest method testFeatureUsageHitCount.
@Test
public void testFeatureUsageHitCount() throws InterruptedException {
long start = System.currentTimeMillis();
// Create Event
repo.saveEvent(new Event(SOURCE_JAVA, TARGET_FEATURE, "f1", EventConstants.ACTION_CREATE));
for (int i = 0; i < 8; i++) {
Thread.sleep(100);
repo.saveEvent(new Event(SOURCE_JAVA, TARGET_FEATURE, "f1", EventConstants.ACTION_CHECK_OK));
repo.saveEvent(new Event(SOURCE_WEB, TARGET_FEATURE, "f2", EventConstants.ACTION_CHECK_OK));
}
Thread.sleep(100);
// Assert bar chart (2 bars with 8 and 8)
EventQueryDefinition testQuery = new EventQueryDefinition(start, System.currentTimeMillis());
// Assert Pie Chart (2 sectors with 8 and 8)
Map<String, MutableHitCount> mapOfHit = repo.getFeatureUsageHitCount(testQuery);
Assert.assertEquals(2, mapOfHit.size());
Assert.assertTrue(mapOfHit.containsKey("f1"));
Assert.assertTrue(mapOfHit.containsKey("f2"));
Assert.assertEquals(8, mapOfHit.get("f1").get());
}
Aggregations