Search in sources :

Example 1 with MockBatchingStateRestoreListener

use of org.apache.kafka.test.MockBatchingStateRestoreListener in project apache-kafka-on-k8s by banzaicloud.

the class ProcessorStateManagerTest method shouldRestoreStoreWithBatchingRestoreSpecification.

@Test
public void shouldRestoreStoreWithBatchingRestoreSpecification() throws Exception {
    final TaskId taskId = new TaskId(0, 2);
    final MockBatchingStateRestoreListener batchingRestoreCallback = new MockBatchingStateRestoreListener();
    final KeyValue<byte[], byte[]> expectedKeyValue = KeyValue.pair(key, value);
    final MockStateStore persistentStore = getPersistentStore();
    final ProcessorStateManager stateMgr = getStandByStateManager(taskId);
    try {
        stateMgr.register(persistentStore, batchingRestoreCallback);
        stateMgr.updateStandbyStates(persistentStorePartition, Collections.singletonList(consumerRecord));
        assertThat(batchingRestoreCallback.getRestoredRecords().size(), is(1));
        assertTrue(batchingRestoreCallback.getRestoredRecords().contains(expectedKeyValue));
    } finally {
        stateMgr.close(Collections.<TopicPartition, Long>emptyMap());
    }
}
Also used : TaskId(org.apache.kafka.streams.processor.TaskId) MockBatchingStateRestoreListener(org.apache.kafka.test.MockBatchingStateRestoreListener) MockStateStore(org.apache.kafka.test.MockStateStore) Test(org.junit.Test)

Aggregations

TaskId (org.apache.kafka.streams.processor.TaskId)1 MockBatchingStateRestoreListener (org.apache.kafka.test.MockBatchingStateRestoreListener)1 MockStateStore (org.apache.kafka.test.MockStateStore)1 Test (org.junit.Test)1