use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class OutputFacadeTest method delete.
@Test
@MongoDBFixtures("OutputFacadeTest.json")
public void delete() throws NotFoundException {
final Output output = outputService.load("5adf239e4b900a0fdb4e5197");
assertThat(outputService.count()).isEqualTo(1L);
facade.delete(output);
assertThat(outputService.count()).isEqualTo(0L);
assertThatThrownBy(() -> outputService.load("5adf239e4b900a0fdb4e5197")).isInstanceOf(NotFoundException.class);
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class V20180718155800_AddContentPackIdAndRevTest method upgrade.
@Test
@MongoDBFixtures("V20180718155800_AddContentPackIdAndRevTest.json")
public void upgrade() {
final MongoCollection<Document> collection = mongodb.mongoConnection().getMongoDatabase().getCollection(ContentPackPersistenceService.COLLECTION_NAME);
final Bson filter = and(exists(ContentPack.FIELD_META_ID), exists(ContentPack.FIELD_META_REVISION));
assertThat(collection.count(filter)).isEqualTo(1L);
migration.upgrade();
assertThat(collection.count(filter)).isEqualTo(2L);
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class DashboardV1FacadeTest method viewDTOShouldHaveACorrectViewState.
@Test
@MongoDBFixtures("DashboardV1FacadeTest.json")
public void viewDTOShouldHaveACorrectViewState() {
assertThat(viewDTO.type()).isEqualByComparingTo(ViewDTO.Type.DASHBOARD);
assertThat(viewDTO.state()).isNotNull();
assertThat(viewDTO.state().size()).isEqualTo(1);
ViewStateDTO viewState = viewDTO.state().values().iterator().next();
assertThat(viewState.widgets().size()).isEqualTo(12);
final Set<String> widgetIds = viewState.widgets().stream().map(WidgetDTO::id).collect(Collectors.toSet());
final Set<String> widgetPositionIds = viewState.widgetPositions().keySet();
assertThat(widgetIds).containsAll(widgetPositionIds);
widgetIds.forEach(widgetId -> assertThat(viewState.titles().widgetTitle(widgetId)).isPresent());
widgetIds.forEach(widgetId -> assertThat(viewState.widgetMapping().get(widgetId)).isNotEmpty());
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class InputFacadeTest method resolveNativeEntityGrokPattern.
@Test
@MongoDBFixtures("InputFacadeTest.json")
public void resolveNativeEntityGrokPattern() throws NotFoundException {
final Input input = inputService.find("5ae2ebbeef27464477f0fd8b");
EntityDescriptor entityDescriptor = EntityDescriptor.create(ModelId.of(input.getId()), ModelTypes.INPUT_V1);
EntityDescriptor expectedDescriptor = EntityDescriptor.create(ModelId.of("1"), ModelTypes.GROK_PATTERN_V1);
Graph<EntityDescriptor> graph = facade.resolveNativeEntity(entityDescriptor);
assertThat(graph.nodes()).contains(expectedDescriptor);
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class InputFacadeTest method exportEntity.
@Test
@MongoDBFixtures("InputFacadeTest.json")
public void exportEntity() {
final ModelId id = ModelId.of("5acc84f84b900a4ff290d9a7");
final EntityDescriptor descriptor = EntityDescriptor.create(id, ModelTypes.INPUT_V1);
final EntityDescriptorIds entityDescriptorIds = EntityDescriptorIds.of(descriptor);
final Entity entity = facade.exportEntity(descriptor, entityDescriptorIds).orElseThrow(AssertionError::new);
assertThat(entity).isInstanceOf(EntityV1.class);
assertThat(entity.id()).isEqualTo(ModelId.of(entityDescriptorIds.get(descriptor).orElse(null)));
assertThat(entity.type()).isEqualTo(ModelTypes.INPUT_V1);
final EntityV1 entityV1 = (EntityV1) entity;
final InputEntity inputEntity = objectMapper.convertValue(entityV1.data(), InputEntity.class);
assertThat(inputEntity.title()).isEqualTo(ValueReference.of("Local Raw UDP"));
assertThat(inputEntity.type()).isEqualTo(ValueReference.of("org.graylog2.inputs.raw.udp.RawUDPInput"));
assertThat(inputEntity.global()).isEqualTo(ValueReference.of(false));
assertThat(inputEntity.configuration()).containsEntry("bind_address", ValueReference.of("127.0.0.1")).containsEntry("port", ValueReference.of(5555));
}
Aggregations