use of io.confluent.ksql.rest.entity.TypeList in project ksql by confluentinc.
the class ClientTest method shouldFailToListTypesViaExecuteStatement.
@Test
public void shouldFailToListTypesViaExecuteStatement() {
// Given
final TypeList entity = new TypeList("list types;", Collections.emptyMap());
testEndpoints.setKsqlEndpointResponse(Collections.singletonList(entity));
// When
final Exception e = assertThrows(// thrown from .get() when the future completes exceptionally
ExecutionException.class, () -> javaClient.executeStatement("list types;").get());
// Then
assertThat(e.getCause(), instanceOf(KsqlClientException.class));
assertThat(e.getCause().getMessage(), containsString(EXECUTE_STATEMENT_USAGE_DOC));
assertThat(e.getCause().getMessage(), containsString("does not currently support listing custom types"));
}
use of io.confluent.ksql.rest.entity.TypeList in project ksql by confluentinc.
the class MigrationsTest method assertTypeCount.
private static void assertTypeCount(final int count) {
final List<KsqlEntity> entities = assertThatEventually(() -> makeKsqlRequest("LIST TYPES;"), hasSize(1));
assertThat(entities.get(0), instanceOf(TypeList.class));
TypeList entity = (TypeList) entities.get(0);
assertThat(entity.getTypes().size(), is(count));
}
use of io.confluent.ksql.rest.entity.TypeList in project ksql by confluentinc.
the class ListTypesExecutor method execute.
public static StatementExecutorResponse execute(final ConfiguredStatement<ListTypes> configuredStatement, final SessionProperties sessionProperties, final KsqlExecutionContext executionContext, final ServiceContext serviceContext) {
final ImmutableMap.Builder<String, SchemaInfo> types = ImmutableMap.builder();
final Iterator<CustomType> customTypes = executionContext.getMetaStore().types();
while (customTypes.hasNext()) {
final CustomType customType = customTypes.next();
types.put(customType.getName(), EntityUtil.schemaInfo(customType.getType()));
}
return StatementExecutorResponse.handled(Optional.of(new TypeList(configuredStatement.getStatementText(), types.build())));
}
use of io.confluent.ksql.rest.entity.TypeList in project ksql by confluentinc.
the class ConsoleTest method shouldPrintTypesList.
@Test
public void shouldPrintTypesList() {
// Given:
final KsqlEntityList entities = new KsqlEntityList(ImmutableList.of(new TypeList("statement", ImmutableMap.of("typeB", new SchemaInfo(SqlBaseType.ARRAY, null, new SchemaInfo(SqlBaseType.STRING, null, null)), "typeA", new SchemaInfo(SqlBaseType.STRUCT, ImmutableList.of(new FieldInfo("f1", new SchemaInfo(SqlBaseType.STRING, null, null), Optional.empty())), null), "typeC", new SchemaInfo(SqlBaseType.DECIMAL, null, null, ImmutableMap.of("precision", 10, "scale", 9))))));
// When:
console.printKsqlEntityList(entities);
// Then:
final String output = terminal.getOutputString();
Approvals.verify(output, approvalOptions);
}
Aggregations