Search in sources :

Example 6 with DataTablesParams

use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams 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 7 with DataTablesParams

use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams 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 8 with DataTablesParams

use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams 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 9 with DataTablesParams

use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams 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 10 with DataTablesParams

use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams 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

DataTablesParams (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams)13 DataTablesResponse (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse)13 Sort (org.springframework.data.domain.Sort)10 Test (org.junit.Test)8 DataTablesResponseModel (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel)7 Project (ca.corefacility.bioinformatics.irida.model.project.Project)5 User (ca.corefacility.bioinformatics.irida.model.user.User)5 DataTablesRequest (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.config.DataTablesRequest)4 Collectors (java.util.stream.Collectors)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 Page (org.springframework.data.domain.Page)4 PageRequest (org.springframework.data.domain.PageRequest)4 UserService (ca.corefacility.bioinformatics.irida.service.user.UserService)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Principal (java.security.Principal)3 java.util (java.util)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 Controller (org.springframework.stereotype.Controller)3 Model (org.springframework.ui.Model)3