Search in sources :

Example 6 with OutputEntity

use of org.graylog2.contentpacks.model.entities.OutputEntity in project graylog2-server by Graylog2.

the class OutputFacadeTest method collectEntity.

@Test
@MongoDBFixtures("OutputFacadeTest.json")
public void collectEntity() {
    final EntityDescriptor descriptor = EntityDescriptor.create("5adf239e4b900a0fdb4e5197", ModelTypes.OUTPUT_V1);
    final EntityDescriptorIds entityDescriptorIds = EntityDescriptorIds.of(descriptor);
    final Optional<Entity> collectedEntity = facade.exportEntity(descriptor, entityDescriptorIds);
    assertThat(collectedEntity).isPresent().containsInstanceOf(EntityV1.class);
    final EntityV1 entity = (EntityV1) collectedEntity.orElseThrow(AssertionError::new);
    assertThat(entity.id()).isEqualTo(ModelId.of(entityDescriptorIds.get(descriptor).orElse(null)));
    assertThat(entity.type()).isEqualTo(ModelTypes.OUTPUT_V1);
    final OutputEntity outputEntity = objectMapper.convertValue(entity.data(), OutputEntity.class);
    assertThat(outputEntity.title()).isEqualTo(ValueReference.of("STDOUT"));
    assertThat(outputEntity.type()).isEqualTo(ValueReference.of("org.graylog2.outputs.LoggingOutput"));
    assertThat(outputEntity.configuration()).isNotEmpty();
}
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) EntityDescriptorIds(org.graylog2.contentpacks.EntityDescriptorIds) OutputEntity(org.graylog2.contentpacks.model.entities.OutputEntity) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Aggregations

OutputEntity (org.graylog2.contentpacks.model.entities.OutputEntity)5 EntityDescriptorIds (org.graylog2.contentpacks.EntityDescriptorIds)4 Entity (org.graylog2.contentpacks.model.entities.Entity)4 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)4 EntityV1 (org.graylog2.contentpacks.model.entities.EntityV1)4 NativeEntity (org.graylog2.contentpacks.model.entities.NativeEntity)4 Output (org.graylog2.plugin.streams.Output)3 Test (org.junit.Test)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)2 ValidationException (org.graylog2.plugin.database.ValidationException)2 MessageOutput (org.graylog2.plugin.outputs.MessageOutput)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Strings.nullToEmpty (com.google.common.base.Strings.nullToEmpty)1 Graph (com.google.common.graph.Graph)1 GraphBuilder (com.google.common.graph.GraphBuilder)1 ImmutableGraph (com.google.common.graph.ImmutableGraph)1 MutableGraph (com.google.common.graph.MutableGraph)1 Collections (java.util.Collections)1