Search in sources :

Example 66 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class LookupDataAdapterFacadeTest method resolveEntityDescriptor.

@Test
@MongoDBFixtures("LookupDataAdapterFacadeTest.json")
public void resolveEntityDescriptor() {
    final EntityDescriptor descriptor = EntityDescriptor.create("5adf24a04b900a0fdb4e52c8", ModelTypes.LOOKUP_ADAPTER_V1);
    final Graph<EntityDescriptor> graph = facade.resolveNativeEntity(descriptor);
    assertThat(graph.nodes()).containsOnly(descriptor);
}
Also used : EntityDescriptor(org.graylog2.contentpacks.model.entities.EntityDescriptor) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 67 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class LookupDataAdapterFacadeTest method exportEntityDescriptor.

@Test
@MongoDBFixtures("LookupDataAdapterFacadeTest.json")
public void exportEntityDescriptor() {
    final EntityDescriptor descriptor = EntityDescriptor.create("5adf24a04b900a0fdb4e52c8", ModelTypes.LOOKUP_ADAPTER_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.LOOKUP_ADAPTER_V1);
    final EntityV1 entityV1 = (EntityV1) entity;
    final LookupDataAdapterEntity lookupDataAdapterEntity = objectMapper.convertValue(entityV1.data(), LookupDataAdapterEntity.class);
    assertThat(lookupDataAdapterEntity.name()).isEqualTo(ValueReference.of("http-dsv"));
    assertThat(lookupDataAdapterEntity.title()).isEqualTo(ValueReference.of("HTTP DSV"));
    assertThat(lookupDataAdapterEntity.description()).isEqualTo(ValueReference.of("HTTP DSV"));
}
Also used : EntityV1(org.graylog2.contentpacks.model.entities.EntityV1) EntityDescriptor(org.graylog2.contentpacks.model.entities.EntityDescriptor) NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) Entity(org.graylog2.contentpacks.model.entities.Entity) LookupDataAdapterEntity(org.graylog2.contentpacks.model.entities.LookupDataAdapterEntity) LookupDataAdapterEntity(org.graylog2.contentpacks.model.entities.LookupDataAdapterEntity) EntityDescriptorIds(org.graylog2.contentpacks.EntityDescriptorIds) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 68 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class OutputFacadeTest method exportNativeEntity.

@Test
@MongoDBFixtures("OutputFacadeTest.json")
public void exportNativeEntity() throws NotFoundException {
    final Output output = outputService.load("5adf239e4b900a0fdb4e5197");
    final EntityDescriptor descriptor = EntityDescriptor.create(output.getId(), ModelTypes.OUTPUT_V1);
    final EntityDescriptorIds entityDescriptorIds = EntityDescriptorIds.of(descriptor);
    final Entity entity = facade.exportNativeEntity(output, entityDescriptorIds);
    assertThat(entity).isInstanceOf(EntityV1.class);
    assertThat(entity.id()).isEqualTo(ModelId.of(entityDescriptorIds.get(descriptor).orElse(null)));
    assertThat(entity.type()).isEqualTo(ModelTypes.OUTPUT_V1);
    final EntityV1 entityV1 = (EntityV1) entity;
    final OutputEntity outputEntity = objectMapper.convertValue(entityV1.data(), OutputEntity.class);
    assertThat(outputEntity.title()).isEqualTo(ValueReference.of("STDOUT"));
    assertThat(outputEntity.type()).isEqualTo(ValueReference.of("org.graylog2.outputs.LoggingOutput"));
    assertThat(outputEntity.configuration()).containsEntry("prefix", ValueReference.of("Writing message: "));
}
Also used : EntityV1(org.graylog2.contentpacks.model.entities.EntityV1) EntityDescriptor(org.graylog2.contentpacks.model.entities.EntityDescriptor) NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) Entity(org.graylog2.contentpacks.model.entities.Entity) OutputEntity(org.graylog2.contentpacks.model.entities.OutputEntity) MessageOutput(org.graylog2.plugin.outputs.MessageOutput) LoggingOutput(org.graylog2.outputs.LoggingOutput) Output(org.graylog2.plugin.streams.Output) EntityDescriptorIds(org.graylog2.contentpacks.EntityDescriptorIds) OutputEntity(org.graylog2.contentpacks.model.entities.OutputEntity) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 69 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class OutputFacadeTest method findExisting.

@Test
@MongoDBFixtures("OutputFacadeTest.json")
public void findExisting() {
    final Entity entity = EntityV1.builder().id(ModelId.of("1")).type(ModelTypes.OUTPUT_V1).data(objectMapper.convertValue(OutputEntity.create(ValueReference.of("STDOUT"), ValueReference.of("org.graylog2.outputs.LoggingOutput"), ReferenceMapUtils.toReferenceMap(ImmutableMap.of("prefix", "Writing message: "))), JsonNode.class)).build();
    final Optional<NativeEntity<Output>> existingOutput = facade.findExisting(entity, Collections.emptyMap());
    assertThat(existingOutput).isEmpty();
}
Also used : NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) Entity(org.graylog2.contentpacks.model.entities.Entity) OutputEntity(org.graylog2.contentpacks.model.entities.OutputEntity) NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 70 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class OutputFacadeTest method listEntityExcerpts.

@Test
@MongoDBFixtures("OutputFacadeTest.json")
public void listEntityExcerpts() {
    final EntityExcerpt expectedEntityExcerpt = EntityExcerpt.builder().id(ModelId.of("5adf239e4b900a0fdb4e5197")).type(ModelTypes.OUTPUT_V1).title("STDOUT").build();
    final Set<EntityExcerpt> entityExcerpts = facade.listEntityExcerpts();
    assertThat(entityExcerpts).containsOnly(expectedEntityExcerpt);
}
Also used : EntityExcerpt(org.graylog2.contentpacks.model.entities.EntityExcerpt) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Aggregations

MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)167 Test (org.junit.Test)167 Entity (org.graylog2.contentpacks.model.entities.Entity)47 NativeEntity (org.graylog2.contentpacks.model.entities.NativeEntity)47 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)42 EntityV1 (org.graylog2.contentpacks.model.entities.EntityV1)24 EntityDescriptorIds (org.graylog2.contentpacks.EntityDescriptorIds)23 DateTime (org.joda.time.DateTime)17 ObjectId (org.bson.types.ObjectId)15 EntityExcerpt (org.graylog2.contentpacks.model.entities.EntityExcerpt)15 NativeEntityDescriptor (org.graylog2.contentpacks.model.entities.NativeEntityDescriptor)15 LookupTableEntity (org.graylog2.contentpacks.model.entities.LookupTableEntity)11 AbstractMap (java.util.AbstractMap)10 MigrationCompleted (org.graylog.plugins.views.migrations.V20191203120602_MigrateSavedSearchesToViewsSupport.V20191203120602_MigrateSavedSearchesToViews.MigrationCompleted)10 LookupCacheEntity (org.graylog2.contentpacks.model.entities.LookupCacheEntity)10 LookupDataAdapterEntity (org.graylog2.contentpacks.model.entities.LookupDataAdapterEntity)10 MongoDBServiceTest (org.graylog2.database.MongoDBServiceTest)10 GRN (org.graylog.grn.GRN)9 PipelineEntity (org.graylog2.contentpacks.model.entities.PipelineEntity)9 Document (org.bson.Document)8