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);
}
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();
}
Aggregations