use of org.jdbi.v3.core.codec.CodecFactory in project jdbi by jdbi.
the class TestCodecFactory method testCollectionCodec.
@Test
public void testCollectionCodec() {
CodecFactory factory = CodecFactory.forSingleCodec(SET_CODEC_TYPE, new GenericSetCodec());
Optional<Function<Object, Argument>> result = factory.prepare(SET_CODEC_TYPE, new ConfigRegistry());
assertTrue(result.isPresent());
// The TypeResolvingCodecFactory in jdbi3-guava returns true here.
result = factory.prepare(CONCRETE_TYPE_CODEC_TYPE, new ConfigRegistry());
assertFalse(result.isPresent());
}
use of org.jdbi.v3.core.codec.CodecFactory in project jdbi by jdbi.
the class TypeResolvingCodecFactoryTest method testNegativeStillWorks.
@Test
public void testNegativeStillWorks() {
CodecFactory factory = TypeResolvingCodecFactory.forSingleCodec(SET_CODEC_TYPE, new GenericSetCodec());
QualifiedType<Set<Integer>> integerSetType = QualifiedType.of(new GenericType<Set<Integer>>() {
});
Optional<Function<Object, Argument>> result = factory.prepare(integerSetType, new ConfigRegistry());
assertFalse(result.isPresent());
QualifiedType<HashSet<Integer>> concreteIntegerType = QualifiedType.of(new GenericType<HashSet<Integer>>() {
});
result = factory.prepare(concreteIntegerType, new ConfigRegistry());
assertFalse(result.isPresent());
QualifiedType<String> stringType = QualifiedType.of(String.class);
result = factory.prepare(stringType, new ConfigRegistry());
assertFalse(result.isPresent());
}
use of org.jdbi.v3.core.codec.CodecFactory in project jdbi by jdbi.
the class TypeResolvingCodecFactoryTest method testInterfaceCodec.
@Test
public void testInterfaceCodec() {
CodecFactory factory = TypeResolvingCodecFactory.forSingleCodec(XINTERFACE_CODEC_TYPE, new StringXInterfaceCodec());
QualifiedType<?> xClassType = QualifiedType.of(XClass.class);
Optional<Function<Object, Argument>> result = factory.prepare(xClassType, new ConfigRegistry());
assertTrue(result.isPresent());
QualifiedType<?> yClassType = QualifiedType.of(YClass.class);
result = factory.prepare(yClassType, new ConfigRegistry());
assertTrue(result.isPresent());
QualifiedType<?> zClassType = QualifiedType.of(ZClass.class);
result = factory.prepare(zClassType, new ConfigRegistry());
assertTrue(result.isPresent());
}
use of org.jdbi.v3.core.codec.CodecFactory in project jdbi by jdbi.
the class TypeResolvingCodecFactoryTest method testCollectionCodec.
@Test
public void testCollectionCodec() {
CodecFactory factory = TypeResolvingCodecFactory.forSingleCodec(SET_CODEC_TYPE, new GenericSetCodec());
Optional<Function<Object, Argument>> result = factory.prepare(SET_CODEC_TYPE, new ConfigRegistry());
assertTrue(result.isPresent());
result = factory.prepare(CONCRETE_TYPE_CODEC_TYPE, new ConfigRegistry());
assertTrue(result.isPresent());
}
Aggregations