use of org.ff4j.audit.EventQueryDefinition in project ff4j by ff4j.
the class FeatureUsageController method get.
/**
* {@inheritDoc}
*/
public void get(HttpServletRequest req, HttpServletResponse res, WebContext ctx) throws Exception {
createPage(ctx, new EventQueryDefinition());
LOGGER.info("Display feature usage");
}
use of org.ff4j.audit.EventQueryDefinition in project ff4j by ff4j.
the class EventRepositoryTestSupport method testFeatureUsageHitCount.
/**
* TDD.
*/
@Test
public void testFeatureUsageHitCount() throws InterruptedException {
long start = System.currentTimeMillis();
// Given empty event repository
// When
repo.saveEvent(new Event(SOURCE_JAVA, TARGET_FEATURE, "f1", ACTION_CREATE));
for (int i = 0; i < 8; i++) {
Thread.sleep(100);
repo.saveEvent(new Event(SOURCE_JAVA, TARGET_FEATURE, "f1", ACTION_CHECK_OK));
repo.saveEvent(new Event(SOURCE_WEB, TARGET_FEATURE, "f2", ACTION_CHECK_OK));
}
Thread.sleep(100);
// Then
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());
}
use of org.ff4j.audit.EventQueryDefinition in project ff4j by ff4j.
the class EventRepositoryTestSupport method testSaveAuditTrail.
/**
* TDD.
*/
@Test
public void testSaveAuditTrail() throws InterruptedException {
long start = System.currentTimeMillis();
// Given
Event evt1 = new Event(SOURCE_JAVA, TARGET_FEATURE, "f1", EventConstants.ACTION_CREATE);
// When
repo.saveEvent(evt1);
// Wait for the event to be effectively store
Thread.sleep(200);
EventQueryDefinition eqd2 = new EventQueryDefinition(start - 200, System.currentTimeMillis());
Assert.assertEquals(1, repo.getAuditTrail(eqd2).size());
}
use of org.ff4j.audit.EventQueryDefinition in project ff4j by ff4j.
the class EventRepositoryTestSupport method testHostHitCount.
/**
* TDD.
*/
@Test
public void testHostHitCount() throws InterruptedException {
long start = System.currentTimeMillis();
// When
for (int i = 0; i < 8; i++) {
Thread.sleep(100);
repo.saveEvent(new Event(SOURCE_JAVA, TARGET_FEATURE, "f1", ACTION_CHECK_OK));
}
Thread.sleep(200);
// Then
EventQueryDefinition testQuery = new EventQueryDefinition(start, System.currentTimeMillis());
Map<String, MutableHitCount> mapOfHit = repo.getHostHitCount(testQuery);
Assert.assertEquals(1, mapOfHit.size());
Assert.assertEquals(1, mapOfHit.values().size());
}
use of org.ff4j.audit.EventQueryDefinition in project ff4j by ff4j.
the class EventRepositoryTestSupport method testFeatureUsageBarCharts.
/**
* TDD.
*/
@Test
public void testFeatureUsageBarCharts() throws InterruptedException {
long start = System.currentTimeMillis();
// Given empty event repository
// When
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", ACTION_CHECK_OK));
repo.saveEvent(new Event(SOURCE_WEB, TARGET_FEATURE, "f2", ACTION_CHECK_OK));
}
// Then : Assert bar chart (2 bars with 8 and 8)
EventQueryDefinition testQuery = new EventQueryDefinition(start - 10, System.currentTimeMillis() + 10);
BarChart bChart = repo.getFeatureUsageBarChart(testQuery);
Assert.assertEquals(2, bChart.getChartBars().size());
Assert.assertEquals(new Integer(8), bChart.getChartBars().get(0).getValue());
Assert.assertEquals(new Integer(8), bChart.getChartBars().get(1).getValue());
Assert.assertNotNull(bChart.getChartBars().get(0).getColor());
Assert.assertNotNull(bChart.getChartBars().get(1).getColor());
}
Aggregations