use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class LegacyMongoIndexRangeServiceTest method testGetExistingIndexRange.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testGetExistingIndexRange() throws Exception {
final IndexRange indexRange = indexRangeService.get("graylog_0");
final DateTime end = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
final IndexRange expected = MongoIndexRange.create(new ObjectId("56250da2d400000000000001"), "graylog_0", EPOCH, end, end, 0);
assertThat(indexRange).isEqualTo(expected);
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class LegacyMongoIndexRangeServiceTest method testFindAll.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testFindAll() throws Exception {
final SortedSet<IndexRange> indexRanges = indexRangeService.findAll();
final DateTime end0 = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
final DateTime end1 = new DateTime(2015, 1, 2, 0, 0, 0, 0, DateTimeZone.UTC);
final DateTime end2 = new DateTime(2015, 1, 3, 0, 0, 0, 0, DateTimeZone.UTC);
final DateTime end99 = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
assertThat(indexRanges).containsExactly(MongoIndexRange.create(new ObjectId("56250da2d400000000000001"), "graylog_0", EPOCH, end0, end0, 0), MongoIndexRange.create(new ObjectId("56250da2d400000000000099"), "graylog_99", EPOCH, end99, EPOCH, 0), MongoIndexRange.create(new ObjectId("56250da2d400000000000002"), "graylog_1", EPOCH, end1, end1, 1), MongoIndexRange.create(new ObjectId("56250da2d400000000000003"), "graylog_2", EPOCH, end2, end2, 2));
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class MongoIndexSetServiceTest method getReturnsAbsentOptionalIfIndexSetConfigDoesNotExist.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void getReturnsAbsentOptionalIfIndexSetConfigDoesNotExist() throws Exception {
final Optional<IndexSetConfig> indexSetConfig = indexSetService.get(new ObjectId("57f3d3f0a43c2d595eb0a348"));
assertThat(indexSetConfig).isEmpty();
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class MongoIndexSetServiceTest method deleteRemovesExistingIndexSetConfig.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void deleteRemovesExistingIndexSetConfig() throws Exception {
final IndexSetDeletedSubscriber subscriber = new IndexSetDeletedSubscriber();
clusterEventBus.registerClusterEventSubscriber(subscriber);
final int deletedEntries = indexSetService.delete(new ObjectId("57f3d721a43c2d59cb750001"));
assertThat(deletedEntries).isEqualTo(1);
assertThat(indexSetService.get("57f3d721a43c2d59cb750001")).isEmpty();
assertThat(subscriber.getEvents()).hasSize(1).containsExactly(IndexSetDeletedEvent.create("57f3d721a43c2d59cb750001"));
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterEventPeriodicalTest method publishClusterEventHandlesAutoValueCorrectly.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void publishClusterEventHandlesAutoValueCorrectly() throws Exception {
DBCollection collection = mongoConnection.getDatabase().getCollection(ClusterEventPeriodical.COLLECTION_NAME);
DebugEvent event = DebugEvent.create("Node ID", "Test");
assertThat(collection.count()).isEqualTo(0L);
clusterEventPeriodical.publishClusterEvent(event);
verify(clusterEventBus, never()).post(any());
assertThat(collection.count()).isEqualTo(1L);
DBObject dbObject = collection.findOne();
assertThat((String) dbObject.get("producer")).isEqualTo(nodeId.toString());
assertThat((String) dbObject.get("event_class")).isEqualTo(DebugEvent.class.getCanonicalName());
}
Aggregations