MongoJobRepository extends AbstractMongoRepository<String, JobInfo> implements JobRepository { @Override public List<JobInfo> findAllJobInfoWithoutMessages() { return collection() .find() .maxTime(mongoProperties.getDefaultReadTimeout(), TimeUnit.MILLISECONDS) .projection(new Document(getJobInfoWithoutMessagesProjection())) .map(this::decode) .into(new ArrayList<>()); } MongoJobRepository(final MongoDatabase mongoDatabase,
                              final String jobInfoCollectionName,
                              final MongoProperties mongoProperties); @Override JobStatus findStatus(final String jobId); @Override void removeIfStopped(final String id); @Override void appendMessage(final String jobId, final JobMessage jobMessage); @Override void setJobStatus(final String jobId, final JobStatus jobStatus); @Override void setLastUpdate(final String jobId, final OffsetDateTime lastUpdate); @Override List<JobInfo> findLatest(final int maxCount); @Override List<JobInfo> findLatestJobsDistinct(); List<String> findAllJobIdsDistinct(); @Override List<JobInfo> findLatestBy(final String type, final int maxCount); @Override List<JobInfo> findByType(final String type); @Override List<JobInfo> findRunningWithoutUpdateSince(final OffsetDateTime timeOffset); @Override List<JobInfo> findAllJobInfoWithoutMessages(); @Override void keepJobMessagesWithinMaximumSize(String jobId); static final String ID; }
@Test public void shouldStoreAndRetrieveAllJobInfoWithoutMessages() { final JobInfo job1 = someJobInfo("http: final JobInfo job2 = someJobInfo("http: repo.createOrUpdate(job1); repo.createOrUpdate(job2); final List<JobInfo> jobInfos = repo.findAllJobInfoWithoutMessages(); assertThat(jobInfos, hasSize(2)); assertThat(jobInfos.get(0), is(job1.copy().setMessages(emptyList()).build())); assertThat(jobInfos.get(1), is(job2.copy().setMessages(emptyList()).build())); }