Search in sources :

Example 1 with TestUtils

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) TestUtils(io.confluent.ksql.rest.server.utils.TestUtils) TopicPartition(org.apache.kafka.common.TopicPartition) ArrayList(java.util.ArrayList) List(java.util.List) Pair(io.confluent.ksql.util.Pair)

Example 2 with TestUtils

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());
}
Also used : TestUtils(io.confluent.ksql.rest.server.utils.TestUtils) CommandStatus(io.confluent.ksql.rest.entity.CommandStatus) Pair(io.confluent.ksql.util.Pair) Test(org.junit.Test)

Aggregations

TestUtils (io.confluent.ksql.rest.server.utils.TestUtils)2 Pair (io.confluent.ksql.util.Pair)2 CommandStatus (io.confluent.ksql.rest.entity.CommandStatus)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)1 TopicPartition (org.apache.kafka.common.TopicPartition)1 Test (org.junit.Test)1