Search in sources :

Example 26 with NativeEntity

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

the class PipelineFacadeTest method findExisting.

@Test
@MongoDBFixtures("PipelineFacadeTest/pipelines.json")
public void findExisting() {
    final Entity entity = EntityV1.builder().id(ModelId.of("1")).type(ModelTypes.PIPELINE_V1).data(objectMapper.convertValue(PipelineEntity.create(ValueReference.of("Title"), ValueReference.of("Description"), ValueReference.of("pipeline \"Title\"\nstage 0 match either\nrule \"debug\"\nrule \"no-op\"\nend"), Collections.singleton(ValueReference.of("5adf23894b900a0f00000001"))), JsonNode.class)).build();
    final Optional<NativeEntity<PipelineDao>> existingEntity = facade.findExisting(entity, Collections.emptyMap());
    assertThat(existingEntity).isEmpty();
}
Also used : NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) Entity(org.graylog2.contentpacks.model.entities.Entity) PipelineEntity(org.graylog2.contentpacks.model.entities.PipelineEntity) NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 27 with NativeEntity

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

the class InputFacadeTest method findExisting.

@Test
@MongoDBFixtures("InputFacadeTest.json")
public void findExisting() {
    final Map<String, Object> configuration = new HashMap<>();
    configuration.put("override_source", null);
    configuration.put("recv_buffer_size", 262144);
    configuration.put("bind_address", "127.0.0.1");
    configuration.put("port", 5555);
    configuration.put("number_worker_threads", 8);
    final Entity entity = EntityV1.builder().id(ModelId.of("5acc84f84b900a4ff290d9a7")).type(ModelTypes.INPUT_V1).data(objectMapper.convertValue(InputEntity.create(ValueReference.of("Local Raw UDP"), ReferenceMapUtils.toReferenceMap(configuration), Collections.emptyMap(), ValueReference.of("org.graylog2.inputs.raw.udp.RawUDPInput"), ValueReference.of(false), Collections.emptyList()), JsonNode.class)).build();
    final Optional<NativeEntity<InputWithExtractors>> existingInput = facade.findExisting(entity, Collections.emptyMap());
    assertThat(existingInput).isEmpty();
}
Also used : NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) ConverterEntity(org.graylog2.contentpacks.model.entities.ConverterEntity) InputEntity(org.graylog2.contentpacks.model.entities.InputEntity) Entity(org.graylog2.contentpacks.model.entities.Entity) ExtractorEntity(org.graylog2.contentpacks.model.entities.ExtractorEntity) LookupTableEntity(org.graylog2.contentpacks.model.entities.LookupTableEntity) GrokPatternEntity(org.graylog2.contentpacks.model.entities.GrokPatternEntity) HashMap(java.util.HashMap) NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 28 with NativeEntity

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

the class LookupDataAdapterFacadeTest method createNativeEntity.

@Test
public void createNativeEntity() {
    final Entity entity = EntityV1.builder().id(ModelId.of("1")).type(ModelTypes.LOOKUP_ADAPTER_V1).data(objectMapper.convertValue(LookupDataAdapterEntity.create(ValueReference.of("http-dsv"), ValueReference.of("HTTP DSV"), ValueReference.of("HTTP DSV"), ReferenceMapUtils.toReferenceMap(Collections.emptyMap())), JsonNode.class)).build();
    assertThat(dataAdapterService.findAll()).isEmpty();
    final NativeEntity<DataAdapterDto> nativeEntity = facade.createNativeEntity(entity, Collections.emptyMap(), Collections.emptyMap(), "username");
    assertThat(nativeEntity.descriptor().id()).isNotNull();
    assertThat(nativeEntity.descriptor().type()).isEqualTo(ModelTypes.LOOKUP_ADAPTER_V1);
    assertThat(nativeEntity.entity().name()).isEqualTo("http-dsv");
    assertThat(nativeEntity.entity().title()).isEqualTo("HTTP DSV");
    assertThat(nativeEntity.entity().description()).isEqualTo("HTTP DSV");
    assertThat(dataAdapterService.findAll()).hasSize(1);
}
Also used : NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) Entity(org.graylog2.contentpacks.model.entities.Entity) LookupDataAdapterEntity(org.graylog2.contentpacks.model.entities.LookupDataAdapterEntity) DataAdapterDto(org.graylog2.lookup.dto.DataAdapterDto) Test(org.junit.Test)

Example 29 with NativeEntity

use of org.graylog2.contentpacks.model.entities.NativeEntity 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 30 with NativeEntity

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

the class OutputFacadeTest method createNativeEntity.

@Test
public void createNativeEntity() {
    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 NativeEntity<Output> nativeEntity = facade.createNativeEntity(entity, Collections.emptyMap(), Collections.emptyMap(), "username");
    assertThat(nativeEntity.descriptor().type()).isEqualTo(ModelTypes.OUTPUT_V1);
    assertThat(nativeEntity.entity().getTitle()).isEqualTo("STDOUT");
    assertThat(nativeEntity.entity().getType()).isEqualTo("org.graylog2.outputs.LoggingOutput");
    assertThat(nativeEntity.entity().getCreatorUserId()).isEqualTo("username");
    assertThat(nativeEntity.entity().getConfiguration()).containsEntry("prefix", "Writing message: ");
}
Also used : 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) Test(org.junit.Test)

Aggregations

NativeEntity (org.graylog2.contentpacks.model.entities.NativeEntity)30 Entity (org.graylog2.contentpacks.model.entities.Entity)28 Test (org.junit.Test)26 NativeEntityDescriptor (org.graylog2.contentpacks.model.entities.NativeEntityDescriptor)15 MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)14 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)12 EntityV1 (org.graylog2.contentpacks.model.entities.EntityV1)7 LookupCacheEntity (org.graylog2.contentpacks.model.entities.LookupCacheEntity)7 LookupTableEntity (org.graylog2.contentpacks.model.entities.LookupTableEntity)7 ValueReference (org.graylog2.contentpacks.model.entities.references.ValueReference)7 HashMap (java.util.HashMap)6 LookupDataAdapterEntity (org.graylog2.contentpacks.model.entities.LookupDataAdapterEntity)6 CacheDto (org.graylog2.lookup.dto.CacheDto)6 Map (java.util.Map)5 RuleDao (org.graylog.plugins.pipelineprocessor.db.RuleDao)5 GrokPatternEntity (org.graylog2.contentpacks.model.entities.GrokPatternEntity)5 DataAdapterDto (org.graylog2.lookup.dto.DataAdapterDto)5 Graph (com.google.common.graph.Graph)4 GraphBuilder (com.google.common.graph.GraphBuilder)4 ImmutableGraph (com.google.common.graph.ImmutableGraph)4