use of com.facebook.airlift.json.JsonCodecFactory in project presto by prestodb.
the class MetadataManager method createTestingViewCodec.
private static JsonCodec<ViewDefinition> createTestingViewCodec(FunctionAndTypeManager functionAndTypeManager) {
JsonObjectMapperProvider provider = new JsonObjectMapperProvider();
provider.setJsonDeserializers(ImmutableMap.of(Type.class, new TypeDeserializer(functionAndTypeManager)));
return new JsonCodecFactory(provider).jsonCodec(ViewDefinition.class);
}
use of com.facebook.airlift.json.JsonCodecFactory in project presto by prestodb.
the class TestSignature method testSerializationRoundTrip.
@Test
public void testSerializationRoundTrip() {
JsonObjectMapperProvider objectMapperProvider = new JsonObjectMapperProvider();
objectMapperProvider.setJsonDeserializers(ImmutableMap.of(Type.class, new TypeDeserializer(createTestFunctionAndTypeManager())));
JsonCodec<Signature> codec = new JsonCodecFactory(objectMapperProvider, true).jsonCodec(Signature.class);
Signature expected = new Signature(QualifiedObjectName.valueOf(DEFAULT_NAMESPACE, "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.getNameSuffix(), expected.getNameSuffix());
assertEquals(actual.getKind(), expected.getKind());
assertEquals(actual.getReturnType(), expected.getReturnType());
assertEquals(actual.getArgumentTypes(), expected.getArgumentTypes());
}
Aggregations