use of org.ff4j.audit.EventQueryDefinition in project ff4j by ff4j.
the class JdbcFeatureStoreCoreTest method testQueryBuilder.
@Test
public void testQueryBuilder() {
JdbcQueryBuilder builder = new JdbcQueryBuilder();
builder.getFeatureDistributionAudit();
EventQueryDefinition eqd = new EventQueryDefinition();
builder.getPurgeFeatureUsageQuery(eqd);
builder.getSelectFeatureUsageQuery(eqd);
builder.getPurgeAuditTrailQuery(eqd);
builder.removeFeatureFromGroup();
builder.deleteRoles();
builder.getFeatureProperty();
builder.getEventByUuidQuery();
builder.getHostHitCount();
builder.getUserHitCount();
builder.getSourceHitCount();
EventQueryDefinition e1 = new EventQueryDefinition();
builder.buildWhereClause(e1, true, false);
builder.buildWhereClause(e1, false, false);
e1.getHostFilters().add("localhost");
e1.getNamesFilter().add("aaa");
e1.getSourceFilters().add("java");
builder.buildWhereClause(e1, true, false);
}
use of org.ff4j.audit.EventQueryDefinition 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.EventQueryDefinition in project ff4j by ff4j.
the class EventRepositoryTestSupport method testSearchFeatureUsageEvents.
@Test
public void testSearchFeatureUsageEvents() 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());
EventSeries es = repo.searchFeatureUsageEvents(testQuery);
Assert.assertEquals(16, es.size());
// Then
}
use of org.ff4j.audit.EventQueryDefinition in project ff4j by ff4j.
the class CassandraTest method testCassandraQueryBuilder.
@Test
public void testCassandraQueryBuilder() {
CassandraConnection cc = new CassandraConnection();
CassandraQueryBuilder cqb = new CassandraQueryBuilder(cc);
// Mapping with a whole set of filters
EventQueryDefinition eqd = new EventQueryDefinition();
eqd.addFilterAction(EventConstants.ACTION_CLEAR);
eqd.addFilterHost("localhost");
eqd.addFilterName("TOTO");
eqd.addFilterName("TATA");
eqd.addFilterSource("JAVA");
// Create dedicated
Assert.assertNotNull(cqb.cqlUserHitCount(eqd));
Assert.assertNotNull(cqb.cqlCreateEvent(20));
}
use of org.ff4j.audit.EventQueryDefinition in project ff4j by ff4j.
the class AbstractController method buildQuery.
protected EventQueryDefinition buildQuery(HttpServletRequest req) {
EventQueryDefinition edf = new EventQueryDefinition();
try {
Date from = SDFSLOT.parse(req.getParameter("slotfrom"));
Date to = SDFSLOT.parse(req.getParameter("slotto"));
edf = new EventQueryDefinition(from.getTime(), to.getTime());
} catch (ParseException pe) {
// Nothing to raise, use default values.
}
return edf;
}
Aggregations