DeveloperService { public DeveloperPage list(DeveloperDTO developerDTO, PageableDTO pageableDTO) { Developer developer = GenericConverter.mapper(developerDTO, Developer.class); Example<Developer> example = Example.of(developer, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Developer> page = developerRepository.findAll(example, pageable); DeveloperPage developerPage = new DeveloperPage(PageDTO.build(page)); return developerPage; }  Developer find(Long id); Developer login(DeveloperLogin developerLogin); DeveloperPage list(DeveloperDTO developerDTO, PageableDTO pageableDTO); List<Developer> list(DeveloperDTO developerDTO); @Transactional Developer save(DeveloperDTO developerDTO); @Transactional Developer update(Long id, DeveloperDTO developerDTO); @Transactional void delete(Long id);  }
@Test public void listPageable() { PageableDTO pageableDTO = new PageableDTO(); pageableDTO.setLimit(10); pageableDTO.setOffset(0); List<Developer> developers = new ArrayList<>(); developers.add(developer); Page<Developer> page = new PageImpl<>(developers); Mockito.when(developerRepository.findAll(Mockito.any(), Mockito.any(Pageable.class))).thenReturn(page); DeveloperPage list = developerService.list(developerDTO, pageableDTO); List<Developer> content = list.getContent(); assertEquals(developers, content); }
@Test public void listArray() { PageableDTO pageableDTO = new PageableDTO(); pageableDTO.setLimit(10); pageableDTO.setOffset(0); List<Developer> developers = new ArrayList<>(); developers.add(developer); Mockito.when(developerRepository.findAll(Mockito.any(Example.class))).thenReturn(developers); List<Developer> developersResult = developerService.list(developerDTO); assertEquals(developers, developersResult); }