use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterConfigServiceImplTest method removeDoesNothingIfConfigDoesNotExist.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void removeDoesNothingIfConfigDoesNotExist() throws Exception {
final DBCollection collection = mongoConnection.getDatabase().getCollection(COLLECTION_NAME);
assertThat(collection.count()).isEqualTo(0L);
assertThat(clusterConfigService.remove(CustomConfig.class)).isEqualTo(0);
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterConfigServiceImplTest method writeUpdatesExistingClusterConfig.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void writeUpdatesExistingClusterConfig() throws Exception {
CustomConfig customConfig = new CustomConfig();
customConfig.text = "TEST";
DBObject seedObject = new BasicDBObjectBuilder().add("type", CustomConfig.class.getCanonicalName()).add("payload", Collections.singletonMap("text", "ORIGINAL")).add("last_updated", TIME.toString()).add("last_updated_by", "NOT ID").get();
final DBCollection collection = mongoConnection.getDatabase().getCollection(COLLECTION_NAME);
collection.save(seedObject);
assertThat(collection.count()).isEqualTo(1L);
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");
@SuppressWarnings("unchecked") Map<String, Object> payload = (Map<String, Object>) dbObject.get("payload");
assertThat(payload).containsEntry("text", "TEST");
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class AlarmCallbackConfigurationServiceImplTest method testGetForStreamSingleDocument.
@Test
@UsingDataSet(locations = "alarmCallbackConfigurationsSingleDocument.json", loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testGetForStreamSingleDocument() throws Exception {
final Stream stream = mock(StreamImpl.class);
final String streamId = "5400deadbeefdeadbeefaffe";
when(stream.getId()).thenReturn(streamId);
final List<AlarmCallbackConfiguration> configs = alarmCallbackConfigurationService.getForStream(stream);
final AlarmCallbackConfiguration alarmCallback = configs.get(0);
assertNotNull("Returned list should not be null", configs);
assertEquals("Returned list should contain a single document", 1, configs.size());
assertNotNull("Returned Alarm Callback should not be null", alarmCallback);
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class AlertServiceImplTest method loadRecentOfStreamsLimitsResults.
@Test
@UsingDataSet(locations = "multiple-alerts.json")
public void loadRecentOfStreamsLimitsResults() throws Exception {
final List<Alert> alerts = alertService.loadRecentOfStreams(ImmutableList.of("5666df42bee80072613ce14d", "5666df42bee80072613ce14e", "5666df42bee80072613ce14f"), new DateTime(0L, DateTimeZone.UTC), 1);
assertThat(alerts.size()).isEqualTo(1);
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class AlertServiceImplTest method loadRecentOfStreamQueriesByDate.
@Test
@UsingDataSet(locations = "multiple-alerts.json")
public void loadRecentOfStreamQueriesByDate() throws Exception {
final List<Alert> alerts = alertService.loadRecentOfStream(STREAM_ID, new DateTime(0L, DateTimeZone.UTC), 300);
assertThat(alerts.size()).isEqualTo(2);
}
Aggregations