Search in sources :

Example 1 with DropType

use of io.confluent.ksql.parser.DropType in project ksql by confluentinc.

the class DropTypeFactoryTest method shouldFailCreateTypeIfTypeDoesNotExist.

@Test
public void shouldFailCreateTypeIfTypeDoesNotExist() {
    // Given:
    final DropType dropType = new DropType(Optional.empty(), NOT_EXISTING_TYPE, false);
    // When:
    final Exception e = assertThrows(KsqlException.class, () -> factory.create(dropType));
    // Then:
    assertThat(e.getMessage(), equalTo("Type " + NOT_EXISTING_TYPE + " does not exist."));
}
Also used : DropType(io.confluent.ksql.parser.DropType) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 2 with DropType

use of io.confluent.ksql.parser.DropType in project ksql by confluentinc.

the class DropTypeFactoryTest method shouldCreateDropType.

@Test
public void shouldCreateDropType() {
    // Given:
    final DropType dropType = new DropType(Optional.empty(), EXISTING_TYPE, false);
    // When:
    final DropTypeCommand cmd = factory.create(dropType);
    // Then:
    assertThat(cmd.getTypeName(), equalTo(EXISTING_TYPE));
}
Also used : DropTypeCommand(io.confluent.ksql.execution.ddl.commands.DropTypeCommand) DropType(io.confluent.ksql.parser.DropType) Test(org.junit.Test)

Example 3 with DropType

use of io.confluent.ksql.parser.DropType in project ksql by confluentinc.

the class DropTypeFactoryTest method shouldCreateDropTypeForExistingTypeAndIfExistsSet.

@Test
public void shouldCreateDropTypeForExistingTypeAndIfExistsSet() {
    // Given:
    final DropType dropType = new DropType(Optional.empty(), EXISTING_TYPE, true);
    // When:
    final DropTypeCommand cmd = factory.create(dropType);
    // Then:
    assertThat(cmd.getTypeName(), equalTo(EXISTING_TYPE));
}
Also used : DropTypeCommand(io.confluent.ksql.execution.ddl.commands.DropTypeCommand) DropType(io.confluent.ksql.parser.DropType) Test(org.junit.Test)

Example 4 with DropType

use of io.confluent.ksql.parser.DropType in project ksql by confluentinc.

the class CommandFactoriesTest method shouldCreateDropType.

@Test
public void shouldCreateDropType() {
    // Given:
    final DropType dropType = new DropType(Optional.empty(), SOME_TYPE_NAME, false);
    // When:
    final DropTypeCommand cmd = (DropTypeCommand) commandFactories.create("sqlExpression", dropType, SessionConfig.of(ksqlConfig, emptyMap()));
    // Then:
    assertThat(cmd, is(dropTypeCommand));
    verify(dropTypeFactory).create(dropType);
}
Also used : DropTypeCommand(io.confluent.ksql.execution.ddl.commands.DropTypeCommand) DropType(io.confluent.ksql.parser.DropType) Test(org.junit.Test)

Example 5 with DropType

use of io.confluent.ksql.parser.DropType in project ksql by confluentinc.

the class DropTypeFactoryTest method shouldNotFailCreateTypeIfTypeDoesNotExistAndIfExistsSet.

@Test
public void shouldNotFailCreateTypeIfTypeDoesNotExistAndIfExistsSet() {
    // Given:
    final DropType dropType = new DropType(Optional.empty(), NOT_EXISTING_TYPE, true);
    // When:
    final DropTypeCommand cmd = factory.create(dropType);
    // Then:
    assertThat(cmd.getTypeName(), equalTo(NOT_EXISTING_TYPE));
}
Also used : DropTypeCommand(io.confluent.ksql.execution.ddl.commands.DropTypeCommand) DropType(io.confluent.ksql.parser.DropType) Test(org.junit.Test)

Aggregations

DropType (io.confluent.ksql.parser.DropType)5 Test (org.junit.Test)5 DropTypeCommand (io.confluent.ksql.execution.ddl.commands.DropTypeCommand)4 KsqlException (io.confluent.ksql.util.KsqlException)1