Search in sources :

Example 1 with OutputImpl

use of org.graylog2.streams.OutputImpl in project graylog2-server by Graylog2.

the class OutputFacadeTest method exportEntity.

@Test
public void exportEntity() {
    final ImmutableMap<String, Object> configuration = ImmutableMap.of("some-setting", "foobar");
    final OutputImpl output = OutputImpl.create("01234567890", "Output Title", "org.graylog2.outputs.LoggingOutput", "admin", configuration, new Date(0L), null);
    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("Output Title"));
    assertThat(outputEntity.type()).isEqualTo(ValueReference.of("org.graylog2.outputs.LoggingOutput"));
    assertThat(outputEntity.configuration()).containsEntry("some-setting", ValueReference.of("foobar"));
}
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) OutputImpl(org.graylog2.streams.OutputImpl) Date(java.util.Date) Test(org.junit.Test)

Example 2 with OutputImpl

use of org.graylog2.streams.OutputImpl in project graylog2-server by Graylog2.

the class OutputFacadeTest method createExcerpt.

@Test
public void createExcerpt() {
    final ImmutableMap<String, Object> configuration = ImmutableMap.of();
    final OutputImpl output = OutputImpl.create("01234567890", "Output Title", "org.graylog2.output.SomeOutputClass", "admin", configuration, new Date(0L), null);
    final EntityExcerpt excerpt = facade.createExcerpt(output);
    assertThat(excerpt.id()).isEqualTo(ModelId.of(output.getId()));
    assertThat(excerpt.type()).isEqualTo(ModelTypes.OUTPUT_V1);
    assertThat(excerpt.title()).isEqualTo(output.getTitle());
}
Also used : EntityExcerpt(org.graylog2.contentpacks.model.entities.EntityExcerpt) OutputImpl(org.graylog2.streams.OutputImpl) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Date (java.util.Date)2 OutputImpl (org.graylog2.streams.OutputImpl)2 Test (org.junit.Test)2 EntityDescriptorIds (org.graylog2.contentpacks.EntityDescriptorIds)1 Entity (org.graylog2.contentpacks.model.entities.Entity)1 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)1 EntityExcerpt (org.graylog2.contentpacks.model.entities.EntityExcerpt)1 EntityV1 (org.graylog2.contentpacks.model.entities.EntityV1)1 NativeEntity (org.graylog2.contentpacks.model.entities.NativeEntity)1 OutputEntity (org.graylog2.contentpacks.model.entities.OutputEntity)1