use of uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation 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 uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation in project goci by EBISPOT.
the class AssociationController method viewStudySnps.
/* Study SNP/Associations */
// Generate list of SNP associations linked to a study
@RequestMapping(value = "/studies/{studyId}/associations", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewStudySnps(Model model, @PathVariable Long studyId, @RequestParam(required = false) Long associationId) {
// Get all associations for a study
Collection<Association> associations = associationRepository.findByStudyId(studyId);
// For our associations create a table view object and return
Collection<SnpAssociationTableView> snpAssociationTableViews = new ArrayList<SnpAssociationTableView>();
for (Association association : associations) {
SnpAssociationTableView snpAssociationTableView = snpAssociationTableViewService.createSnpAssociationTableView(association);
snpAssociationTableViews.add(snpAssociationTableView);
}
model.addAttribute("snpAssociationTableViews", snpAssociationTableViews);
// Determine last viewed association
LastViewedAssociation lastViewedAssociation = associationOperationsService.getLastViewedAssociation(associationId);
model.addAttribute("lastViewedAssociation", lastViewedAssociation);
// Pass back count of associations
Integer totalAssociations = associations.size();
model.addAttribute("totalAssociations", totalAssociations);
// Also passes back study object to view so we can create links back to main study page
model.addAttribute("study", studyRepository.findOne(studyId));
return "study_association";
}
use of uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation in project goci by EBISPOT.
the class AssociationController method viewStudySnps.
/* Study SNP/Associations */
// Generate list of SNP associations linked to a study
@RequestMapping(value = "/studies/{studyId}/associations", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewStudySnps(Model model, @PathVariable Long studyId, @RequestParam(required = false) Long associationId, @RequestParam(defaultValue = "1", required = false) Integer page) {
// Get all associations for a study - ORIGINAL
// Collection<Association> associations = associationRepository.findByStudyId(studyId);
// Get pages of associations
Page<Association> associations = associationRepository.findByStudyId(studyId, constructPageSpecification(page - 1));
// For our associations create a table view object and return
Collection<SnpAssociationTableView> snpAssociationTableViews = new ArrayList<SnpAssociationTableView>();
for (Association association : associations) {
SnpAssociationTableView snpAssociationTableView = snpAssociationTableViewService.createSnpAssociationTableView(association);
snpAssociationTableViews.add(snpAssociationTableView);
}
model.addAttribute("snpAssociationTableViews", snpAssociationTableViews);
// Determine last viewed association
LastViewedAssociation lastViewedAssociation = associationOperationsService.getLastViewedAssociation(associationId);
model.addAttribute("lastViewedAssociation", lastViewedAssociation);
// Pass back count of associations
// Integer totalAssociations = associations.size();
long totalAssociations;
totalAssociations = associations.getTotalElements();
model.addAttribute("totalAssociations", totalAssociations);
// Also passes back study object to view so we can create links back to main study page
model.addAttribute("study", studyRepository.findOne(studyId));
if (page == 1) {
return "study_association";
} else {
return "study_association_by_page";
}
}
Aggregations