DynamoJobRepository extends AbstractDynamoRepository implements JobRepository { @Override public void removeIfStopped(String jobId) { findOne(jobId).ifPresent(jobInfo -> { if (jobInfo.isStopped()) { Map<String, AttributeValue> keyMap = new HashMap<>(); keyMap.put(ID.key(), toStringAttributeValue(jobId)); DeleteItemRequest deleteJobRequest = DeleteItemRequest.builder() .tableName(tableName) .key(keyMap) .build(); dynamoDbClient.deleteItem(deleteJobRequest); } }); } DynamoJobRepository(DynamoDbClient dynamoDbClient, final String tableName, int pageSize); @Override Optional<JobInfo> findOne(String jobId); @Override List<JobInfo> findLatest(int maxCount); @Override List<JobInfo> findLatestJobsDistinct(); @Override List<JobInfo> findLatestBy(String type, int maxCount); @Override List<JobInfo> findRunningWithoutUpdateSince(OffsetDateTime timeOffset); @Override List<JobInfo> findAll(); @Override List<JobInfo> findAllJobInfoWithoutMessages(); @Override List<JobInfo> findByType(String jobType); @Override JobInfo createOrUpdate(final JobInfo job); @Override void removeIfStopped(String jobId); @Override JobInfo.JobStatus findStatus(String jobId); @Override void appendMessage(String jobId, JobMessage jobMessage); @Override void setJobStatus(String jobId, JobInfo.JobStatus jobStatus); @Override void setLastUpdate(String jobId, OffsetDateTime lastUpdate); @Override long size(); @Override void deleteAll();  }
@Test void shouldNotFailToRemoveMissingJob() { testee.removeIfStopped("foo"); }