use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class MongoIndexSetServiceTest method deleteRemovesExistingIndexSetConfig.
@Test
@MongoDBFixtures("MongoIndexSetServiceTest.json")
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 org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class V20161215163900_MoveIndexSetDefaultConfigTest method upgrade.
@Test
@MongoDBFixtures("V20161215163900_MoveIndexSetDefaultConfigTest.json")
public void upgrade() throws Exception {
final long count = collection.count();
migration.upgrade();
final MigrationCompleted migrationCompleted = clusterConfigService.get(MigrationCompleted.class);
assertThat(collection.count()).withFailMessage("No document should be deleted by the migration!").isEqualTo(count);
assertThat(collection.count(Filters.exists("default"))).withFailMessage("The migration should have deleted the \"default\" field from the documents!").isEqualTo(0L);
assertThat(clusterConfigService.get(DefaultIndexSetConfig.class)).withFailMessage("The DefaultIndexSetConfig should have been written to cluster config!").isNotNull();
assertThat(clusterConfigService.get(DefaultIndexSetConfig.class).defaultIndexSetId()).isEqualTo("57f3d721a43c2d59cb750001");
assertThat(migrationCompleted).isNotNull();
assertThat(migrationCompleted.indexSetIds()).containsExactlyInAnyOrder("57f3d721a43c2d59cb750001", "57f3d721a43c2d59cb750003");
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class MongoInputStatusServiceTest method handleDeleteEvent_WhenDeletingInputRemovesState.
@Test
@MongoDBFixtures("input-status.json")
public void handleDeleteEvent_WhenDeletingInputRemovesState() throws Exception {
final String deletedInput = "54e3deadbeefdeadbeef0001";
final InputDeleted inputDeletedEvent = new InputDeleted() {
@Override
public String id() {
return deletedInput;
}
};
// Simulate that the input has actually been deleted
// TODO: This will change once we fix https://github.com/Graylog2/graylog2-server/issues/7812
when(inputService.find(deletedInput)).thenThrow(new NotFoundException());
cut.handleInputDeleted(inputDeletedEvent);
// The record should be removed from the DB
assertThat(cut.get(deletedInput).isPresent(), is(false));
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class OutputServiceImplTest method loadReturnsExistingOutput.
@Test
@MongoDBFixtures("OutputServiceImplTest.json")
public void loadReturnsExistingOutput() throws NotFoundException {
final Output output = outputService.load("54e3deadbeefdeadbeef0001");
assertThat(output.getId()).isEqualTo("54e3deadbeefdeadbeef0001");
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class OutputServiceImplTest method updatingOutputIsPersistent.
@Test
@MongoDBFixtures("single-output.json")
public void updatingOutputIsPersistent() throws Exception {
final String outputId = "5b927d32a7c8644ed44576ed";
final Output newOutput = outputService.update(outputId, Collections.singletonMap("title", "Some other Title"));
assertThat(newOutput.getTitle()).isEqualTo("Some other Title");
final Output retrievedOutput = outputService.load(outputId);
assertThat(retrievedOutput.getTitle()).isEqualTo("Some other Title");
}
Aggregations