Search in sources :

Example 1 with Record

use of io.confluent.ksql.test.tools.Record in project ksql by confluentinc.

the class SchemaTranslationTest method generateInputRecords.

private static List<Record> generateInputRecords(final Schema avroSchema) {
    final Generator generator = new Generator(avroSchema, new Random());
    final List<Record> list = new ArrayList<>();
    for (int i = 0; i < 100; i++) {
        final Object avro = generator.generate();
        final JsonNode spec = avroToJson(avro, avroSchema, true);
        final Record record = new Record(TOPIC_NAME, "test-key", JsonNodeFactory.instance.textNode("test-key"), avroToValueSpec(avro, avroSchema, true), spec, Optional.of(0L), null, Optional.empty());
        list.add(record);
    }
    return list;
}
Also used : Random(java.util.Random) ArrayList(java.util.ArrayList) Record(io.confluent.ksql.test.tools.Record) JsonNode(com.fasterxml.jackson.databind.JsonNode) Generator(io.confluent.avro.random.generator.Generator)

Example 2 with Record

use of io.confluent.ksql.test.tools.Record in project ksql by confluentinc.

the class SchemaTranslationWithSchemaIdTest method generateInputRecords.

private static List<Record> generateInputRecords(final Schema avroSchema) {
    final Generator generator = new Generator(avroSchema, new Random());
    final List<Record> list = new ArrayList<>();
    for (int i = 0; i < 100; i++) {
        final Object avro = generator.generate();
        final JsonNode spec = avroToJson(avro, avroSchema, false);
        final Record record = new Record(TOPIC_NAME, "test-key", JsonNodeFactory.instance.textNode("test-key"), avroToValueSpec(avro, avroSchema, false), spec, Optional.of(0L), null, Optional.empty());
        list.add(record);
    }
    return list;
}
Also used : Random(java.util.Random) ArrayList(java.util.ArrayList) Record(io.confluent.ksql.test.tools.Record) JsonNode(com.fasterxml.jackson.databind.JsonNode) Generator(io.confluent.avro.random.generator.Generator)

Example 3 with Record

use of io.confluent.ksql.test.tools.Record in project ksql by confluentinc.

the class RestTestExecutor method verifyOutput.

private void verifyOutput(final RestTestCase testCase) {
    testCase.getOutputsByTopic().forEach((topicName, records) -> {
        final TopicInfo topicInfo = topicInfoCache.get(topicName).orElseThrow(() -> new KsqlException("No information found for topic: " + topicName));
        final List<? extends ConsumerRecord<?, ?>> received = kafkaCluster.verifyAvailableRecords(topicName, records.size(), topicInfo.getKeyDeserializer(), topicInfo.getValueDeserializer());
        for (int idx = 0; idx < records.size(); idx++) {
            final Record expected = records.get(idx);
            final ConsumerRecord<?, ?> actual = received.get(idx);
            compareKeyValueTimestamp(actual, expected);
        }
    });
}
Also used : Record(io.confluent.ksql.test.tools.Record) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) ProducerRecord(org.apache.kafka.clients.producer.ProducerRecord) KsqlException(io.confluent.ksql.util.KsqlException) TopicInfo(io.confluent.ksql.test.tools.TopicInfoCache.TopicInfo)

Example 4 with Record

use of io.confluent.ksql.test.tools.Record in project ksql by confluentinc.

the class RecordNodeTest method shouldUseExactDecimals.

@Test
public void shouldUseExactDecimals() {
    // Given:
    final RecordNode node = new RecordNode("topic", NullNode.getInstance(), new DecimalNode(new BigDecimal("10.000")), Optional.empty(), Optional.empty(), Optional.empty());
    // When:
    final Record result = node.build();
    // Then:
    assertThat(result.value(), is(new BigDecimal("10.000")));
}
Also used : Record(io.confluent.ksql.test.tools.Record) DecimalNode(com.fasterxml.jackson.databind.node.DecimalNode) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

Record (io.confluent.ksql.test.tools.Record)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 Generator (io.confluent.avro.random.generator.Generator)2 ArrayList (java.util.ArrayList)2 Random (java.util.Random)2 DecimalNode (com.fasterxml.jackson.databind.node.DecimalNode)1 TopicInfo (io.confluent.ksql.test.tools.TopicInfoCache.TopicInfo)1 KsqlException (io.confluent.ksql.util.KsqlException)1 BigDecimal (java.math.BigDecimal)1 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)1 ProducerRecord (org.apache.kafka.clients.producer.ProducerRecord)1 Test (org.junit.Test)1