Search in sources :

Example 11 with DataTablesResponse

use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse in project irida by phac-nml.

the class AnalysesListingServiceTest method testGetPagedSubmissionsForAdmin.

@Test
public void testGetPagedSubmissionsForAdmin() throws IridaWorkflowNotFoundException, ExecutionManagerException {
    String searchValue = "";
    DataTablesParams params = new DataTablesParams(1, 10, 1, searchValue, new Sort(Sort.Direction.ASC, "id"), ImmutableMap.of());
    when(analysisSubmissionService.listAllSubmissions(eq(searchValue), any(String.class), eq(null), Matchers.any(), Matchers.any())).thenReturn(AnalysesDataFactory.getPagedAnalysisSubmissions());
    DataTablesResponse response = analysesListingService.getPagedSubmissions(params, Locale.US, null, null);
    assertEquals("DataTables response should have a draw value of 1", 1, response.getDraw());
    assertEquals("DataTables response should have a records filtered value of 150", 150, response.getRecordsFiltered());
    assertEquals("DataTables response should have a records total value of 150", 150, response.getRecordsTotal());
    assertTrue("Should have data value", response.getData() != null);
    verify(analysisSubmissionService).listAllSubmissions(eq(searchValue), any(String.class), eq(null), Matchers.any(), Matchers.any());
}
Also used : Sort(org.springframework.data.domain.Sort) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) DataTablesParams(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams) Test(org.junit.Test)

Example 12 with DataTablesResponse

use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse in project irida by phac-nml.

the class ProjectsControllerTest method testGetAjaxAdminProjectsList.

@Test
public void testGetAjaxAdminProjectsList() {
    when(projectService.findAllProjects(any(String.class), any(Integer.class), any(Integer.class), any(Sort.class))).thenReturn(getProjectPage());
    when(sampleService.getSamplesForProject(any(Project.class))).thenReturn(TestDataFactory.constructListJoinProjectSample());
    DataTablesParams params = new DataTablesParams(0, 10, 1, "", new Sort(Sort.Direction.ASC, "modifiedDate"), new HashMap<>());
    DataTablesResponse response = controller.getAjaxAdminProjectsList(params);
    assertEquals("Should have 10 data elements, since page size is 10", 10, response.getData().size());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sort(org.springframework.data.domain.Sort) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) Matchers.anyString(org.mockito.Matchers.anyString) DataTablesParams(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams) Test(org.junit.Test)

Example 13 with DataTablesResponse

use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse in project irida by phac-nml.

the class ClientsControllerTest method testGetAjaxClientList.

@SuppressWarnings("unchecked")
@Test
public void testGetAjaxClientList() {
    IridaClientDetails client1 = new IridaClientDetails();
    client1.setId(1L);
    IridaClientDetails client2 = new IridaClientDetails();
    client2.setId(2L);
    Page<IridaClientDetails> clientPage = new PageImpl<>(Lists.newArrayList(client1, client2));
    when(clientDetailsService.search(any(Specification.class), any(PageRequest.class))).thenReturn(clientPage);
    DataTablesParams params = new DataTablesParams(1, 10, 1, "", new Sort(Sort.Direction.ASC, "createdDate"), new HashMap<>());
    DataTablesResponse response = controller.getAjaxClientsList(params);
    List<DataTablesResponseModel> models = response.getData();
    assertEquals(2, models.size());
    verify(clientDetailsService).search(any(Specification.class), any(PageRequest.class));
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) PageRequest(org.springframework.data.domain.PageRequest) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) Sort(org.springframework.data.domain.Sort) Specification(org.springframework.data.jpa.domain.Specification) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) IridaClientDetails(ca.corefacility.bioinformatics.irida.model.IridaClientDetails) DataTablesParams(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams) Test(org.junit.Test)

Example 14 with DataTablesResponse

use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse in project irida by phac-nml.

the class AnalysesListingServiceTest method testGetPagedSubmissionsForProject.

@Test
public void testGetPagedSubmissionsForProject() throws IridaWorkflowNotFoundException, ExecutionManagerException {
    String searchValue = "";
    Project project = new Project();
    DataTablesParams params = new DataTablesParams(1, 10, 1, searchValue, new Sort(Sort.Direction.ASC, "id"), ImmutableMap.of());
    when(analysisSubmissionService.listSubmissionsForProject(eq(searchValue), any(String.class), eq(null), Matchers.any(), eq(project), Matchers.any())).thenReturn(AnalysesDataFactory.getPagedAnalysisSubmissions());
    DataTablesResponse response = analysesListingService.getPagedSubmissions(params, Locale.US, null, project);
    assertEquals("DataTables response should have a draw value of 1", 1, response.getDraw());
    assertEquals("DataTables response should have a records filtered value of 150", 150, response.getRecordsFiltered());
    assertEquals("DataTables response should have a records total value of 150", 150, response.getRecordsTotal());
    assertTrue("Should have data value", response.getData() != null);
    verify(analysisSubmissionService).listSubmissionsForProject(eq(searchValue), any(String.class), eq(null), Matchers.any(), eq(project), Matchers.any());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sort(org.springframework.data.domain.Sort) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) DataTablesParams(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams) Test(org.junit.Test)

Example 15 with DataTablesResponse

use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse in project irida by phac-nml.

the class AnalysisControllerDataTablesTest method setup.

@Before
public void setup() throws IridaWorkflowNotFoundException, ExecutionManagerException {
    // initializes controller and mocks
    MockitoAnnotations.initMocks(this);
    /*
		Need to set up a mock for the AnalysisSubmissionService so that it return a Page of AnalysisSubmission.
		 */
    DataTablesParams params = new DataTablesParams(1, 10, 1, "", new Sort(Sort.Direction.ASC, "id"), ImmutableMap.of());
    Page<AnalysisSubmission> page = AnalysesDataFactory.getPagedAnalysisSubmissions();
    when(analysesListingService.getPagedSubmissions(Matchers.any(), Matchers.any(), Matchers.any(), Matchers.any())).thenReturn(new DataTablesResponse(params, page, ImmutableList.of()));
    mockMvc = MockMvcBuilders.standaloneSetup(analysisController).build();
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) Sort(org.springframework.data.domain.Sort) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) DataTablesParams(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams) Before(org.junit.Before)

Aggregations

DataTablesResponse (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse)22 DataTablesResponseModel (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel)16 DataTablesParams (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams)13 Sort (org.springframework.data.domain.Sort)11 Project (ca.corefacility.bioinformatics.irida.model.project.Project)8 Test (org.junit.Test)8 PageRequest (org.springframework.data.domain.PageRequest)8 User (ca.corefacility.bioinformatics.irida.model.user.User)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 DataTablesRequest (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.config.DataTablesRequest)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)3 UserService (ca.corefacility.bioinformatics.irida.service.user.UserService)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Collectors (java.util.stream.Collectors)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Page (org.springframework.data.domain.Page)3 Controller (org.springframework.stereotype.Controller)3 Model (org.springframework.ui.Model)3