use of io.confluent.ksql.execution.ddl.commands.DropSourceCommand in project ksql by confluentinc.
the class DdlCommandExecTest method shouldThrowOnDropStreamWhenConstraintExist.
@Test
public void shouldThrowOnDropStreamWhenConstraintExist() {
// 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 Exception e = assertThrows(KsqlReferentialIntegrityException.class, () -> cmdExec.execute(SQL_TEXT, dropStream, false, Collections.emptySet()));
// Then:
assertThat(e.getMessage(), containsString("Cannot drop s1."));
assertThat(e.getMessage(), containsString("The following streams and/or tables read from this source: [s2, s3]."));
assertThat(e.getMessage(), containsString("You need to drop them before dropping s1."));
}
Aggregations