use of org.springframework.data.domain.Pageable in project goci by EBISPOT.
the class AssociationControllerTest method viewStudySnps.
@Test
public void viewStudySnps() throws Exception {
SnpAssociationTableView snpAssociationTableView = new SnpAssociationTableView();
LastViewedAssociation lastViewedAssociation = new LastViewedAssociation();
Pageable pagination = new PageRequest(0, 100);
List<Association> list = new ArrayList<Association>();
list.add(ASSOCIATION);
Page<Association> returnPage = new PageImpl<Association>(list, pagination, list.size());
when(associationRepository.findByStudyId(STUDY.getId(), pagination)).thenReturn(returnPage);
when(snpAssociationTableViewService.createSnpAssociationTableView(ASSOCIATION)).thenReturn(snpAssociationTableView);
when(associationOperationsService.getLastViewedAssociation(Matchers.anyLong())).thenReturn(lastViewedAssociation);
when(studyRepository.findOne(Matchers.anyLong())).thenReturn(STUDY);
mockMvc.perform(get("/studies/1234/associations").accept(MediaType.TEXT_HTML_VALUE)).andExpect(status().isOk()).andExpect(model().attribute("snpAssociationTableViews", hasSize(1))).andExpect(model().attribute("snpAssociationTableViews", instanceOf(Collection.class))).andExpect(model().attribute("lastViewedAssociation", instanceOf(LastViewedAssociation.class))).andExpect(model().attribute("totalAssociations", 1L)).andExpect(model().attributeExists("study")).andExpect(view().name("study_association"));
verify(associationRepository, times(1)).findByStudyId(STUDY.getId(), pagination);
verify(snpAssociationTableViewService, times(1)).createSnpAssociationTableView(ASSOCIATION);
verify(associationOperationsService, times(1)).getLastViewedAssociation(Matchers.anyLong());
verify(studyRepository, times(1)).findOne(Matchers.anyLong());
}
use of org.springframework.data.domain.Pageable in project spring-petclinic by spring-projects.
the class VetController method findPaginated.
private Page<Vet> findPaginated(int page) {
int pageSize = 5;
Pageable pageable = PageRequest.of(page - 1, pageSize);
return vets.findAll(pageable);
}
use of org.springframework.data.domain.Pageable in project spring-petclinic by spring-projects.
the class OwnerController method findPaginatedForOwnersLastName.
private Page<Owner> findPaginatedForOwnersLastName(int page, String lastname) {
int pageSize = 5;
Pageable pageable = PageRequest.of(page - 1, pageSize);
return owners.findByLastName(lastname, pageable);
}
use of org.springframework.data.domain.Pageable in project fastjson by alibaba.
the class Issue2752 method test_for_issue.
public void test_for_issue() {
Pageable pageRequest = new PageRequest(0, 10, new Sort(new Sort.Order("id, desc")));
SerializeConfig config = new SerializeConfig();
config.register(new MyModule());
String result = JSON.toJSONString(pageRequest, config);
assertTrue(result.indexOf("\"property\":\"id, desc\"") != -1);
}
use of org.springframework.data.domain.Pageable in project c4sg-services by Code4SocialGood.
the class OrganizationServiceImpl method findByCriteria.
public Page<OrganizationDTO> findByCriteria(String keyWord, List<String> countries, Boolean open, String status, List<String> categories, Integer page, Integer size) {
Page<Organization> organizationPages;
List<Organization> organizations = null;
if (page == null)
page = 0;
if (size == null) {
if (countries == null || countries.isEmpty()) {
if (open == null) {
if (categories != null) {
organizations = organizationDAO.findByCriteria(keyWord, open, status, categories);
} else {
organizations = organizationDAO.findByCriteriaNoCategoriesFilter(keyWord, open, status);
}
} else {
if (categories == null) {
organizations = organizationDAO.findByCriteriaAndOpenNoCategoriesFilter(keyWord, open, status);
} else {
organizations = organizationDAO.findByCriteriaAndOpen(keyWord, open, status, categories);
}
}
} else {
if (open == null) {
if (categories != null) {
organizations = organizationDAO.findByCriteriaAndCountries(keyWord, countries, open, status, categories);
}
} else {
organizations = organizationDAO.findByCriteriaAndCountriesAndOpen(keyWord, countries, open, status, categories);
}
}
organizationPages = new PageImpl<>(organizations);
return organizationPages.map(o -> organizationMapper.getOrganizationDtoFromEntity(o));
}
Pageable pageable = new PageRequest(page, size);
if (countries == null || countries.isEmpty()) {
if (open == null) {
if (categories == null) {
organizationPages = organizationDAO.findByCriteriaNoCategoriesFilter(keyWord, open, status, pageable);
} else {
organizationPages = organizationDAO.findByCriteria(keyWord, open, status, categories, pageable);
}
} else {
if (categories == null) {
organizationPages = organizationDAO.findByCriteriaAndOpenNoCategoriesFilter(keyWord, open, status, pageable);
} else {
organizationPages = organizationDAO.findByCriteriaAndOpen(keyWord, open, status, categories, pageable);
}
}
} else if (open == null) {
organizationPages = organizationDAO.findByCriteriaAndCountries(keyWord, countries, open, status, categories, pageable);
} else {
organizationPages = organizationDAO.findByCriteriaAndCountriesAndOpen(keyWord, countries, open, status, categories, pageable);
}
return organizationPages.map(o -> organizationMapper.getOrganizationDtoFromEntity(o));
}
Aggregations