use of org.apache.kafka.connect.data.SchemaAndValue in project kafka by apache.
the class JsonConverterTest method longToConnect.
@Test
public void longToConnect() {
assertEquals(new SchemaAndValue(Schema.INT64_SCHEMA, 12L), converter.toConnectData(TOPIC, "{ \"schema\": { \"type\": \"int64\" }, \"payload\": 12 }".getBytes()));
assertEquals(new SchemaAndValue(Schema.INT64_SCHEMA, 4398046511104L), converter.toConnectData(TOPIC, "{ \"schema\": { \"type\": \"int64\" }, \"payload\": 4398046511104 }".getBytes()));
}
use of org.apache.kafka.connect.data.SchemaAndValue in project kafka by apache.
the class SimpleHeaderConverterTest method shouldConvertListWithMixedValuesToListWithoutSchema.
@Test
public void shouldConvertListWithMixedValuesToListWithoutSchema() {
List<Object> list = new ArrayList<>();
list.add("foo");
list.add((short) 13344);
SchemaAndValue result = roundTrip(null, list);
assertEquals(Schema.Type.ARRAY, result.schema().type());
assertNull(result.schema().valueSchema());
assertEquals(list, result.value());
}
use of org.apache.kafka.connect.data.SchemaAndValue in project kafka by apache.
the class SimpleHeaderConverterTest method shouldConvertEmptyMapToMap.
@Test
public void shouldConvertEmptyMapToMap() {
Map<Object, Object> map = new LinkedHashMap<>();
SchemaAndValue result = roundTrip(null, map);
assertEquals(Schema.Type.MAP, result.schema().type());
assertNull(result.schema().keySchema());
assertNull(result.schema().valueSchema());
assertEquals(map, result.value());
}
use of org.apache.kafka.connect.data.SchemaAndValue in project kafka by apache.
the class SimpleHeaderConverterTest method shouldParseStringOfMapWithIntValuesWithoutWhitespaceAsMap.
@Test
public void shouldParseStringOfMapWithIntValuesWithoutWhitespaceAsMap() {
SchemaAndValue result = roundTrip(Schema.STRING_SCHEMA, "{\"foo\":1234567890,\"bar\":0,\"baz\":-987654321}");
assertEquals(STRING_INT_MAP_SCHEMA, result.schema());
assertEquals(STRING_INT_MAP, result.value());
}
use of org.apache.kafka.connect.data.SchemaAndValue in project kafka by apache.
the class SimpleHeaderConverterTest method shouldParseStringOfMapWithStringValuesWithoutWhitespaceAsMap.
@Test
public void shouldParseStringOfMapWithStringValuesWithoutWhitespaceAsMap() {
SchemaAndValue result = roundTrip(Schema.STRING_SCHEMA, "{\"foo\":\"123\",\"bar\":\"baz\"}");
assertEquals(STRING_MAP_SCHEMA, result.schema());
assertEquals(STRING_MAP, result.value());
}
Aggregations