use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class MongoIndexRangeServiceTest method findIgnoresLegacyIndexRanges.
@Test
@UsingDataSet(locations = "MongoIndexRangeServiceTest-LegacyIndexRanges.json", loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void findIgnoresLegacyIndexRanges() throws Exception {
final DateTime begin = new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC);
final DateTime end = new DateTime(2015, 2, 1, 0, 0, DateTimeZone.UTC);
final SortedSet<IndexRange> indexRanges = indexRangeService.find(begin, end);
assertThat(indexRanges).containsOnly(MongoIndexRange.create(new ObjectId("55e0261a0cc6980000000003"), "graylog_1", new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC), 42));
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterConfigServiceImplTest method getOrDefaultReturnsDefaultValueOnNonExistingConfig.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void getOrDefaultReturnsDefaultValueOnNonExistingConfig() throws Exception {
final DBCollection collection = mongoConnection.getDatabase().getCollection(COLLECTION_NAME);
assertThat(collection.count()).isEqualTo(0L);
CustomConfig defaultValue = new CustomConfig();
defaultValue.text = "DEFAULT";
assertThat(clusterConfigService.getOrDefault(CustomConfig.class, defaultValue)).isSameAs(defaultValue);
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterConfigServiceImplTest method getReturnsNullOnInvalidPayload.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void getReturnsNullOnInvalidPayload() throws Exception {
DBObject dbObject = new BasicDBObjectBuilder().add("type", CustomConfig.class.getCanonicalName()).add("payload", "wrong payload").add("last_updated", TIME.toString()).add("last_updated_by", "ID").get();
final DBCollection collection = mongoConnection.getDatabase().getCollection(COLLECTION_NAME);
collection.save(dbObject);
assertThat(collection.count()).isEqualTo(1L);
assertThat(clusterConfigService.get(CustomConfig.class)).isNull();
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterConfigServiceImplTest method getWithKeyReturnsExistingConfig.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void getWithKeyReturnsExistingConfig() throws Exception {
DBObject dbObject = new BasicDBObjectBuilder().add("type", "foo").add("payload", Collections.singletonMap("text", "TEST")).add("last_updated", TIME.toString()).add("last_updated_by", "ID").get();
final DBCollection collection = mongoConnection.getDatabase().getCollection(COLLECTION_NAME);
collection.save(dbObject);
assertThat(collection.count()).isEqualTo(1L);
CustomConfig customConfig = clusterConfigService.get("foo", CustomConfig.class);
assertThat(customConfig).isInstanceOf(CustomConfig.class);
assertThat(customConfig.text).isEqualTo("TEST");
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterConfigServiceImplTest method removeSuccessfullyRemovesConfig.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void removeSuccessfullyRemovesConfig() throws Exception {
DBObject dbObject = new BasicDBObjectBuilder().add("type", CustomConfig.class.getCanonicalName()).add("payload", Collections.singletonMap("text", "TEST")).add("last_updated", TIME.toString()).add("last_updated_by", "ID").get();
final DBCollection collection = mongoConnection.getDatabase().getCollection(COLLECTION_NAME);
collection.save(dbObject);
assertThat(collection.count()).isEqualTo(1L);
assertThat(clusterConfigService.remove(CustomConfig.class)).isEqualTo(1);
assertThat(collection.count()).isEqualTo(0L);
}
Aggregations