Search in sources :

Example 61 with SchemaAndValue

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()));
}
Also used : SchemaAndValue(org.apache.kafka.connect.data.SchemaAndValue) Test(org.junit.jupiter.api.Test)

Example 62 with SchemaAndValue

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());
}
Also used : ArrayList(java.util.ArrayList) SchemaAndValue(org.apache.kafka.connect.data.SchemaAndValue) Test(org.junit.jupiter.api.Test)

Example 63 with SchemaAndValue

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());
}
Also used : LinkedHashMap(java.util.LinkedHashMap) SchemaAndValue(org.apache.kafka.connect.data.SchemaAndValue) Test(org.junit.jupiter.api.Test)

Example 64 with SchemaAndValue

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());
}
Also used : SchemaAndValue(org.apache.kafka.connect.data.SchemaAndValue) Test(org.junit.jupiter.api.Test)

Example 65 with SchemaAndValue

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());
}
Also used : SchemaAndValue(org.apache.kafka.connect.data.SchemaAndValue) Test(org.junit.jupiter.api.Test)

Aggregations

SchemaAndValue (org.apache.kafka.connect.data.SchemaAndValue)140 Test (org.junit.Test)57 Schema (org.apache.kafka.connect.data.Schema)49 Test (org.junit.jupiter.api.Test)46 HashMap (java.util.HashMap)32 Struct (org.apache.kafka.connect.data.Struct)21 Date (org.apache.kafka.connect.data.Date)18 BigInteger (java.math.BigInteger)12 Map (java.util.Map)12 ConnectorStatus (org.apache.kafka.connect.runtime.ConnectorStatus)11 BigDecimal (java.math.BigDecimal)10 TopicPartition (org.apache.kafka.common.TopicPartition)9 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)8 TaskStatus (org.apache.kafka.connect.runtime.TaskStatus)8 Callback (org.apache.kafka.clients.producer.Callback)7 SinkRecord (org.apache.kafka.connect.sink.SinkRecord)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 Collection (java.util.Collection)6 GregorianCalendar (java.util.GregorianCalendar)6 LinkedHashMap (java.util.LinkedHashMap)6