use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class RegisteredLookupExtractionFnTest method testSerDe.
@Test
public void testSerDe() throws Exception {
final ObjectMapper mapper = new DefaultObjectMapper();
final LookupExtractorFactoryContainerProvider manager = EasyMock.createStrictMock(LookupReferencesManager.class);
managerReturnsMap(manager);
EasyMock.replay(manager);
final RegisteredLookupExtractionFn fn = new RegisteredLookupExtractionFn(manager, LOOKUP_NAME, true, null, true, false);
EasyMock.verify(manager);
final Map<String, Object> result = mapper.readValue(mapper.writeValueAsString(fn), JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT);
Assert.assertEquals(mapper.convertValue(fn, JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT), result);
Assert.assertEquals(LOOKUP_NAME, result.get("lookup"));
Assert.assertEquals(true, result.get("retainMissingValue"));
Assert.assertEquals(true, result.get("injective"));
Assert.assertNull(result.get("replaceMissingValueWith"));
Assert.assertEquals(false, result.get("optimize"));
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class MapLookupExtractorFactoryTest method testSerDeserMapLookupExtractorFactory.
@Test
public void testSerDeserMapLookupExtractorFactory() throws IOException {
ObjectMapper mapper = new DefaultObjectMapper();
mapper.registerSubtypes(MapLookupExtractorFactory.class);
LookupExtractorFactory lookupExtractorFactory = new MapLookupExtractorFactory(ImmutableMap.of("key", "value"), true);
Assert.assertEquals(lookupExtractorFactory, mapper.readerFor(LookupExtractorFactory.class).readValue(mapper.writeValueAsString(lookupExtractorFactory)));
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class LookupDimensionSpecTest method testSerDesr.
@Parameters
@Test
public void testSerDesr(DimensionSpec lookupDimSpec) throws IOException {
ObjectMapper mapper = new DefaultObjectMapper();
mapper.registerSubtypes(new NamedType(LookupDimensionSpec.class, "lookup"));
InjectableValues injectableValues = new InjectableValues.Std().addValue(LookupExtractorFactoryContainerProvider.class, LOOKUP_REF_MANAGER);
String serLookup = mapper.writeValueAsString(lookupDimSpec);
Assert.assertEquals(lookupDimSpec, mapper.readerFor(DimensionSpec.class).with(injectableValues).readValue(serLookup));
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class LoadSpecTest method setUp.
@BeforeClass
public static void setUp() {
final Injector injector = GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.of(new Module() {
@Override
public void configure(Binder binder) {
binder.bind(LocalDataSegmentPuller.class);
}
}));
mapper = new DefaultObjectMapper();
mapper.registerModule(new SimpleModule("loadSpecTest").registerSubtypes(LocalLoadSpec.class));
mapper.setInjectableValues(new GuiceInjectableValues(injector));
final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
mapper.setAnnotationIntrospectors(new AnnotationIntrospectorPair(guiceIntrospector, mapper.getSerializationConfig().getAnnotationIntrospector()), new AnnotationIntrospectorPair(guiceIntrospector, mapper.getDeserializationConfig().getAnnotationIntrospector()));
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class IntervalLoadRuleTest method testSerde.
@Test
public void testSerde() throws Exception {
IntervalLoadRule rule = new IntervalLoadRule(Intervals.of("0/3000"), ImmutableMap.of(DruidServer.DEFAULT_TIER, 2));
ObjectMapper jsonMapper = new DefaultObjectMapper();
Rule reread = jsonMapper.readValue(jsonMapper.writeValueAsString(rule), Rule.class);
Assert.assertEquals(rule, reread);
}
Aggregations