use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class LegacyMongoIndexRangeServiceTest method testGetIncompleteIndexRange.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testGetIncompleteIndexRange() throws Exception {
final IndexRange indexRange = indexRangeService.get("graylog_99");
final DateTime end = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
final IndexRange expected = MongoIndexRange.create(new ObjectId("56250da2d400000000000099"), "graylog_99", EPOCH, end, EPOCH, 0);
assertThat(indexRange).isEqualTo(expected);
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class MongoIndexSetServiceTest method deleteWithAssignedStreams.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void deleteWithAssignedStreams() throws Exception {
final IndexSetDeletedSubscriber subscriber = new IndexSetDeletedSubscriber();
clusterEventBus.registerClusterEventSubscriber(subscriber);
final FakeStream stream1 = new FakeStream("Test stream 1");
final String streamId = "57f3d721a43c2d59cb750001";
stream1.setIndexSetId(streamId);
when(streamService.loadAllWithIndexSet(streamId)).thenReturn(Collections.singletonList(stream1));
final int deletedEntries = indexSetService.delete(streamId);
assertThat(deletedEntries).isEqualTo(0);
assertThat(indexSetService.get(streamId)).isPresent();
assertThat(indexSetService.findAll()).hasSize(2);
assertThat(subscriber.getEvents()).isEmpty();
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class MongoIndexSetServiceTest method getReturnsExistingIndexSetConfig.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void getReturnsExistingIndexSetConfig() throws Exception {
final Optional<IndexSetConfig> indexSetConfig = indexSetService.get(new ObjectId("57f3d721a43c2d59cb750001"));
assertThat(indexSetConfig).isPresent().contains(IndexSetConfig.create("57f3d721a43c2d59cb750001", "Test 1", "This is the index set configuration for Test 1", true, "test_1", 4, 1, MessageCountRotationStrategy.class.getCanonicalName(), MessageCountRotationStrategyConfig.create(1000), NoopRetentionStrategy.class.getCanonicalName(), NoopRetentionStrategyConfig.create(10), ZonedDateTime.of(2016, 10, 4, 17, 0, 0, 0, ZoneOffset.UTC), "standard", "test_1", 1, false));
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterEventCleanupPeriodicalTest method testDoRun.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void testDoRun() throws Exception {
final DBCollection collection = mongoConnection.getDatabase().getCollection(ClusterEventPeriodical.COLLECTION_NAME);
assertThat(insertEvent(collection, 0L)).isTrue();
assertThat(insertEvent(collection, TIME.getMillis())).isTrue();
assertThat(insertEvent(collection, TIME.minus(ClusterEventCleanupPeriodical.DEFAULT_MAX_EVENT_AGE).getMillis())).isTrue();
assertThat(insertEvent(collection, TIME.minus(2 * ClusterEventCleanupPeriodical.DEFAULT_MAX_EVENT_AGE).getMillis())).isTrue();
assertThat(collection.count()).isEqualTo(4L);
clusterEventCleanupPeriodical.run();
assertThat(collection.count()).isEqualTo(2L);
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterEventPeriodicalTest method publishClusterEventSkipsDeadEvent.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void publishClusterEventSkipsDeadEvent() throws Exception {
DBCollection collection = mongoConnection.getDatabase().getCollection(ClusterEventPeriodical.COLLECTION_NAME);
DeadEvent event = new DeadEvent(clusterEventBus, new SimpleEvent("test"));
assertThat(collection.count()).isEqualTo(0L);
clusterEventPeriodical.publishClusterEvent(event);
verify(clusterEventBus, never()).post(any());
assertThat(collection.count()).isEqualTo(0L);
}
Aggregations