Search in sources :

Example 6 with LookupDataAdapterEntity

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

the class LookupDataAdapterFacadeTest method collectEntity.

@Test
@MongoDBFixtures("LookupDataAdapterFacadeTest.json")
public void collectEntity() {
    final EntityDescriptor descriptor = EntityDescriptor.create("5adf24a04b900a0fdb4e52c8", ModelTypes.LOOKUP_ADAPTER_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.LOOKUP_ADAPTER_V1);
    final LookupDataAdapterEntity lookupDataAdapterEntity = objectMapper.convertValue(entity.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)

Aggregations

LookupDataAdapterEntity (org.graylog2.contentpacks.model.entities.LookupDataAdapterEntity)6 EntityDescriptorIds (org.graylog2.contentpacks.EntityDescriptorIds)3 Entity (org.graylog2.contentpacks.model.entities.Entity)3 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)3 EntityV1 (org.graylog2.contentpacks.model.entities.EntityV1)3 NativeEntity (org.graylog2.contentpacks.model.entities.NativeEntity)3 DataAdapterDto (org.graylog2.lookup.dto.DataAdapterDto)3 Test (org.junit.Test)3 MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Constraint (org.graylog2.contentpacks.model.constraints.Constraint)1 PluginVersionConstraint (org.graylog2.contentpacks.model.constraints.PluginVersionConstraint)1 FallbackAdapterConfig (org.graylog2.plugin.lookup.FallbackAdapterConfig)1 LookupDataAdapterConfiguration (org.graylog2.plugin.lookup.LookupDataAdapterConfiguration)1