use of io.confluent.ksql.rest.server.LocalCommands.LOCAL_COMMANDS_PROCESSED_SUFFIX in project ksql by confluentinc.
the class LocalCommandsTest method shouldWriteAppIdToCommandFile.
@Test
public void shouldWriteAppIdToCommandFile() throws IOException {
// Given
final File dir = commandsDir.newFolder();
LocalCommands localCommands = LocalCommands.open(ksqlEngine, dir);
File processedFile = localCommands.getCurrentLocalCommandsFile();
// When
localCommands.write(metadata1);
localCommands.write(metadata2);
// Then
// Need to create a new local commands in order not to skip the "current" file we just wrote.
localCommands = LocalCommands.open(ksqlEngine, dir);
localCommands.write(metadata3);
localCommands.processLocalCommandFiles(serviceContext);
verify(ksqlEngine).cleanupOrphanedInternalTopics(any(), eq(ImmutableSet.of(QUERY_APP_ID1, QUERY_APP_ID2)));
List<Path> paths = Files.list(dir.toPath()).collect(Collectors.toList());
String expectedProcessedFileName = processedFile.getAbsolutePath() + LOCAL_COMMANDS_PROCESSED_SUFFIX;
assertThat(paths.size(), is(2));
assertThat(paths.stream().anyMatch(path -> path.toFile().getAbsolutePath().equals(expectedProcessedFileName)), is(true));
}
Aggregations