use of io.confluent.ksql.rest.server.utils.TestUtils in project ksql by confluentinc.
the class CommandRunnerTest method getRecordMap.
private Map<TopicPartition, List<ConsumerRecord<CommandId, Command>>> getRecordMap() {
List<Pair<CommandId, Command>> commandList = new TestUtils().getAllPriorCommandRecords();
List<ConsumerRecord<CommandId, Command>> recordList = new ArrayList<>();
for (Pair commandPair : commandList) {
recordList.add(new ConsumerRecord<>("T", 1, 1, (CommandId) commandPair.getLeft(), (Command) commandPair.getRight()));
}
Map<TopicPartition, List<ConsumerRecord<CommandId, Command>>> recordMap = new HashMap<>();
recordMap.put(new TopicPartition("T", 1), recordList);
return recordMap;
}
use of io.confluent.ksql.rest.server.utils.TestUtils in project ksql by confluentinc.
the class StatementExecutorTest method shouldHandlePriorStatement.
@Test
public void shouldHandlePriorStatement() throws Exception {
TestUtils testUtils = new TestUtils();
List<Pair<CommandId, Command>> priorCommands = testUtils.getAllPriorCommandRecords();
final RestoreCommands restoreCommands = new RestoreCommands();
priorCommands.forEach(pair -> restoreCommands.addCommand(pair.left, pair.right));
CommandId topicCommandId = new CommandId(CommandId.Type.TOPIC, "_CSASTopicGen", CommandId.Action.CREATE);
CommandId csCommandId = new CommandId(CommandId.Type.STREAM, "_CSASStreamGen", CommandId.Action.CREATE);
CommandId csasCommandId = new CommandId(CommandId.Type.STREAM, "_CSASGen", CommandId.Action.CREATE);
CommandId ctasCommandId = new CommandId(CommandId.Type.TABLE, "_CTASGen", CommandId.Action.CREATE);
statementExecutor.handleRestoration(restoreCommands);
Map<CommandId, CommandStatus> statusStore = statementExecutor.getStatuses();
Assert.assertNotNull(statusStore);
Assert.assertEquals(4, statusStore.size());
Assert.assertEquals(CommandStatus.Status.SUCCESS, statusStore.get(topicCommandId).getStatus());
Assert.assertEquals(CommandStatus.Status.SUCCESS, statusStore.get(csCommandId).getStatus());
Assert.assertEquals(CommandStatus.Status.SUCCESS, statusStore.get(csasCommandId).getStatus());
Assert.assertEquals(CommandStatus.Status.ERROR, statusStore.get(ctasCommandId).getStatus());
}
Aggregations