Search in sources :

Example 16 with ReferenceMapUtils.toReferenceMap

use of org.graylog2.contentpacks.model.entities.references.ReferenceMapUtils.toReferenceMap in project graylog2-server by Graylog2.

the class LookupTableFacadeTest method resolveEntity.

@Test
@MongoDBFixtures({ "LookupCacheFacadeTest.json", "LookupDataAdapterFacadeTest.json", "LookupTableFacadeTest.json" })
public void resolveEntity() {
    final Entity entity = EntityV1.builder().id(ModelId.of("5adf24dd4b900a0fdb4e530d")).type(ModelTypes.LOOKUP_TABLE_V1).data(objectMapper.convertValue(LookupTableEntity.create(ValueReference.of("http-dsv-no-cache"), ValueReference.of("HTTP DSV without Cache"), ValueReference.of("HTTP DSV without Cache"), ValueReference.of("5adf24b24b900a0fdb4e52dd"), ValueReference.of("5adf24a04b900a0fdb4e52c8"), ValueReference.of("Default single value"), ValueReference.of(LookupDefaultValue.Type.STRING), ValueReference.of("Default multi value"), ValueReference.of(LookupDefaultValue.Type.OBJECT)), JsonNode.class)).build();
    final Entity cacheEntity = EntityV1.builder().id(ModelId.of("5adf24b24b900a0fdb4e52dd")).type(ModelTypes.LOOKUP_CACHE_V1).data(objectMapper.convertValue(LookupCacheEntity.create(ValueReference.of("no-op-cache"), ValueReference.of("No-op cache"), ValueReference.of("No-op cache"), ReferenceMapUtils.toReferenceMap(ImmutableMap.of("type", "none"))), JsonNode.class)).build();
    final Entity dataAdapterEntity = EntityV1.builder().id(ModelId.of("5adf24a04b900a0fdb4e52c8")).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();
    final Map<EntityDescriptor, Entity> entities = ImmutableMap.of(cacheEntity.toEntityDescriptor(), cacheEntity, dataAdapterEntity.toEntityDescriptor(), dataAdapterEntity);
    final Graph<Entity> graph = facade.resolveForInstallation(entity, Collections.emptyMap(), entities);
    assertThat(graph.nodes()).hasSize(3).containsOnly(entity, cacheEntity, dataAdapterEntity);
}
Also used : NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) Entity(org.graylog2.contentpacks.model.entities.Entity) LookupCacheEntity(org.graylog2.contentpacks.model.entities.LookupCacheEntity) LookupDataAdapterEntity(org.graylog2.contentpacks.model.entities.LookupDataAdapterEntity) LookupTableEntity(org.graylog2.contentpacks.model.entities.LookupTableEntity) EntityDescriptor(org.graylog2.contentpacks.model.entities.EntityDescriptor) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 17 with ReferenceMapUtils.toReferenceMap

use of org.graylog2.contentpacks.model.entities.references.ReferenceMapUtils.toReferenceMap in project graylog2-server by Graylog2.

the class LookupCacheFacadeTest method findExistingWithNoExistingEntity.

@Test
@MongoDBFixtures("LookupCacheFacadeTest.json")
public void findExistingWithNoExistingEntity() {
    final Entity entity = EntityV1.builder().id(ModelId.of("1")).type(ModelTypes.LOOKUP_CACHE_V1).data(objectMapper.convertValue(LookupCacheEntity.create(ValueReference.of("some-cache"), ValueReference.of("Some cache"), ValueReference.of("Some cache"), ReferenceMapUtils.toReferenceMap(ImmutableMap.of("type", "none"))), JsonNode.class)).build();
    final Optional<NativeEntity<CacheDto>> existingCache = facade.findExisting(entity, Collections.emptyMap());
    assertThat(existingCache).isEmpty();
}
Also used : NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) Entity(org.graylog2.contentpacks.model.entities.Entity) LookupCacheEntity(org.graylog2.contentpacks.model.entities.LookupCacheEntity) NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Aggregations

Entity (org.graylog2.contentpacks.model.entities.Entity)17 NativeEntity (org.graylog2.contentpacks.model.entities.NativeEntity)17 Test (org.junit.Test)17 MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)13 LookupTableEntity (org.graylog2.contentpacks.model.entities.LookupTableEntity)6 HashMap (java.util.HashMap)5 ConverterEntity (org.graylog2.contentpacks.model.entities.ConverterEntity)5 ExtractorEntity (org.graylog2.contentpacks.model.entities.ExtractorEntity)5 GrokPatternEntity (org.graylog2.contentpacks.model.entities.GrokPatternEntity)5 InputEntity (org.graylog2.contentpacks.model.entities.InputEntity)5 LookupCacheEntity (org.graylog2.contentpacks.model.entities.LookupCacheEntity)5 LookupDataAdapterEntity (org.graylog2.contentpacks.model.entities.LookupDataAdapterEntity)5 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)3 OutputEntity (org.graylog2.contentpacks.model.entities.OutputEntity)3 Input (org.graylog2.inputs.Input)3 FakeHttpMessageInput (org.graylog2.inputs.random.FakeHttpMessageInput)3 RawUDPInput (org.graylog2.inputs.raw.udp.RawUDPInput)3 MessageInput (org.graylog2.plugin.inputs.MessageInput)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ArrayList (java.util.ArrayList)2