use of org.ff4j.audit.chart.TimeSeriesChart in project ff4j by ff4j.
the class AbstractEventRepositoryTest method testGetFeatureUsageHistory.
@Test
public void testGetFeatureUsageHistory() throws InterruptedException {
long start = System.currentTimeMillis();
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 - 20, System.currentTimeMillis());
TimeSeriesChart tsc = repo.getFeatureUsageHistory(testQuery, TimeUnit.HOURS);
Assert.assertEquals(1, tsc.getTimeSlots().size());
}
use of org.ff4j.audit.chart.TimeSeriesChart in project ff4j by ff4j.
the class AuditBeanTest method testTimeSerieChart.
@Test
public void testTimeSerieChart() {
long top = System.currentTimeMillis();
TimeSeriesChart t1 = new TimeSeriesChart(top - 100000, top + 100000, TimeUnit.MINUTES);
new TimeSeriesChart(top - 100000, top + 100000, TimeUnit.HOURS);
new TimeSeriesChart(top - 100000, top + 100000, TimeUnit.DAYS);
new TimeSeriesChart(top - 100000, top + 100000, TimeUnit.SECONDS);
t1.addEvent(new EventBuilder().name("f1").build());
t1.addEvent(new EventBuilder().name("f2").build());
Assert.assertNotNull(t1.getSdf());
Assert.assertNotNull(t1.toString());
TimeSeriesChart tsc1 = new TimeSeriesChart();
tsc1.setSdf(new SimpleDateFormat("yyyy"));
tsc1.setTimeSlots(new ArrayList<String>());
tsc1.setSeries(new HashMap<String, Serie<Map<String, MutableHitCount>>>());
Assert.assertNotNull(tsc1);
}
use of org.ff4j.audit.chart.TimeSeriesChart in project ff4j by ff4j.
the class EventRepositoryRedis method getFeatureUsageHistory.
/**
* {@inheritDoc}
*/
@Override
public TimeSeriesChart getFeatureUsageHistory(EventQueryDefinition query, TimeUnit tu) {
TimeSeriesChart tsc = new TimeSeriesChart(query.getFrom(), query.getTo(), tu);
Set<String> events = getEventsFromRedis(query);
for (String event : events) {
tsc.addEvent(marshallEvent(event));
}
return tsc;
}
use of org.ff4j.audit.chart.TimeSeriesChart in project ff4j by ff4j.
the class EventRepositoryTestSupport method testGetFeatureUsageHistory.
@Test
public void testGetFeatureUsageHistory() throws InterruptedException {
long start = System.currentTimeMillis();
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 - 20, System.currentTimeMillis());
TimeSeriesChart tsc = repo.getFeatureUsageHistory(testQuery, TimeUnit.HOURS);
Assert.assertEquals(1, tsc.getTimeSlots().size());
}
use of org.ff4j.audit.chart.TimeSeriesChart in project ff4j by ff4j.
the class EventRepositoryHBase method getFeatureUsageHistory.
/**
* {@inheritDoc}
*/
@Override
public TimeSeriesChart getFeatureUsageHistory(EventQueryDefinition query, TimeUnit units) {
// Create the interval depending on units
TimeSeriesChart tsc = new TimeSeriesChart(query.getFrom(), query.getTo(), units);
// Search All events
Iterator<Event> iterEvent = searchFeatureUsageEvents(query).iterator();
// Dispatch events into time slots
while (iterEvent.hasNext()) {
tsc.addEvent(iterEvent.next());
}
return tsc;
}
Aggregations