use of org.graylog2.contentpacks.model.entities.references.ReferenceMapUtils.toReferenceMap in project graylog2-server by Graylog2.
the class LookupCacheFacadeTest method createNativeEntity.
@Test
public void createNativeEntity() {
final Entity entity = EntityV1.builder().id(ModelId.of("1")).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();
assertThat(cacheService.findAll()).isEmpty();
final NativeEntity<CacheDto> nativeEntity = facade.createNativeEntity(entity, Collections.emptyMap(), Collections.emptyMap(), "username");
final NativeEntityDescriptor descriptor = nativeEntity.descriptor();
final CacheDto cacheDto = nativeEntity.entity();
assertThat(nativeEntity.descriptor().id()).isNotNull();
assertThat(descriptor.type()).isEqualTo(ModelTypes.LOOKUP_CACHE_V1);
assertThat(cacheDto.name()).isEqualTo("no-op-cache");
assertThat(cacheDto.title()).isEqualTo("No-op cache");
assertThat(cacheDto.description()).isEqualTo("No-op cache");
assertThat(cacheDto.config().type()).isEqualTo("none");
assertThat(cacheService.findAll()).hasSize(1);
}
use of org.graylog2.contentpacks.model.entities.references.ReferenceMapUtils.toReferenceMap in project graylog2-server by Graylog2.
the class LookupCacheFacadeTest method findExisting.
@Test
@MongoDBFixtures("LookupCacheFacadeTest.json")
public void findExisting() {
final Entity entity = EntityV1.builder().id(ModelId.of("1")).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 NativeEntity<CacheDto> existingCache = facade.findExisting(entity, Collections.emptyMap()).orElseThrow(AssertionError::new);
final NativeEntityDescriptor descriptor = existingCache.descriptor();
final CacheDto cacheDto = existingCache.entity();
assertThat(descriptor.id()).isEqualTo(ModelId.of("5adf24b24b900a0fdb4e52dd"));
assertThat(descriptor.type()).isEqualTo(ModelTypes.LOOKUP_CACHE_V1);
assertThat(cacheDto.id()).isEqualTo("5adf24b24b900a0fdb4e52dd");
assertThat(cacheDto.name()).isEqualTo("no-op-cache");
assertThat(cacheDto.title()).isEqualTo("No-op cache");
assertThat(cacheDto.description()).isEqualTo("No-op cache");
assertThat(cacheDto.config().type()).isEqualTo("none");
}
use of org.graylog2.contentpacks.model.entities.references.ReferenceMapUtils.toReferenceMap in project graylog2-server by Graylog2.
the class LookupCacheFacadeTest method resolveEntity.
@Test
@MongoDBFixtures("LookupCacheFacadeTest.json")
public void resolveEntity() {
final Entity entity = EntityV1.builder().id(ModelId.of("1")).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 Graph<Entity> graph = facade.resolveForInstallation(entity, Collections.emptyMap(), Collections.emptyMap());
assertThat(graph.nodes()).containsOnly(entity);
}
use of org.graylog2.contentpacks.model.entities.references.ReferenceMapUtils.toReferenceMap 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();
}
use of org.graylog2.contentpacks.model.entities.references.ReferenceMapUtils.toReferenceMap in project graylog2-server by Graylog2.
the class InputFacadeTest method resolveEntity.
@Test
@MongoDBFixtures("InputFacadeTest.json")
public void resolveEntity() {
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 Graph<Entity> graph = facade.resolveForInstallation(entity, Collections.emptyMap(), Collections.emptyMap());
assertThat(graph.nodes()).containsOnly(entity);
}
Aggregations