Search in sources :

Example 11 with EventQueryDefinition

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);
}
Also used : JdbcQueryBuilder(org.ff4j.store.JdbcQueryBuilder) EventQueryDefinition(org.ff4j.audit.EventQueryDefinition) Test(org.junit.Test)

Example 12 with EventQueryDefinition

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());
}
Also used : TimeSeriesChart(org.ff4j.audit.chart.TimeSeriesChart) EventQueryDefinition(org.ff4j.audit.EventQueryDefinition) Event(org.ff4j.audit.Event) Test(org.junit.Test)

Example 13 with EventQueryDefinition

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
}
Also used : EventQueryDefinition(org.ff4j.audit.EventQueryDefinition) EventSeries(org.ff4j.audit.EventSeries) Event(org.ff4j.audit.Event) Test(org.junit.Test)

Example 14 with EventQueryDefinition

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));
}
Also used : EventQueryDefinition(org.ff4j.audit.EventQueryDefinition) Test(org.junit.Test)

Example 15 with EventQueryDefinition

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;
}
Also used : EventQueryDefinition(org.ff4j.audit.EventQueryDefinition) ParseException(java.text.ParseException) Date(java.util.Date)

Aggregations

EventQueryDefinition (org.ff4j.audit.EventQueryDefinition)31 Test (org.junit.Test)25 Event (org.ff4j.audit.Event)22 MutableHitCount (org.ff4j.audit.MutableHitCount)8 BarChart (org.ff4j.audit.chart.BarChart)3 TimeSeriesChart (org.ff4j.audit.chart.TimeSeriesChart)3 Date (java.util.Date)2 EventSeries (org.ff4j.audit.EventSeries)2 ParseException (java.text.ParseException)1 PieChart (org.ff4j.audit.chart.PieChart)1 EventRepository (org.ff4j.audit.repository.EventRepository)1 JdbcQueryBuilder (org.ff4j.store.JdbcQueryBuilder)1