Search in sources :

Example 1 with DdlCommandResult

use of io.confluent.ksql.execution.ddl.commands.DdlCommandResult in project ksql by confluentinc.

the class DdlCommandExecTest method shouldDropSource.

@Test
public void shouldDropSource() {
    // Given:
    metaStore.putSource(source, false);
    givenDropSourceCommand(STREAM_NAME);
    // When:
    final DdlCommandResult result = cmdExec.execute(SQL_TEXT, dropSource, false, NO_QUERY_SOURCES);
    // Then
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getMessage(), equalTo(String.format("Source %s (topic: %s) was dropped.", STREAM_NAME, TOPIC_NAME)));
}
Also used : DdlCommandResult(io.confluent.ksql.execution.ddl.commands.DdlCommandResult) Test(org.junit.Test)

Example 2 with DdlCommandResult

use of io.confluent.ksql.execution.ddl.commands.DdlCommandResult in project ksql by confluentinc.

the class DdlCommandExecTest method shouldWarnAddDuplicateTableWithoutReplace.

@Test
public void shouldWarnAddDuplicateTableWithoutReplace() {
    // Given:
    givenCreateTable();
    cmdExec.execute(SQL_TEXT, createTable, false, NO_QUERY_SOURCES);
    // When:
    givenCreateTable();
    final DdlCommandResult result = cmdExec.execute(SQL_TEXT, createTable, false, NO_QUERY_SOURCES);
    // Then:
    assertThat("Expected successful execution", result.isSuccess());
    assertThat(result.getMessage(), containsString("A table with the same name already exists"));
}
Also used : DdlCommandResult(io.confluent.ksql.execution.ddl.commands.DdlCommandResult) Test(org.junit.Test)

Example 3 with DdlCommandResult

use of io.confluent.ksql.execution.ddl.commands.DdlCommandResult in project ksql by confluentinc.

the class DdlCommandExecTest method shouldRegisterType.

@Test
public void shouldRegisterType() {
    // When:
    final DdlCommandResult result = cmdExec.execute(SQL_TEXT, registerType, false, NO_QUERY_SOURCES);
    // Then:
    assertThat("Expected successful resolution", result.isSuccess());
    assertThat(result.getMessage(), is("Registered custom type with name 'type' and SQL type " + type));
}
Also used : DdlCommandResult(io.confluent.ksql.execution.ddl.commands.DdlCommandResult) Test(org.junit.Test)

Example 4 with DdlCommandResult

use of io.confluent.ksql.execution.ddl.commands.DdlCommandResult in project ksql by confluentinc.

the class DdlCommandExecTest method shouldDropStreamIfConstraintExistsAndRestoreIsInProgress.

@Test
public void shouldDropStreamIfConstraintExistsAndRestoreIsInProgress() {
    // Given:
    final CreateStreamCommand stream1 = buildCreateStream(SourceName.of("s1"), SCHEMA, false, false);
    final CreateStreamCommand stream2 = buildCreateStream(SourceName.of("s2"), SCHEMA, false, false);
    final CreateStreamCommand stream3 = buildCreateStream(SourceName.of("s3"), SCHEMA, false, false);
    cmdExec.execute(SQL_TEXT, stream1, true, Collections.emptySet());
    cmdExec.execute(SQL_TEXT, stream2, true, Collections.singleton(SourceName.of("s1")));
    cmdExec.execute(SQL_TEXT, stream3, true, Collections.singleton(SourceName.of("s1")));
    // When:
    final DropSourceCommand dropStream = buildDropSourceCommand(SourceName.of("s1"));
    final DdlCommandResult result = cmdExec.execute(SQL_TEXT, dropStream, false, Collections.emptySet(), true);
    // Then
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getMessage(), equalTo(String.format("Source %s (topic: %s) was dropped.", STREAM_NAME, TOPIC_NAME)));
}
Also used : DdlCommandResult(io.confluent.ksql.execution.ddl.commands.DdlCommandResult) CreateStreamCommand(io.confluent.ksql.execution.ddl.commands.CreateStreamCommand) DropSourceCommand(io.confluent.ksql.execution.ddl.commands.DropSourceCommand) Test(org.junit.Test)

Example 5 with DdlCommandResult

use of io.confluent.ksql.execution.ddl.commands.DdlCommandResult in project ksql by confluentinc.

the class DdlCommandExecTest method shouldNotRegisterExistingType.

@Test
public void shouldNotRegisterExistingType() {
    // Given:
    metaStore.registerType("type", SqlTypes.STRING);
    // When:
    final DdlCommandResult result = cmdExec.execute(SQL_TEXT, registerType, false, NO_QUERY_SOURCES);
    // Then:
    assertThat("Expected successful resolution", result.isSuccess());
    assertThat(result.getMessage(), is("type is already registered with type STRING"));
}
Also used : DdlCommandResult(io.confluent.ksql.execution.ddl.commands.DdlCommandResult) Test(org.junit.Test)

Aggregations

DdlCommandResult (io.confluent.ksql.execution.ddl.commands.DdlCommandResult)11 Test (org.junit.Test)11 AlterSourceCommand (io.confluent.ksql.execution.ddl.commands.AlterSourceCommand)2 CreateStreamCommand (io.confluent.ksql.execution.ddl.commands.CreateStreamCommand)1 DropSourceCommand (io.confluent.ksql.execution.ddl.commands.DropSourceCommand)1