use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class PullQueryFunctionalTest method setUpClass.
@BeforeClass
public static void setUpClass() {
TEST_HARNESS.ensureTopics(2, USER_TOPIC);
final AtomicLong timestampSupplier = new AtomicLong(BASE_TIME);
final Multimap<GenericKey, RecordMetadata> producedRows = TEST_HARNESS.produceRows(USER_TOPIC, USER_PROVIDER, KEY_FORMAT, VALUE_FORMAT, timestampSupplier::getAndIncrement);
LOG.info("Produced rows: " + producedRows.size());
makeAdminRequest("CREATE STREAM " + USERS_STREAM + " (" + USER_PROVIDER.ksqlSchemaString(false) + ")" + " WITH (" + " kafka_topic='" + USER_TOPIC + "', " + " value_format='" + VALUE_FORMAT.name() + "'" + ");");
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class AssertExecutor method assertContent.
private static void assertContent(final KsqlExecutionContext engine, final KsqlConfig config, final InsertValues values, final TestDriverPipeline driverPipeline, final boolean isTombstone) {
final boolean compareTimestamp = values.getColumns().stream().anyMatch(SystemColumns.ROWTIME_NAME::equals);
final DataSource dataSource = engine.getMetaStore().getSource(values.getTarget());
KsqlGenericRecord expected = new GenericRecordFactory(config, engine.getMetaStore(), System::currentTimeMillis).build(values.getColumns(), values.getValues(), dataSource.getSchema(), dataSource.getDataSourceType());
if (isTombstone) {
if (expected.value.values().stream().anyMatch(Objects::nonNull)) {
throw new AssertionError("Unexpected value columns specified in ASSERT NULL VALUES.");
}
expected = KsqlGenericRecord.of(expected.key, null, expected.ts);
}
final Iterator<TestRecord<GenericKey, GenericRow>> records = driverPipeline.getRecordsForTopic(dataSource.getKafkaTopicName());
if (!records.hasNext()) {
throwAssertionError("Expected another record, but all records have already been read:", dataSource, expected, driverPipeline.getAllRecordsForTopic(dataSource.getKafkaTopicName()).stream().map(rec -> KsqlGenericRecord.of(rec.key(), rec.value(), rec.timestamp())).collect(Collectors.toList()));
}
final TestRecord<GenericKey, GenericRow> actualTestRecord = records.next();
final KsqlGenericRecord actual = KsqlGenericRecord.of(actualTestRecord.key(), actualTestRecord.value(), compareTimestamp ? actualTestRecord.timestamp() : expected.ts);
if (!actual.equals(expected)) {
throwAssertionError("Expected record does not match actual.", dataSource, expected, ImmutableList.of(actual));
}
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class KeyUtilTest method shouldConvertNullKeyToList.
@Test
public void shouldConvertNullKeyToList() {
// Given:
final GenericKey key = GenericKey.genericKey((Object) null);
// When:
final List<?> result = KeyUtil.asList(key);
// Then:
assertThat(result, is(Collections.singletonList((null))));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class TableRowValidationTest method shouldThrowOnKeyFieldCountMismatch.
@Test(expected = IllegalArgumentException.class)
public void shouldThrowOnKeyFieldCountMismatch() {
// Given:
final GenericKey key = GenericKey.genericKey("key");
// When:
TableRowValidation.validate(SCHEMA, key, A_VALUE);
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class KsMaterializedTableIQv2Test method getEmptyIteratorResult.
private static StateQueryResult getEmptyIteratorResult() {
final StateQueryResult result = new StateQueryResult<>();
Set<GenericKey> keySet = new HashSet<>();
Map<GenericKey, ValueAndTimestamp<GenericRow>> map = new HashMap<>();
final KeyValueIterator iterator = new TestKeyValueIterator(keySet, map);
final QueryResult queryResult = QueryResult.forResult(iterator);
queryResult.setPosition(POSITION);
result.addResult(PARTITION, queryResult);
return result;
}
Aggregations