FormSubmissionService { public List<FormSubmissionDTO> fetch(long formFetchToken) { return with(allFormSubmissions.findByServerVersion(formFetchToken)).convert(new Converter<FormSubmission, FormSubmissionDTO>() { @Override public FormSubmissionDTO convert(FormSubmission submission) { return FormSubmissionConverter.from(submission); } }); } @Autowired  FormSubmissionService(AllFormSubmissions allFormSubmissions); List<FormSubmissionDTO> fetch(long formFetchToken); List<FormSubmission> getNewSubmissionsForANM(String anmIdentifier, Long version, Integer batchSize); List<FormSubmission> getAllSubmissions(Long version, Integer batchSize); void submit(List<FormSubmissionDTO> formSubmissionsDTO);  }
@Test public void shouldFetchFormSubmissionsByGiven() throws Exception { long baseTimeStamp = DateUtil.now().getMillis(); FormSubmissionDTO firstFormSubmissionDTO = new FormSubmissionDTO("anm id 1", "instance id 1", "entity id 1", "form name 1", "", valueOf(baseTimeStamp), "1").withServerVersion("0"); FormSubmissionDTO secondFormSubmissionDTO = new FormSubmissionDTO("anm id 2", "instance id 2", "entity id 2", "form name 1", "", valueOf(baseTimeStamp + 1), "1").withServerVersion("1"); FormSubmission firstFormSubmission = new FormSubmission("anm id 1", "instance id 1", "form name 1", "entity id 1", baseTimeStamp, "1", null, 0L); FormSubmission secondFormSubmission = new FormSubmission("anm id 2", "instance id 2", "form name 1", "entity id 2", baseTimeStamp + 1, "1", null, 1L); when(allFormSubmissions.findByServerVersion(0L)).thenReturn(asList(firstFormSubmission, secondFormSubmission)); List<FormSubmissionDTO> formSubmissionDTOs = formSubmissionService.fetch(0L); assertEquals(asList(firstFormSubmissionDTO, secondFormSubmissionDTO), formSubmissionDTOs); }