assertThat(db.countClass(DefaultTimeline.DB_CLASS), equalTo(6L));
}
underTest.purgeOlderThan(2);
// ensure 1st returned entry is the latest (and still exists on timeline)
underTest.retrieve(0, 1, null, null, null, new TimelineCallback()
{
public boolean processNext(final Entry rec) throws IOException {
assertThat(rec.getType(), equalTo("TEST"));
assertThat(rec.getSubType(), equalTo("2"));
assertThat(rec.getData().get("day"), equalTo("3"));
return false;
}
});
try (ODatabaseDocumentTx db = underTest.openDb()) {
partitionsPostPurge1 = Lists.newArrayList(Collections2.filter(db.getClusterNames(), new Predicate<String>()
{
@Override
public boolean apply(String input) {
return input.startsWith(DefaultTimeline.DB_CLUSTER_PREFIX);
}
}));
assertThat(db.countClass(DefaultTimeline.DB_CLASS), equalTo(4L));
}
underTest.purgeOlderThan(1);
// ensure 1st returned entry is the latest (and still exists on timeline)
underTest.retrieve(0, 1, null, null, null, new TimelineCallback()
{
public boolean processNext(final Entry rec) throws IOException {
assertThat(rec.getType(), equalTo("TEST"));
assertThat(rec.getSubType(), equalTo("2"));
assertThat(rec.getData().get("day"), equalTo("3"));
return false;
}
});
try (ODatabaseDocumentTx db = underTest.openDb()) {
partitionsPostPurge2 = Lists.newArrayList(Collections2.filter(db.getClusterNames(), new Predicate<String>()
{
@Override
public boolean apply(String input) {
return input.startsWith(DefaultTimeline.DB_CLUSTER_PREFIX);
}
}));
assertThat(db.countClass(DefaultTimeline.DB_CLASS), equalTo(2L));
}
underTest.purgeOlderThan(0);
// ensure that timeline is empty, callback should not be called
underTest.retrieve(0, 1, null, null, null, new TimelineCallback()
{
public boolean processNext(final Entry rec) throws IOException {
assertThat("Timeline should be empty. callback should not be invoked!", false);
return false;
}