List of usage examples for org.springframework.data.domain PageImpl PageImpl
public PageImpl(List<T> content)
From source file:com.frank.search.solr.core.query.result.SolrResultPage.java
public final void setFacetQueryResultPage(List<FacetQueryEntry> facetQueryResult) { this.facetQueryResult = new PageImpl<FacetQueryEntry>(facetQueryResult); }
From source file:com.frank.search.solr.core.query.result.SolrResultPage.java
@Override public Page<FacetQueryEntry> getFacetQueryResult() { return this.facetQueryResult != null ? this.facetQueryResult : new PageImpl<FacetQueryEntry>(Collections.<FacetQueryEntry>emptyList()); }
From source file:com.alliander.osgp.acceptancetests.basicfunctions.VerifyAuthorizePlatformFunctionSteps.java
@DomainStep("an organisation which is member of platform function group (.*)") public void givenAnAuthenticatedOrganisation(final String group) { this.setUp(); this.organisation = new OrganisationBuilder().withOrganisationIdentification(ORGANISATION) .withFunctionGroup(com.alliander.osgp.domain.core.valueobjects.PlatformFunctionGroup .valueOf(group.toUpperCase())) .build();/*from w ww. j ava 2 s .com*/ when(this.organisationRepositoryMock.findByOrganisationIdentification(ORGANISATION)) .thenReturn(this.organisation); when(this.logItemRepositoryMock.findAll(any(Pageable.class))) .thenReturn(new PageImpl<>(new ArrayList<DeviceLogItem>())); }
From source file:de.rahn.finances.server.web.ui.SecuritiesControllerTest.java
/** * Test method for {@link SecuritiesController#securityTypeList()}. *//*from w ww . ja va2s .c om*/ @Test public void testAttributeModelSecurityTypeList() throws Exception { when(securitiesService.getSecurities(anyBoolean(), any())).thenReturn(new PageImpl<>(emptyList())); mockMvc.perform(get("/securities")).andExpect(status().isOk()) .andExpect(model().attribute("securityTypeList", notNullValue())); }
From source file:com._4dconcept.springframework.data.marklogic.repository.support.SimpleMarklogicRepository.java
@Override public Page<T> findAll(Pageable pageable) { Query query = newQueryBuilderInstance().options(new MarklogicOperationOptions() { @Override/*from w w w .j a v a 2s.c o m*/ public Class entityClass() { return entityInformation.getJavaType(); } }).with(pageable).build(); long count = marklogicOperations.count(query); if (count == 0) { return new PageImpl<>(Collections.emptyList()); } return new PageImpl<>(marklogicOperations.find(query, entityInformation.getJavaType()), pageable, count); }
From source file:org.terasoluna.tourreservation.app.searchtour.SearchTourControllerTest.java
/** * This method tests the success case of Search operation. <br> * </p>//from ww w. ja v a 2 s .c o m */ @Test public void testSearchSuccess() { MockHttpServletRequestBuilder getRequest = MockMvcRequestBuilders.get("/searchtour/search"); // Set mock behavior for service method when(tourInfoService.searchTour((TourInfoSearchCriteria) anyObject(), (Pageable) anyObject())) .thenReturn(new PageImpl<TourInfo>(new ArrayList<TourInfo>())); DateTime dateTime = dateFactory.newDateTime(); DateTime nextWeekDate = dateTime.plusWeeks(1); getRequest.param("depYear", String.valueOf(nextWeekDate.getYear())); getRequest.param("depMonth", String.valueOf(nextWeekDate.getMonthOfYear())); getRequest.param("depDay", String.valueOf(nextWeekDate.getDayOfMonth())); getRequest.param("tourDays", "2"); getRequest.param("adultCount", "2"); getRequest.param("childCount", "2"); getRequest.param("basePrice", "2"); getRequest.param("depCode", "01"); getRequest.param("arrCode", "02"); try { ResultActions results = mockMvc.perform(getRequest); results.andExpect(status().isOk()); results.andExpect(view().name("searchtour/searchForm")); results.andExpect(model().hasNoErrors()); return; } catch (Exception e) { e.printStackTrace(); } fail(); // FAIL when exception is thrown }
From source file:org.openlmis.fulfillment.service.BaseCommunicationServiceTest.java
private void mockPageResponseEntity(Object dto) { ResponseEntity<PageDto<T>> response = stubRestTemplateAndGetPageResponseEntity(); doReturn(new PageDto<>(new PageImpl<>(ImmutableList.of(dto)))).when(response).getBody(); }
From source file:org.jblogcms.core.post.service.PostServiceImpl.java
@Override @Transactional(readOnly = true)//from ww w. jav a 2 s . c om public Page<Post> findFeedPosts(Pageable pageable, Long currentAccountId) { List<BlogRelation> blogRelations = blogRelationService.getBlogRelations(currentAccountId); Page<Post> posts = new PageImpl<Post>(new ArrayList<Post>()); if (!blogRelations.isEmpty()) { List<Long> blogIds = new ArrayList<>(blogRelations.size()); for (BlogRelation blogRelation : blogRelations) { blogIds.add(blogRelation.getItem().getId()); } posts = postRepository.findPostsByBlogIds(blogIds, pageable); posts = postToolService.addItemRatesToItemPage(posts, currentAccountId); posts = postToolService.addItemRelationsToItemPage(posts, currentAccountId); } return posts; }
From source file:de.appsolve.padelcampus.db.dao.generic.BaseEntityDAO.java
@Override public Page<T> findAllByFuzzySearch(String search, Set<Criterion> criterions, String... associations) { Criteria criteria = getCriteria();/*w w w .j av a 2 s .c om*/ for (String association : associations) { criteria.setFetchMode(association, FetchMode.JOIN); } List<Criterion> predicates = new ArrayList<>(); for (String indexedPropery : getIndexedProperties()) { if (!StringUtils.isEmpty(search)) { String[] searchTerms = search.split(" "); for (String searchTerm : searchTerms) { predicates.add(Restrictions.ilike(indexedPropery, searchTerm, MatchMode.ANYWHERE)); } } } if (!predicates.isEmpty()) { criteria.add(Restrictions.or(predicates.toArray(new Criterion[predicates.size()]))); } if (criterions != null) { for (Criterion c : criterions) { criteria.add(c); } } criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); @SuppressWarnings("unchecked") List<T> objects = criteria.list(); sort(objects); PageImpl<T> page = new PageImpl<>(objects); return page; }
From source file:it.reply.orchestrator.controller.DeploymentControllerTest.java
@Test public void getDeployments() throws Exception { List<Deployment> deployments = ControllerTestUtils.createDeployments(2, true); deployments.get(0).setStatus(Status.CREATE_FAILED); deployments.get(0).setStatusReason("Some reason"); deployments.get(1).setStatus(Status.CREATE_COMPLETE); Pageable pageable = ControllerTestUtils.createDefaultPageable(); Mockito.when(deploymentService.getDeployments(pageable)).thenReturn(new PageImpl<Deployment>(deployments)); mockMvc.perform(get("/deployments").accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, OAuth2AccessToken.BEARER_TYPE + " <access token>")).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(document("authentication", requestHeaders(// w w w .j a va2s. co m headerWithName(HttpHeaders.AUTHORIZATION).description("OAuth2 bearer token")))) .andDo(document("deployments", preprocessResponse(prettyPrint()), responseFields(fieldWithPath("links[]").ignored(), fieldWithPath("content[].uuid").description("The unique identifier of a resource"), fieldWithPath("content[].creationTime").description( "Creation date-time (http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14)"), fieldWithPath("content[].updateTime").description("Update date-time"), fieldWithPath("content[].status").description( "The status of the deployment. (http://indigo-dc.github.io/orchestrator/apidocs/it/reply/orchestrator/enums/Status.html)"), fieldWithPath("content[].statusReason").description( "Verbose explanation of reason that lead to the deployment status (Present only if the deploy is in some error status)"), fieldWithPath("content[].task").description( "The current step of the deployment process. (http://indigo-dc.github.io/orchestrator/apidocs/it/reply/orchestrator/enums/Task.html)"), fieldWithPath("content[].callback").description( "The endpoint used by the orchestrator to notify the progress of the deployment process."), fieldWithPath("content[].outputs").description("The outputs of the TOSCA document"), fieldWithPath("content[].links[]").ignored(), fieldWithPath("page").ignored()))); }