ProviderService { public ProviderPage listWithPageableAndFilter(ProviderDTO providerDTO, PageableDTO pageableDTO) { Provider provider = GenericConverter.mapper(providerDTO, Provider.class); Example<Provider> example = Example.of(provider, ExampleMatcher.matching().withIgnorePaths("providerDefault").withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Provider> page = this.providerRepository.findAll(example, pageable); return new ProviderPage(PageDTO.build(page)); }  Provider save(ProviderDTO providerPersist); @Transactional Provider edit(Long idProvider, ProviderDTO providerEdit); ProviderPage listWithPageableAndFilter(ProviderDTO providerDTO, PageableDTO pageableDTO); List<Provider> listWithFilter(ProviderDTO providerDTO); Provider findOne(Long id); void delete(Long id);  }
@SuppressWarnings("unchecked") @Test public void testListWithPageableAndFilter() { PageableDTO pageableDTO = new PageableDTO(); pageableDTO.setLimit(10); pageableDTO.setOffset(0); ArrayList<Provider> listProviders = new ArrayList<>(); this.providerDatabase.setName("Provider Authentication"); listProviders.add(providerDatabase); Page<Provider> page = new PageImpl<>(listProviders); Mockito.when(this.providerRepository.findAll(Mockito.any(Example.class), Mockito.any(Pageable.class))).thenReturn(page); ProviderPage providerPageResp = this.providerService.listWithPageableAndFilter(this.providerDTO, pageableDTO); assertEquals(1L, providerPageResp.getTotalElements()); Mockito.verify(this.providerRepository, Mockito.times(1)).findAll(Mockito.any(Example.class), Mockito.any(Pageable.class)); }