use of io.confluent.ksql.rest.entity.ErrorEntity in project ksql by confluentinc.
the class ConnectExecutor method execute.
public StatementExecutorResponse execute(final ConfiguredStatement<CreateConnector> statement, final SessionProperties sessionProperties, final KsqlExecutionContext executionContext, final ServiceContext serviceContext) {
final CreateConnector createConnector = statement.getStatement();
final ConnectClient client = serviceContext.getConnectClient();
final List<String> errors = validate(createConnector, client);
if (!errors.isEmpty()) {
final String errorMessage = "Validation error: " + String.join("\n", errors);
return StatementExecutorResponse.handled(Optional.of(new ErrorEntity(statement.getStatementText(), errorMessage)));
}
final Optional<KsqlEntity> connectorsResponse = handleIfNotExists(statement, createConnector, client);
if (connectorsResponse.isPresent()) {
return StatementExecutorResponse.handled(connectorsResponse);
}
final ConnectResponse<ConnectorInfo> response = client.create(createConnector.getName(), buildConnectorConfig(createConnector));
if (response.datum().isPresent()) {
return StatementExecutorResponse.handled(Optional.of(new CreateConnectorEntity(statement.getStatementText(), response.datum().get())));
}
if (createConnector.ifNotExists()) {
final Optional<KsqlEntity> connectors = handleIfNotExists(statement, createConnector, client);
if (connectors.isPresent()) {
return StatementExecutorResponse.handled(connectors);
}
}
return StatementExecutorResponse.handled(connectErrorHandler.handle(statement, response));
}
use of io.confluent.ksql.rest.entity.ErrorEntity in project ksql by confluentinc.
the class ConsoleTest method shouldPrintErrorEntityLongNonJson.
@Test
public void shouldPrintErrorEntityLongNonJson() {
// Given:
final KsqlEntity entity = new ErrorEntity("statementText", Strings.repeat("Not a JSON value! ", 10));
// When:
console.printKsqlEntityList(ImmutableList.of(entity));
// Then:
final String output = terminal.getOutputString();
Approvals.verify(output, approvalOptions);
}
Aggregations