use of org.ff4j.audit.EventQueryDefinition in project ff4j by ff4j.
the class AbstractEventRepositoryTest method testPurgeEvents.
/**
* TDD.
*/
@Test
public void testPurgeEvents() throws InterruptedException {
// Given, 2 events in the repo
long topStart = System.currentTimeMillis();
Event evtAudit = new Event(SOURCE_JAVA, TARGET_FEATURE, "f1", ACTION_CREATE);
evtAudit.setUuid("1234-5678-9012-3456");
Event evtFeatureUsage = new Event(SOURCE_JAVA, TARGET_FEATURE, "f2", ACTION_CHECK_OK);
evtFeatureUsage.setUuid("1234-5678-9012-3457");
repo.saveEvent(evtAudit);
repo.saveEvent(evtFeatureUsage);
Thread.sleep(100);
Assert.assertNotNull(repo.getEventByUUID(evtAudit.getUuid(), System.currentTimeMillis()));
Assert.assertNotNull(repo.getEventByUUID(evtFeatureUsage.getUuid(), System.currentTimeMillis()));
// When
EventQueryDefinition testQuery = new EventQueryDefinition(topStart - 100, System.currentTimeMillis());
repo.purgeFeatureUsage(testQuery);
Assert.assertNull(repo.getEventByUUID(evtFeatureUsage.getUuid(), System.currentTimeMillis()));
Assert.assertTrue(repo.searchFeatureUsageEvents(testQuery).isEmpty());
// Then
EventQueryDefinition testQuery2 = new EventQueryDefinition(topStart - 100, System.currentTimeMillis());
repo.purgeAuditTrail(testQuery2);
Assert.assertNull(repo.getEventByUUID(evtAudit.getUuid(), System.currentTimeMillis()));
}
Aggregations