use of com.fasterxml.jackson.module.guice.ObjectMapperModule in project druid by druid-io.
the class StaticAzureBlobStoreFirehoseFactoryTest 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);
}
use of com.fasterxml.jackson.module.guice.ObjectMapperModule in project druid by druid-io.
the class GoogleCloudStorageInputSourceTest method createGoogleObjectMapper.
public static ObjectMapper createGoogleObjectMapper() {
final DruidModule baseModule = new TestGoogleModule();
final ObjectMapper baseMapper = new DefaultObjectMapper();
baseModule.getJacksonModules().forEach(baseMapper::registerModule);
final Injector injector = Guice.createInjector(new ObjectMapperModule(), baseModule);
return injector.getInstance(ObjectMapper.class);
}
use of com.fasterxml.jackson.module.guice.ObjectMapperModule in project api-core by ca-cwds.
the class ObjectMapperModuleTest method testJacksonInjectThroughGuice.
@Test
public void testJacksonInjectThroughGuice() throws Exception {
final Injector injector = Guice.createInjector(new ObjectMapperModule(), new Module() {
@Override
public void configure(Binder binder) {
binder.bind(Integer.class).toInstance(1);
// guice based named injection
binder.bind(Integer.class).annotatedWith(Names.named("two")).toInstance(2);
binder.bind(Integer.class).annotatedWith(SystemCodeSerializer.class).toInstance(3);
// javax based named injection
binder.bind(Integer.class).annotatedWith(Names.named("five")).toInstance(5);
// guice based method injection
binder.bind(Integer.class).annotatedWith(Names.named("six")).toInstance(6);
// javax based method injection
binder.bind(Integer.class).annotatedWith(Names.named("seven")).toInstance(7);
// test other method injections (need different keys, so use Long
binder.bind(Long.class).annotatedWith(SystemCodeSerializer.class).toInstance(8L);
binder.bind(Long.class).toInstance(9L);
}
});
final ObjectMapper mapper = injector.getInstance(ObjectMapper.class);
mapper.readValue("{\"four\": 4}", SomeBean.class).verify();
}
use of com.fasterxml.jackson.module.guice.ObjectMapperModule in project api-core by ca-cwds.
the class ObjectMapperModuleTest method testModulesRegisteredThroughNormalInstantiation.
@Test
public void testModulesRegisteredThroughNormalInstantiation() throws Exception {
final Injector injector = Guice.createInjector(new ObjectMapperModule().registerModule(new IntegerAsBase16Module()));
final ObjectMapper mapper = injector.getInstance(ObjectMapper.class);
Assert.assertEquals(mapper.writeValueAsString(new Integer(10)), "\"A\"");
}
use of com.fasterxml.jackson.module.guice.ObjectMapperModule in project api-core by ca-cwds.
the class ObjectMapperModuleTest method testModulesRegisteredThroughInjectionWithNameAnnotation.
@Test
public void testModulesRegisteredThroughInjectionWithNameAnnotation() throws Exception {
final Injector injector = Guice.createInjector(new ObjectMapperModule().registerModule(IntegerAsBase16Module.class, Names.named("billy")), new Module() {
@Override
public void configure(Binder binder) {
binder.bind(IntegerAsBase16Module.class).annotatedWith(Names.named("billy")).to(IntegerAsBase16Module.class);
}
});
final ObjectMapper mapper = injector.getInstance(ObjectMapper.class);
Assert.assertEquals(mapper.writeValueAsString(new Integer(10)), "\"A\"");
}
Aggregations