@Test
public void testReplaceTask() {

    JobStore store = getJobStore();
    Job<BatchJobExt> job = createBatchJobObject();
    store.init().await();
    store.storeJob(job).await();
    Pair<List<Job<?>>, Integer> jobsAndErrors = store.retrieveJobs().toBlocking().first();
    assertThat(jobsAndErrors.getLeft().get(0)).isEqualTo(job);
    Task firstTask = createTaskObject(job);
    store.storeTask(firstTask).await();
    Task retrievedTask = store.retrieveTask(firstTask.getId()).toBlocking().first();
    assertThat(firstTask).isEqualTo(retrievedTask);
    Task secondTask = createTaskObject(job);
    store.replaceTask(firstTask, secondTask).await();
    Pair<List<Task>, Integer> tasks = store.retrieveTasksForJob(job.getId()).toBlocking().first();
    assertThat(tasks.getLeft()).hasSize(1);
    assertThat(tasks.getRight()).isEqualTo(0);
    assertThat(tasks.getLeft().get(0)).isEqualTo(secondTask);
}