@Test public void listEnvironments() { List<Environment> environments = new ArrayList<>(); environments.add(environment); Mockito.when(this.environmentRepository.findAll(Mockito.any(Example.class))) .thenReturn(environments); List<Environment> environmentResp = this.environmentService.list(this.environmentDTO); assertEquals(environments.size(), environmentResp.size()); Mockito.verify(this.environmentRepository, Mockito.times(1)).findAll(Mockito.any(Example.class)); }
public EnvironmentPage list(EnvironmentDTO environmentDTO, PageableDTO pageableDTO) { Environment environment = GenericConverter.mapper(environmentDTO, Environment.class); Example<Environment> example = Example.of(environment, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Environment> page = environmentRepository.findAll(example, pageable); return new EnvironmentPage(PageDTO.build(page)); }
EnvironmentService { public EnvironmentPage list(EnvironmentDTO environmentDTO, PageableDTO pageableDTO) { Environment environment = GenericConverter.mapper(environmentDTO, Environment.class); Example<Environment> example = Example.of(environment, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Environment> page = environmentRepository.findAll(example, pageable); return new EnvironmentPage(PageDTO.build(page)); } }
EnvironmentService { public EnvironmentPage list(EnvironmentDTO environmentDTO, PageableDTO pageableDTO) { Environment environment = GenericConverter.mapper(environmentDTO, Environment.class); Example<Environment> example = Example.of(environment, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Environment> page = environmentRepository.findAll(example, pageable); return new EnvironmentPage(PageDTO.build(page)); }  }
EnvironmentService { public EnvironmentPage list(EnvironmentDTO environmentDTO, PageableDTO pageableDTO) { Environment environment = GenericConverter.mapper(environmentDTO, Environment.class); Example<Environment> example = Example.of(environment, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Environment> page = environmentRepository.findAll(example, pageable); return new EnvironmentPage(PageDTO.build(page)); }  Environment find(Long id); EnvironmentPage list(EnvironmentDTO environmentDTO, PageableDTO pageableDTO); List<Environment> list(EnvironmentDTO environmentDTO); @Transactional Environment save(EnvironmentDTO environmentDTO); @Transactional Environment update(Long id, EnvironmentDTO environmentDTO); @Transactional void delete(Long id); }
EnvironmentService { public EnvironmentPage list(EnvironmentDTO environmentDTO, PageableDTO pageableDTO) { Environment environment = GenericConverter.mapper(environmentDTO, Environment.class); Example<Environment> example = Example.of(environment, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Environment> page = environmentRepository.findAll(example, pageable); return new EnvironmentPage(PageDTO.build(page)); }  Environment find(Long id); EnvironmentPage list(EnvironmentDTO environmentDTO, PageableDTO pageableDTO); List<Environment> list(EnvironmentDTO environmentDTO); @Transactional Environment save(EnvironmentDTO environmentDTO); @Transactional Environment update(Long id, EnvironmentDTO environmentDTO); @Transactional void delete(Long id);  }