CassandraJobStore implements JobStore { @Override public Observable<Task> retrieveTask(String taskId) { return Observable .fromCallable((Callable<Statement>) () -> { transactionLogger().logBeforeRead(retrieveActiveTaskStatement, "retrieveTask", taskId); return retrieveActiveTaskStatement.bind(taskId); }) .flatMap(statement -> execute(statement).flatMap(resultSet -> { Row row = resultSet.one(); if (row != null) { String value = row.getString(0); Task task = deserializeTask(value); transactionLogger().logAfterRead(retrieveActiveTaskStatement, "retrieveTask", task); return Observable.just(task); } else { return Observable.error(JobStoreException.taskDoesNotExist(taskId)); } })); } @Inject  CassandraJobStore(CassandraStoreConfiguration configuration,
                             Session session,
                             TitusRuntime titusRuntime);   CassandraJobStore(CassandraStoreConfiguration configuration,
                      Session session,
                      TitusRuntime titusRuntime,
                      ObjectMapper mapper,
                      int initialBucketCount,
                      int maxBucketSize); @Override Completable init(); @Override Observable<Pair<List<Job<?>>, Integer>> retrieveJobs(); @Override Observable<Job<?>> retrieveJob(String jobId); @Override Completable storeJob(Job job); @Override Completable updateJob(Job job); @Override Completable deleteJob(Job job); @Override Observable<Pair<List<Task>, Integer>> retrieveTasksForJob(String jobId); @Override Observable<Task> retrieveTask(String taskId); @Override Completable storeTask(Task task); @Override Completable updateTask(Task task); @Override Completable replaceTask(Task oldTask, Task newTask); @Override Completable moveTask(Job jobFrom, Job jobTo, Task taskAfter); @Override Completable deleteTask(Task task); @Override Observable<Job<?>> retrieveArchivedJob(String jobId); @Override Observable<Task> retrieveArchivedTasksForJob(String jobId); @Override Observable<Task> retrieveArchivedTask(String taskId);  }
@Test public void testRetrieveTask() { 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 task = createTaskObject(job); store.storeTask(task).await(); Task retrievedTask = store.retrieveTask(task.getId()).toBlocking().first(); assertThat(task).isEqualTo(retrievedTask); try { store.retrieveArchivedTask(task.getId()).toBlocking().first(); fail("Should not return active task"); } catch (JobStoreException e) { assertThat(e.getErrorCode()).isEqualTo(JobStoreException.ErrorCode.TASK_DOES_NOT_EXIST); } }