use of io.airlift.json.ObjectMapperProvider in project presto by prestodb.
the class TestSignature method testSerializationRoundTrip.
@Test
public void testSerializationRoundTrip() {
ObjectMapperProvider objectMapperProvider = new ObjectMapperProvider();
objectMapperProvider.setJsonDeserializers(ImmutableMap.of(Type.class, new TypeDeserializer(new TypeRegistry())));
JsonCodec<Signature> codec = new JsonCodecFactory(objectMapperProvider, true).jsonCodec(Signature.class);
Signature expected = new Signature("function", SCALAR, parseTypeSignature(StandardTypes.BIGINT), ImmutableList.of(parseTypeSignature(StandardTypes.BOOLEAN), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.VARCHAR)));
String json = codec.toJson(expected);
Signature actual = codec.fromJson(json);
assertEquals(actual.getName(), expected.getName());
assertEquals(actual.getKind(), expected.getKind());
assertEquals(actual.getReturnType(), expected.getReturnType());
assertEquals(actual.getArgumentTypes(), expected.getArgumentTypes());
}
use of io.airlift.json.ObjectMapperProvider in project presto by prestodb.
the class MetadataManager method createTestingViewCodec.
private static JsonCodec<ViewDefinition> createTestingViewCodec() {
ObjectMapperProvider provider = new ObjectMapperProvider();
provider.setJsonDeserializers(ImmutableMap.of(Type.class, new TypeDeserializer(new TypeRegistry())));
return new JsonCodecFactory(provider).jsonCodec(ViewDefinition.class);
}
use of io.airlift.json.ObjectMapperProvider in project presto by prestodb.
the class TestHttpQueryStatsClient method setUp.
@BeforeMethod
public void setUp() throws Exception {
ObjectMapper objectMapper = new ObjectMapperProvider().get();
TestingHttpClient httpClient = new TestingHttpClient(httpRequest -> httpResponse);
this.queryStatsClient = new HttpQueryStatsClient(httpClient, objectMapper, BASE_URL);
}
use of io.airlift.json.ObjectMapperProvider in project presto by prestodb.
the class TestLocalProperties method testJsonSerialization.
@Test
public void testJsonSerialization() throws Exception {
ObjectMapper mapper = new ObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(ColumnHandle.class, new JsonDeserializer<ColumnHandle>() {
@Override
public ColumnHandle deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
return new ObjectMapperProvider().get().readValue(jsonParser, TestingColumnHandle.class);
}
}));
TestingColumnHandle columnHandle = new TestingColumnHandle("a");
LocalProperty<ColumnHandle> property1 = new ConstantProperty<>(columnHandle);
assertEquals(property1, mapper.readValue(mapper.writeValueAsString(property1), new TypeReference<LocalProperty<ColumnHandle>>() {
}));
LocalProperty<ColumnHandle> property2 = new SortingProperty<>(columnHandle, SortOrder.ASC_NULLS_FIRST);
assertEquals(property2, mapper.readValue(mapper.writeValueAsString(property2), new TypeReference<LocalProperty<ColumnHandle>>() {
}));
LocalProperty<ColumnHandle> property3 = new GroupingProperty<>(ImmutableList.of(columnHandle));
assertEquals(property3, mapper.readValue(mapper.writeValueAsString(property3), new TypeReference<LocalProperty<ColumnHandle>>() {
}));
}
use of io.airlift.json.ObjectMapperProvider in project presto by prestodb.
the class TestAllOrNoneValueSet method testJsonSerialization.
@Test
public void testJsonSerialization() throws Exception {
TestingTypeManager typeManager = new TestingTypeManager();
ObjectMapper mapper = new ObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(Type.class, new TestingTypeDeserializer(typeManager)));
AllOrNoneValueSet all = AllOrNoneValueSet.all(HYPER_LOG_LOG);
assertEquals(all, mapper.readValue(mapper.writeValueAsString(all), AllOrNoneValueSet.class));
AllOrNoneValueSet none = AllOrNoneValueSet.none(HYPER_LOG_LOG);
assertEquals(none, mapper.readValue(mapper.writeValueAsString(none), AllOrNoneValueSet.class));
}
Aggregations