@Test public void listAccessTokensWithPageableTest() { PageableDTO pageableDTO = new PageableDTO(); pageableDTO.setLimit(10); pageableDTO.setOffset(0); ArrayList<AccessToken> listTokens = new ArrayList<>(); AccessToken token = new AccessToken(); AccessTokenRequest accessTokenRequest = new AccessTokenRequest(); listTokens.add(token); Page<AccessToken> page = new PageImpl<>(listTokens); Mockito.when(this.accessTokenRepository.findAll(Mockito.any(Example.class), Mockito.any(Pageable.class))) .thenReturn(page); AccessTokenPage planPageResp = this.service.list(accessTokenRequest, pageableDTO); assertEquals(1L, planPageResp.getTotalElements()); Mockito.verify(this.accessTokenRepository, Mockito.times(1)) .findAll(Mockito.any(Example.class), Mockito.any(Pageable.class)); }
@Transactional(readOnly = true) public AccessTokenPage list(AccessTokenRequest accessTokenRequest, PageableDTO pageableDTO) { AccessToken accessToken = GenericConverter.mapper(accessTokenRequest, AccessToken.class); Example<AccessToken> example = Example.of(accessToken, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<AccessToken> page = accessTokenRepository.findAll(example, pageable); AccessTokenPage accessTokenPage = new AccessTokenPage(PageDTO.build(page)); return accessTokenPage; }
AccessTokenService { @Transactional(readOnly = true) public AccessTokenPage list(AccessTokenRequest accessTokenRequest, PageableDTO pageableDTO) { AccessToken accessToken = GenericConverter.mapper(accessTokenRequest, AccessToken.class); Example<AccessToken> example = Example.of(accessToken, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<AccessToken> page = accessTokenRepository.findAll(example, pageable); AccessTokenPage accessTokenPage = new AccessTokenPage(PageDTO.build(page)); return accessTokenPage; } }
AccessTokenService { @Transactional(readOnly = true) public AccessTokenPage list(AccessTokenRequest accessTokenRequest, PageableDTO pageableDTO) { AccessToken accessToken = GenericConverter.mapper(accessTokenRequest, AccessToken.class); Example<AccessToken> example = Example.of(accessToken, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<AccessToken> page = accessTokenRepository.findAll(example, pageable); AccessTokenPage accessTokenPage = new AccessTokenPage(PageDTO.build(page)); return accessTokenPage; }  }
AccessTokenService { @Transactional(readOnly = true) public AccessTokenPage list(AccessTokenRequest accessTokenRequest, PageableDTO pageableDTO) { AccessToken accessToken = GenericConverter.mapper(accessTokenRequest, AccessToken.class); Example<AccessToken> example = Example.of(accessToken, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<AccessToken> page = accessTokenRepository.findAll(example, pageable); AccessTokenPage accessTokenPage = new AccessTokenPage(PageDTO.build(page)); return accessTokenPage; }  @Transactional(readOnly = true) AccessToken find(Long id); @Transactional(readOnly = true) AccessTokenPage list(AccessTokenRequest accessTokenRequest, PageableDTO pageableDTO); @Transactional(readOnly = true) List<AccessToken> list(AccessTokenRequest accessTokenRequest); @Transactional AccessToken save(AccessTokenPersist accessTokenPersist); @Transactional AccessToken update(Long id, AccessTokenPersist accessTokenPersist); @Transactional void delete(Long id); @Transactional AccessToken save(AccessTokenDTO reqBody); }
AccessTokenService { @Transactional(readOnly = true) public AccessTokenPage list(AccessTokenRequest accessTokenRequest, PageableDTO pageableDTO) { AccessToken accessToken = GenericConverter.mapper(accessTokenRequest, AccessToken.class); Example<AccessToken> example = Example.of(accessToken, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<AccessToken> page = accessTokenRepository.findAll(example, pageable); AccessTokenPage accessTokenPage = new AccessTokenPage(PageDTO.build(page)); return accessTokenPage; }  @Transactional(readOnly = true) AccessToken find(Long id); @Transactional(readOnly = true) AccessTokenPage list(AccessTokenRequest accessTokenRequest, PageableDTO pageableDTO); @Transactional(readOnly = true) List<AccessToken> list(AccessTokenRequest accessTokenRequest); @Transactional AccessToken save(AccessTokenPersist accessTokenPersist); @Transactional AccessToken update(Long id, AccessTokenPersist accessTokenPersist); @Transactional void delete(Long id); @Transactional AccessToken save(AccessTokenDTO reqBody);  }