@Test public void listResources() { List<Resource> resources = new ArrayList<>(); resources.add(resource); Mockito.when(this.apiRepository.findOne(1L)).thenReturn(api); Mockito.when(this.resourceRepository.findAll(Mockito.any(Example.class))).thenReturn(resources); List<Resource> environmentResp = this.resourceService.list(1L, this.resourceDTO); assertEquals(resources.size(), environmentResp.size()); Mockito.verify(this.resourceRepository, Mockito.times(1)).findAll(Mockito.any(Example.class)); }
public ResourcePage list(Long apiId, ResourceDTO resourceDTO, PageableDTO pageableDTO) { Api api = apiRepository.findOne(apiId); HeimdallException.checkThrow(api == null, GLOBAL_RESOURCE_NOT_FOUND); Resource resource = GenericConverter.mapper(resourceDTO, Resource.class); resource.setApi(api); Example<Resource> example = Example.of(resource, ExampleMatcher.matching().withIgnorePaths("api.creationDate").withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Resource> page = resourceRepository.findAll(example, pageable); ResourcePage resourcePage = new ResourcePage(PageDTO.build(page)); return resourcePage; }
ResourceService { public ResourcePage list(Long apiId, ResourceDTO resourceDTO, PageableDTO pageableDTO) { Api api = apiRepository.findOne(apiId); HeimdallException.checkThrow(api == null, GLOBAL_RESOURCE_NOT_FOUND); Resource resource = GenericConverter.mapper(resourceDTO, Resource.class); resource.setApi(api); Example<Resource> example = Example.of(resource, ExampleMatcher.matching().withIgnorePaths("api.creationDate").withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Resource> page = resourceRepository.findAll(example, pageable); ResourcePage resourcePage = new ResourcePage(PageDTO.build(page)); return resourcePage; } }
ResourceService { public ResourcePage list(Long apiId, ResourceDTO resourceDTO, PageableDTO pageableDTO) { Api api = apiRepository.findOne(apiId); HeimdallException.checkThrow(api == null, GLOBAL_RESOURCE_NOT_FOUND); Resource resource = GenericConverter.mapper(resourceDTO, Resource.class); resource.setApi(api); Example<Resource> example = Example.of(resource, ExampleMatcher.matching().withIgnorePaths("api.creationDate").withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Resource> page = resourceRepository.findAll(example, pageable); ResourcePage resourcePage = new ResourcePage(PageDTO.build(page)); return resourcePage; }  }
ResourceService { public ResourcePage list(Long apiId, ResourceDTO resourceDTO, PageableDTO pageableDTO) { Api api = apiRepository.findOne(apiId); HeimdallException.checkThrow(api == null, GLOBAL_RESOURCE_NOT_FOUND); Resource resource = GenericConverter.mapper(resourceDTO, Resource.class); resource.setApi(api); Example<Resource> example = Example.of(resource, ExampleMatcher.matching().withIgnorePaths("api.creationDate").withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Resource> page = resourceRepository.findAll(example, pageable); ResourcePage resourcePage = new ResourcePage(PageDTO.build(page)); return resourcePage; }  @Transactional(readOnly = true) Resource find(Long apiId, Long resourceId); ResourcePage list(Long apiId, ResourceDTO resourceDTO, PageableDTO pageableDTO); List<Resource> list(Long apiId, ResourceDTO resourceDTO); Resource save(Long apiId, ResourceDTO resourceDTO); Resource save(Long apiId, Resource resource); Resource update(Long apiId, Long resourceId, ResourceDTO resourceDTO); void delete(Long apiId, Long resourceId); void deleteAllFromApi(Long apiId); }
ResourceService { public ResourcePage list(Long apiId, ResourceDTO resourceDTO, PageableDTO pageableDTO) { Api api = apiRepository.findOne(apiId); HeimdallException.checkThrow(api == null, GLOBAL_RESOURCE_NOT_FOUND); Resource resource = GenericConverter.mapper(resourceDTO, Resource.class); resource.setApi(api); Example<Resource> example = Example.of(resource, ExampleMatcher.matching().withIgnorePaths("api.creationDate").withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Resource> page = resourceRepository.findAll(example, pageable); ResourcePage resourcePage = new ResourcePage(PageDTO.build(page)); return resourcePage; }  @Transactional(readOnly = true) Resource find(Long apiId, Long resourceId); ResourcePage list(Long apiId, ResourceDTO resourceDTO, PageableDTO pageableDTO); List<Resource> list(Long apiId, ResourceDTO resourceDTO); Resource save(Long apiId, ResourceDTO resourceDTO); Resource save(Long apiId, Resource resource); Resource update(Long apiId, Long resourceId, ResourceDTO resourceDTO); void delete(Long apiId, Long resourceId); void deleteAllFromApi(Long apiId);  }