use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class MongoIndexRangeServiceTest method testHandleIndexReopening.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testHandleIndexReopening() throws Exception {
final DateTime begin = new DateTime(2016, 1, 1, 0, 0, DateTimeZone.UTC);
final DateTime end = new DateTime(2016, 1, 15, 0, 0, DateTimeZone.UTC);
when(indices.indexRangeStatsOfIndex("graylog_3")).thenReturn(IndexRangeStats.create(begin, end));
when(indexSetRegistry.isManagedIndex("graylog_3")).thenReturn(true);
localEventBus.post(IndicesReopenedEvent.create(Collections.singleton("graylog_3")));
final SortedSet<IndexRange> indexRanges = indexRangeService.find(begin, end);
assertThat(indexRanges).hasSize(1);
assertThat(indexRanges.first().indexName()).isEqualTo("graylog_3");
assertThat(indexRanges.first().begin()).isEqualTo(begin);
assertThat(indexRanges.first().end()).isEqualTo(end);
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterConfigServiceImplTest method listIgnoresInvalidClasses.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void listIgnoresInvalidClasses() throws Exception {
final DBCollection collection = mongoConnection.getDatabase().getCollection(COLLECTION_NAME);
collection.save(new BasicDBObjectBuilder().add("type", CustomConfig.class.getCanonicalName()).add("payload", Collections.singletonMap("text", "TEST")).add("last_updated", TIME.toString()).add("last_updated_by", "ID").get());
collection.save(new BasicDBObjectBuilder().add("type", "invalid.ClassName").add("payload", Collections.emptyMap()).add("last_updated", TIME.toString()).add("last_updated_by", "ID").get());
assertThat(collection.count()).isEqualTo(2L);
assertThat(clusterConfigService.list()).hasSize(1).containsOnly(CustomConfig.class);
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterConfigServiceImplTest method writePersistsClusterConfig.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void writePersistsClusterConfig() throws Exception {
CustomConfig customConfig = new CustomConfig();
customConfig.text = "TEST";
final DBCollection collection = mongoConnection.getDatabase().getCollection(COLLECTION_NAME);
assertThat(collection.count()).isEqualTo(0L);
clusterConfigService.write(customConfig);
assertThat(collection.count()).isEqualTo(1L);
DBObject dbObject = collection.findOne();
assertThat((String) dbObject.get("type")).isEqualTo(CustomConfig.class.getCanonicalName());
assertThat((String) dbObject.get("last_updated_by")).isEqualTo("ID");
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterConfigServiceImplTest method writeIgnoresNull.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void writeIgnoresNull() throws Exception {
final DBCollection collection = mongoConnection.getDatabase().getCollection(COLLECTION_NAME);
assertThat(collection.count()).isEqualTo(0L);
clusterConfigService.write(null);
assertThat(collection.count()).isEqualTo(0L);
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterConfigServiceImplTest method prepareCollectionCreatesCollectionIfItDoesNotExist.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void prepareCollectionCreatesCollectionIfItDoesNotExist() throws Exception {
assertThat(mongoConnection.getDatabase().collectionExists(COLLECTION_NAME)).isFalse();
DBCollection collection = ClusterConfigServiceImpl.prepareCollection(mongoConnection);
assertThat(collection.getName()).isEqualTo(COLLECTION_NAME);
assertThat(collection.getIndexInfo()).hasSize(2);
assertThat(collection.getWriteConcern()).isEqualTo(WriteConcern.JOURNALED);
}
Aggregations