Search in sources :

Example 1 with ObjectMapperModule

use of com.fasterxml.jackson.module.guice.ObjectMapperModule in project api-core by ca-cwds.

the class ObjectMapperModuleTest method testModulesRegisteredThroughInjectionWithKey.

@Test
public void testModulesRegisteredThroughInjectionWithKey() throws Exception {
    final Injector injector = Guice.createInjector(new ObjectMapperModule().registerModule(Key.get(IntegerAsBase16Module.class)));
    final ObjectMapper mapper = injector.getInstance(ObjectMapper.class);
    Assert.assertEquals(mapper.writeValueAsString(new Integer(10)), "\"A\"");
}
Also used : ObjectMapperModule(com.fasterxml.jackson.module.guice.ObjectMapperModule) BigInteger(java.math.BigInteger) Injector(com.google.inject.Injector) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with ObjectMapperModule

use of com.fasterxml.jackson.module.guice.ObjectMapperModule in project api-core by ca-cwds.

the class ObjectMapperModuleTest method testModulesRegisteredThroughInjection.

@Test
public void testModulesRegisteredThroughInjection() throws Exception {
    final Injector injector = Guice.createInjector(new ObjectMapperModule().registerModule(IntegerAsBase16Module.class));
    final ObjectMapper mapper = injector.getInstance(ObjectMapper.class);
    Assert.assertEquals(mapper.writeValueAsString(new Integer(10)), "\"A\"");
}
Also used : ObjectMapperModule(com.fasterxml.jackson.module.guice.ObjectMapperModule) BigInteger(java.math.BigInteger) Injector(com.google.inject.Injector) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 3 with ObjectMapperModule

use of com.fasterxml.jackson.module.guice.ObjectMapperModule in project druid by druid-io.

the class S3InputSourceTest method createS3ObjectMapper.

public static ObjectMapper createS3ObjectMapper() {
    DruidModule baseModule = new TestS3Module();
    final Injector injector = Guice.createInjector(new ObjectMapperModule(), baseModule, new DruidModule() {

        @Provides
        public AWSCredentialsProvider getAWSCredentialsProvider() {
            return AWSCredentialsUtils.defaultAWSCredentialsProviderChain(null);
        }

        @Override
        public List<? extends Module> getJacksonModules() {
            return Collections.emptyList();
        }

        @Override
        public void configure(Binder binder) {
        }
    });
    final ObjectMapper baseMapper = injector.getInstance(ObjectMapper.class);
    baseModule.getJacksonModules().forEach(baseMapper::registerModule);
    return baseMapper;
}
Also used : ObjectMapperModule(com.fasterxml.jackson.module.guice.ObjectMapperModule) Binder(com.google.inject.Binder) Injector(com.google.inject.Injector) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) DruidModule(org.apache.druid.initialization.DruidModule) Provides(com.google.inject.Provides) Module(com.fasterxml.jackson.databind.Module) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) DruidModule(org.apache.druid.initialization.DruidModule) ObjectMapperModule(com.fasterxml.jackson.module.guice.ObjectMapperModule) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with ObjectMapperModule

use of com.fasterxml.jackson.module.guice.ObjectMapperModule in project druid by druid-io.

the class OssInputSourceTest method createObjectMapper.

public static ObjectMapper createObjectMapper() {
    DruidModule baseModule = new TestOssModule();
    final Injector injector = Guice.createInjector(new ObjectMapperModule(), baseModule);
    final ObjectMapper baseMapper = injector.getInstance(ObjectMapper.class);
    baseModule.getJacksonModules().forEach(baseMapper::registerModule);
    return baseMapper;
}
Also used : ObjectMapperModule(com.fasterxml.jackson.module.guice.ObjectMapperModule) Injector(com.google.inject.Injector) DruidModule(org.apache.druid.initialization.DruidModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with ObjectMapperModule

use of com.fasterxml.jackson.module.guice.ObjectMapperModule in project druid by druid-io.

the class StaticCloudFilesFirehoseFactoryTest method createObjectMapper.

private static ObjectMapper createObjectMapper(DruidModule baseModule) {
    final ObjectMapper baseMapper = new DefaultObjectMapper();
    baseModule.getJacksonModules().forEach(baseMapper::registerModule);
    final Injector injector = Guice.createInjector(new ObjectMapperModule(), baseModule);
    return injector.getInstance(ObjectMapper.class);
}
Also used : ObjectMapperModule(com.fasterxml.jackson.module.guice.ObjectMapperModule) Injector(com.google.inject.Injector) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper)

Aggregations

ObjectMapperModule (com.fasterxml.jackson.module.guice.ObjectMapperModule)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)11 Injector (com.google.inject.Injector)11 BigInteger (java.math.BigInteger)6 Test (org.junit.Test)6 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)4 Binder (com.google.inject.Binder)4 Module (com.google.inject.Module)3 DruidModule (org.apache.druid.initialization.DruidModule)3 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)3 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)1 Module (com.fasterxml.jackson.databind.Module)1 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)1 JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)1 ImmutableList (com.google.common.collect.ImmutableList)1 Provides (com.google.inject.Provides)1 SystemCodeSerializer (gov.ca.cwds.data.SystemCodeSerializer)1 List (java.util.List)1 ModelManager (org.embulk.config.ModelManager)1