Search in sources :

Example 1 with MapperConfig

use of com.fasterxml.jackson.databind.cfg.MapperConfig in project druid by druid-io.

the class InputSourceModuleTest method testSubTypeRegistration.

@Test
public void testSubTypeRegistration() {
    MapperConfig config = mapper.getDeserializationConfig();
    AnnotatedClass annotatedClass = AnnotatedClassResolver.resolveWithoutSuperTypes(config, SqlInputSource.class);
    List<String> subtypes = mapper.getSubtypeResolver().collectAndResolveSubtypesByClass(config, annotatedClass).stream().map(NamedType::getName).collect(Collectors.toList());
    Assert.assertNotNull(subtypes);
    Assert.assertEquals(SQL_NAMED_TYPE, Iterables.getOnlyElement(subtypes));
}
Also used : AnnotatedClass(com.fasterxml.jackson.databind.introspect.AnnotatedClass) MapperConfig(com.fasterxml.jackson.databind.cfg.MapperConfig) Test(org.junit.Test)

Example 2 with MapperConfig

use of com.fasterxml.jackson.databind.cfg.MapperConfig in project druid by druid-io.

the class FirehoseModuleTest method getFirehoseFactorySubtypeClasses.

private static Set<Class> getFirehoseFactorySubtypeClasses(ObjectMapper objectMapper) {
    Class parentClass = FirehoseFactory.class;
    MapperConfig config = objectMapper.getDeserializationConfig();
    AnnotatedClass ac = AnnotatedClass.constructWithoutSuperTypes(parentClass, config);
    Collection<NamedType> subtypes = objectMapper.getSubtypeResolver().collectAndResolveSubtypesByClass(config, ac);
    Assert.assertNotNull(subtypes);
    return subtypes.stream().map(NamedType::getType).filter(c -> !c.equals(parentClass)).collect(Collectors.toSet());
}
Also used : Module(com.fasterxml.jackson.databind.Module) JvmUtils(org.apache.druid.utils.JvmUtils) FirehoseFactory(org.apache.druid.data.input.FirehoseFactory) URL(java.net.URL) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Set(java.util.Set) Test(org.junit.Test) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) URLClassLoader(java.net.URLClassLoader) AnnotatedClass(com.fasterxml.jackson.databind.introspect.AnnotatedClass) ClippedFirehoseFactory(org.apache.druid.segment.realtime.firehose.ClippedFirehoseFactory) Modifier(java.lang.reflect.Modifier) MapperConfig(com.fasterxml.jackson.databind.cfg.MapperConfig) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) ClassPath(com.google.common.reflect.ClassPath) Assert(org.junit.Assert) FirehoseFactory(org.apache.druid.data.input.FirehoseFactory) ClippedFirehoseFactory(org.apache.druid.segment.realtime.firehose.ClippedFirehoseFactory) AnnotatedClass(com.fasterxml.jackson.databind.introspect.AnnotatedClass) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) MapperConfig(com.fasterxml.jackson.databind.cfg.MapperConfig) AnnotatedClass(com.fasterxml.jackson.databind.introspect.AnnotatedClass)

Aggregations

MapperConfig (com.fasterxml.jackson.databind.cfg.MapperConfig)2 AnnotatedClass (com.fasterxml.jackson.databind.introspect.AnnotatedClass)2 Test (org.junit.Test)2 Module (com.fasterxml.jackson.databind.Module)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)1 ClassPath (com.google.common.reflect.ClassPath)1 IOException (java.io.IOException)1 Modifier (java.lang.reflect.Modifier)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 Collection (java.util.Collection)1 Set (java.util.Set)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 FirehoseFactory (org.apache.druid.data.input.FirehoseFactory)1 ClippedFirehoseFactory (org.apache.druid.segment.realtime.firehose.ClippedFirehoseFactory)1 JvmUtils (org.apache.druid.utils.JvmUtils)1 Assert (org.junit.Assert)1