use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class InlineSchemaAvroBytesDecoderTest method testSerde.
@Test
public void testSerde() throws Exception {
String jsonStr = "{\n" + " \"type\": \"schema_inline\",\n" + " \"schema\": {\n" + " \"namespace\": \"io.druid.data.input\",\n" + " \"name\": \"SomeData\",\n" + " \"type\": \"record\",\n" + " \"fields\" : [\n" + " {\"name\":\"timestamp\",\"type\":\"long\"},\n" + " {\"name\":\"eventType\",\"type\":\"string\"},\n" + " {\"name\":\"id\",\"type\":\"long\"}\n" + " ]\n" + " }\n" + "}";
final ObjectMapper mapper = new DefaultObjectMapper();
mapper.setInjectableValues(new InjectableValues.Std().addValue(ObjectMapper.class, mapper));
InlineSchemaAvroBytesDecoder actual = (InlineSchemaAvroBytesDecoder) mapper.readValue(mapper.writeValueAsString(mapper.readValue(jsonStr, AvroBytesDecoder.class)), AvroBytesDecoder.class);
Assert.assertEquals(actual.getSchema().get("name"), "SomeData");
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class InlineSchemasAvroBytesDecoderTest method testSerde.
@Test
public void testSerde() throws Exception {
String jsonStr = "{\n" + " \"type\": \"multiple_schemas_inline\",\n" + " \"schemas\": {\n" + " \"5\": {\n" + " \"namespace\": \"io.druid.data.input\",\n" + " \"name\": \"name5\",\n" + " \"type\": \"record\",\n" + " \"fields\" : [\n" + " {\"name\":\"eventType\",\"type\":\"string\"},\n" + " {\"name\":\"id\",\"type\":\"long\"}\n" + " ]\n" + " },\n" + " \"8\": {\n" + " \"namespace\": \"io.druid.data.input\",\n" + " \"name\": \"name8\",\n" + " \"type\": \"record\",\n" + " \"fields\" : [\n" + " {\"name\":\"eventType\",\"type\":\"string\"},\n" + " {\"name\":\"id\",\"type\":\"long\"}\n" + " ]\n" + " }\n" + " }\n" + "}\n";
final ObjectMapper mapper = new DefaultObjectMapper();
mapper.setInjectableValues(new InjectableValues.Std().addValue(ObjectMapper.class, mapper));
InlineSchemasAvroBytesDecoder actual = (InlineSchemasAvroBytesDecoder) mapper.readValue(mapper.writeValueAsString(mapper.readValue(jsonStr, AvroBytesDecoder.class)), AvroBytesDecoder.class);
Assert.assertEquals(actual.getSchemas().get("5").get("name"), "name5");
Assert.assertEquals(actual.getSchemas().get("8").get("name"), "name8");
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class LoadingLookupFactoryTest method testSerDeser.
@Test
public void testSerDeser() throws IOException {
ObjectMapper mapper = TestHelper.getObjectMapper();
LoadingLookupFactory loadingLookupFactory = new LoadingLookupFactory(new MockDataFetcher(), new OnHeapLoadingCache<String, String>(0, 100, 100L, 0L, 0L), new OffHeapLoadingCache<String, List<String>>(100, 100L, 0L, 0L));
mapper.registerSubtypes(MockDataFetcher.class);
mapper.registerSubtypes(LoadingLookupFactory.class);
Assert.assertEquals(loadingLookupFactory, mapper.reader(LookupExtractorFactory.class).readValue(mapper.writeValueAsString(loadingLookupFactory)));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class LoadingCacheTest method testSerDeser.
@Test
public void testSerDeser() throws IOException {
ObjectMapper mapper = new DefaultObjectMapper();
Assert.assertEquals(loadingCache, mapper.reader(LoadingCache.class).readValue(mapper.writeValueAsString(loadingCache)));
Assert.assertTrue(loadingCache.hashCode() == mapper.reader(LoadingCache.class).readValue(mapper.writeValueAsString(loadingCache)).hashCode());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class StaticS3FirehoseFactoryTest method testSerde.
@Test
public void testSerde() throws Exception {
ObjectMapper mapper = new DefaultObjectMapper();
final List<URI> uris = Arrays.asList(new URI("s3://foo/bar/file.gz"), new URI("s3://bar/foo/file2.gz"));
TestStaticS3FirehoseFactory factory = new TestStaticS3FirehoseFactory(uris);
TestStaticS3FirehoseFactory outputFact = mapper.readValue(mapper.writeValueAsString(factory), TestStaticS3FirehoseFactory.class);
Assert.assertEquals(factory, outputFact);
}
Aggregations