List of usage examples for org.springframework.data.domain PageImpl PageImpl
public PageImpl(List<T> content)
From source file:curly.commons.web.hateoas.PageProcessor.java
public static <T> Page<T> toPage(PagedResources<T> res) { Assert.notNull(res, "Resources content must be not null"); PageMetadata metadata = res.getMetadata(); if (res.getContent().isEmpty()) return new PageImpl<T>(Collections.emptyList()); return new PageImpl<>(new ArrayList<>(res.getContent()), new PageRequest((int) metadata.getNumber(), (int) metadata.getSize()), metadata.getTotalElements()); }
From source file:com.trenako.results.PaginatedLists.java
private static <T> Page<T> failbackPage() { List<T> empty = Collections.emptyList(); return new PageImpl<>(empty); }
From source file:com.expedia.seiso.domain.repo.impl.RepoImplUtils.java
@SuppressWarnings("unchecked") public <T> Page<T> search(@NotNull String entityName, @NotNull EntityManager entityManager, @NonNull Set<String> fieldNames, @NotNull Set<String> searchTokens, Pageable pageable) { // Set max results to avoid huge search queries. List<T> items = new QueryFactory().buildQuery(entityName, entityManager, fieldNames, searchTokens) .setMaxResults(50).getResultList(); return new PageImpl<T>(items); }
From source file:se.inera.axel.rivssek.webconsole.RivSsekServiceMappingPageTest.java
@Override protected void beforeMethodSetup() { super.beforeMethodSetup(); RivSsekServiceMappingRepository rivSsekServiceMappingRepository = mock( RivSsekServiceMappingRepository.class); when(rivSsekServiceMappingRepository.findAll(any(Pageable.class))) .thenReturn(new PageImpl<>(Arrays.asList(new RivSsekServiceMapping.Builder().address("http://test") .ssekReceiverType(IdType.CN).ssekReceiver("ssekReceiver") .rivServiceNamespace("exampleRivNamespace").rivLogicalAddress("12345678-0000").build()))); injector.registerBean("rivSsekServiceMappingRepository", rivSsekServiceMappingRepository); }
From source file:us.repasky.microblog.controllers.UserControllerTest.java
private static final Page<Post> getPagesOfPosts() { final Post post = new Post(); post.setMessage("some post message"); List<Post> posts = new ArrayList<Post>() { private static final long serialVersionUID = -4134372530010086050L; {/*from ww w. ja v a2s . c o m*/ add(post); } }; Page<Post> pagesOfPosts = new PageImpl<Post>(posts); return pagesOfPosts; }
From source file:org.macula.cart.admin.demo.controller.DempApplicationController.java
@RequestMapping(value = "/application/apps", method = RequestMethod.GET) @OpenApi//www . j a v a 2s . com public Page<DemoApplication> getApplications() { return new PageImpl<DemoApplication>(demoApplicationService.getAllApplications()); }
From source file:org.openlmis.fulfillment.service.PageDto.java
public PageDto() { this(new PageImpl<>(new ArrayList<>())); }
From source file:com.nebhale.buildmonitor.web.notify.MessagingBuildsChangedNotifierTest.java
@Test @SuppressWarnings("unchecked") public void BuildsChanged() { Project project = new Project("TEST-KEY", "Test Name"); Build build1 = new Build(project, "test-uri-1", Build.State.FAIL); Build build2 = new Build(project, "test-uri-2", Build.State.FAIL); Resource<Build> resource1 = new Resource<>(build1); Resource<Build> resource2 = new Resource<>(build2); when(this.repository.findAllByProjectOrderByCreatedDesc(project, new PageRequest(0, 10))) .thenReturn(new PageImpl<>(Arrays.asList(build1, build2))); when(this.resourceAssembler.toResource(build1)).thenReturn(resource1); when(this.resourceAssembler.toResource(build2)).thenReturn(resource2); this.notifier.buildsChanged(project); verify(this.messageTemplate).convertAndSend("/app/projects/TEST-KEY/builds", Arrays.asList(resource1, resource2)); }
From source file:it.f2informatica.pagination.services.MongoDBPaginationServiceImpl.java
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public String getEmptyPaginatedResultAsJson(QueryParameters parameters) { return gson.toJson( paginationResponse.generateResponseAttributes(parameters, new PageImpl(Lists.newArrayList()))); }
From source file:it.f2informatica.test.services.domain.consultant.ConsultantServiceTest.java
private Page<ConsultantModel> consultants() { return new PageImpl<>( Arrays.asList(consultantModel().withFirstName("consultant_1").withLastName("consultant_1").build(), consultantModel().withFirstName("consultant_2").withLastName("consultant_2").build())); }