Search in sources :

Example 1 with TextConversionContext

use of com.datastax.oss.dsbulk.codecs.text.TextConversionContext in project dsbulk by datastax.

the class JsonNodeToMapCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL").setFormatNumbers(true).setRoundingMode(HALF_EVEN);
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec = (JsonNodeToMapCodec<Double, List<String>>) codecFactory.<JsonNode, Map<Double, List<String>>>createConvertingCodec(DataTypes.mapOf(DataTypes.DOUBLE, DataTypes.listOf(DataTypes.TEXT)), JSON_NODE_TYPE, true);
}
Also used : ConvertingCodecFactory(com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) ConversionContext(com.datastax.oss.dsbulk.codecs.api.ConversionContext) List(java.util.List) JsonNode(com.fasterxml.jackson.databind.JsonNode) ImmutableMap(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with TextConversionContext

use of com.datastax.oss.dsbulk.codecs.text.TextConversionContext in project dsbulk by datastax.

the class JsonNodeToSetCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL");
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec1 = (JsonNodeToSetCodec<Double>) codecFactory.<JsonNode, Set<Double>>createConvertingCodec(DataTypes.setOf(DataTypes.DOUBLE), JSON_NODE_TYPE, true);
    codec2 = (JsonNodeToSetCodec<String>) codecFactory.<JsonNode, Set<String>>createConvertingCodec(DataTypes.setOf(DataTypes.TEXT), JSON_NODE_TYPE, true);
}
Also used : ConvertingCodecFactory(com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) Set(java.util.Set) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) ConversionContext(com.datastax.oss.dsbulk.codecs.api.ConversionContext) JsonNode(com.fasterxml.jackson.databind.JsonNode) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with TextConversionContext

use of com.datastax.oss.dsbulk.codecs.text.TextConversionContext in project dsbulk by datastax.

the class JsonNodeToShortCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL").setFormatNumbers(true);
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec = (JsonNodeToShortCodec) codecFactory.<JsonNode, Short>createConvertingCodec(DataTypes.SMALLINT, JSON_NODE_TYPE, true);
}
Also used : ConvertingCodecFactory(com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) ConversionContext(com.datastax.oss.dsbulk.codecs.api.ConversionContext) JsonNode(com.fasterxml.jackson.databind.JsonNode) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with TextConversionContext

use of com.datastax.oss.dsbulk.codecs.text.TextConversionContext in project dsbulk by datastax.

the class JsonNodeToTupleCodecTest method setUp.

@BeforeEach
void setUp() {
    tupleType = DriverUtils.mockTupleType(DefaultProtocolVersion.V4, CodecRegistry.DEFAULT, DataTypes.TIMESTAMP, DataTypes.TEXT);
    ConversionContext context1 = new TextConversionContext().setNullStrings("NULL", "");
    ConversionContext context2 = new TextConversionContext().setAllowExtraFields(true);
    ConversionContext context3 = new TextConversionContext().setAllowMissingFields(true);
    codec1 = (JsonNodeToTupleCodec) new ConvertingCodecFactory(context1).<JsonNode, TupleValue>createConvertingCodec(tupleType, JSON_NODE_TYPE, true);
    codec2 = (JsonNodeToTupleCodec) new ConvertingCodecFactory(context2).<JsonNode, TupleValue>createConvertingCodec(tupleType, JSON_NODE_TYPE, true);
    codec3 = (JsonNodeToTupleCodec) new ConvertingCodecFactory(context3).<JsonNode, TupleValue>createConvertingCodec(tupleType, JSON_NODE_TYPE, true);
}
Also used : ConvertingCodecFactory(com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) ConversionContext(com.datastax.oss.dsbulk.codecs.api.ConversionContext) JsonNode(com.fasterxml.jackson.databind.JsonNode) TupleValue(com.datastax.oss.driver.api.core.data.TupleValue) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with TextConversionContext

use of com.datastax.oss.dsbulk.codecs.text.TextConversionContext in project dsbulk by datastax.

the class JsonNodeToUDTCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context1 = new TextConversionContext().setNullStrings("NULL", "");
    ConversionContext context2 = new TextConversionContext().setAllowExtraFields(true);
    ConversionContext context3 = new TextConversionContext().setAllowMissingFields(true);
    ConvertingCodecFactory codecFactory1 = new ConvertingCodecFactory(context1);
    ConvertingCodecFactory codecFactory2 = new ConvertingCodecFactory(context2);
    ConvertingCodecFactory codecFactory3 = new ConvertingCodecFactory(context3);
    udtCodec1 = (JsonNodeToUDTCodec) codecFactory1.<JsonNode, UdtValue>createConvertingCodec(udt1, JSON_NODE_TYPE, true);
    udtCodec2 = (JsonNodeToUDTCodec) codecFactory1.<JsonNode, UdtValue>createConvertingCodec(udt2, JSON_NODE_TYPE, true);
    udtCodec3 = (JsonNodeToUDTCodec) codecFactory2.<JsonNode, UdtValue>createConvertingCodec(udt3, JSON_NODE_TYPE, true);
    udtCodec4 = (JsonNodeToUDTCodec) codecFactory3.<JsonNode, UdtValue>createConvertingCodec(udt4, JSON_NODE_TYPE, true);
}
Also used : ConvertingCodecFactory(com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory) UdtValue(com.datastax.oss.driver.api.core.data.UdtValue) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) ConversionContext(com.datastax.oss.dsbulk.codecs.api.ConversionContext) JsonNode(com.fasterxml.jackson.databind.JsonNode) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ConvertingCodecFactory (com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory)29 TextConversionContext (com.datastax.oss.dsbulk.codecs.text.TextConversionContext)29 BeforeEach (org.junit.jupiter.api.BeforeEach)29 ConversionContext (com.datastax.oss.dsbulk.codecs.api.ConversionContext)28 JsonNode (com.fasterxml.jackson.databind.JsonNode)14 List (java.util.List)4 Instant (java.time.Instant)3 TupleValue (com.datastax.oss.driver.api.core.data.TupleValue)2 UdtValue (com.datastax.oss.driver.api.core.data.UdtValue)2 ImmutableMap (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap)2 BigDecimal (java.math.BigDecimal)2 BigInteger (java.math.BigInteger)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 ImmutableList (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList)1