use of io.trino.spi.type.TestingTypeDeserializer in project trino by trinodb.
the class TestConnectorViewDefinition method createTestingViewCodec.
private static JsonCodec<ConnectorViewDefinition> createTestingViewCodec() {
ObjectMapperProvider provider = new ObjectMapperProvider();
provider.setJsonDeserializers(ImmutableMap.of(Type.class, new TestingTypeDeserializer(new TestingTypeManager())));
return new JsonCodecFactory(provider).jsonCodec(ConnectorViewDefinition.class);
}
use of io.trino.spi.type.TestingTypeDeserializer in project trino by trinodb.
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));
}
use of io.trino.spi.type.TestingTypeDeserializer in project trino by trinodb.
the class TestDomain method testJsonSerialization.
@Test
public void testJsonSerialization() throws Exception {
TestingTypeManager typeManager = new TestingTypeManager();
TestingBlockEncodingSerde blockEncodingSerde = new TestingBlockEncodingSerde();
ObjectMapper mapper = new ObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(Type.class, new TestingTypeDeserializer(typeManager)).addSerializer(Block.class, new TestingBlockJsonSerde.Serializer(blockEncodingSerde)).addDeserializer(Block.class, new TestingBlockJsonSerde.Deserializer(blockEncodingSerde)));
Domain domain = Domain.all(BIGINT);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.none(DOUBLE);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.notNull(BOOLEAN);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.notNull(HYPER_LOG_LOG);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.onlyNull(VARCHAR);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.onlyNull(HYPER_LOG_LOG);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.singleValue(BIGINT, Long.MIN_VALUE);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.singleValue(ID, Long.MIN_VALUE);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 0L), Range.equal(BIGINT, 1L), Range.range(BIGINT, 2L, true, 3L, true)), true);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
}
use of io.trino.spi.type.TestingTypeDeserializer in project trino by trinodb.
the class TestEquatableValueSet method testJsonSerialization.
@Test
public void testJsonSerialization() throws Exception {
TestingTypeManager typeManager = new TestingTypeManager();
TestingBlockEncodingSerde blockEncodingSerde = new TestingBlockEncodingSerde();
ObjectMapper mapper = new ObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(Type.class, new TestingTypeDeserializer(typeManager)).addSerializer(Block.class, new TestingBlockJsonSerde.Serializer(blockEncodingSerde)).addDeserializer(Block.class, new TestingBlockJsonSerde.Deserializer(blockEncodingSerde)));
EquatableValueSet set = EquatableValueSet.all(ID);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
set = EquatableValueSet.none(ID);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
set = EquatableValueSet.of(ID, 1L);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
set = EquatableValueSet.of(ID, 1L, 2L);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
set = EquatableValueSet.of(ID, 1L, 2L).complement();
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
}
use of io.trino.spi.type.TestingTypeDeserializer in project trino by trinodb.
the class TestSortedRangeSet method testJsonSerialization.
@Test
public void testJsonSerialization() throws Exception {
TestingTypeManager typeManager = new TestingTypeManager();
TestingBlockEncodingSerde blockEncodingSerde = new TestingBlockEncodingSerde();
ObjectMapper mapper = new ObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(Type.class, new TestingTypeDeserializer(typeManager)).addSerializer(Block.class, new TestingBlockJsonSerde.Serializer(blockEncodingSerde)).addDeserializer(Block.class, new TestingBlockJsonSerde.Deserializer(blockEncodingSerde)));
SortedRangeSet set = SortedRangeSet.all(BIGINT);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), SortedRangeSet.class));
set = SortedRangeSet.none(DOUBLE);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), SortedRangeSet.class));
set = SortedRangeSet.of(VARCHAR, utf8Slice("abc"));
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), SortedRangeSet.class));
set = SortedRangeSet.of(Range.equal(BOOLEAN, true), Range.equal(BOOLEAN, false));
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), SortedRangeSet.class));
}
Aggregations