Search in sources :

Example 1 with UISampleFilter

use of ca.corefacility.bioinformatics.irida.ria.web.models.UISampleFilter in project irida by phac-nml.

the class ProjectSamplesControllerTest method testGetAjaxProjectSampleModels.

@SuppressWarnings("unchecked")
@Test
public void testGetAjaxProjectSampleModels() {
    Sample sample = TestDataFactory.constructSample();
    when(projectService.read(anyLong())).thenReturn(project);
    when(sampleService.getSamplesForProject(any(Project.class))).thenReturn(ImmutableList.of(new ProjectSampleJoin(project, sample, true)));
    when(sampleService.getFilteredSamplesForProjects(any(List.class), any(List.class), any(String.class), any(String.class), any(String.class), any(Date.class), any(Date.class), any(Integer.class), any(Integer.class), any(Sort.class))).thenReturn(TestDataFactory.getPageOfProjectSampleJoin());
    DataTablesParams params = mock(DataTablesParams.class);
    when(params.getSort()).thenReturn(new Sort(Direction.ASC, "sample.sampleName"));
    DataTablesResponse response = controller.getProjectSamples(1L, params, ImmutableList.of(), ImmutableList.of(), new UISampleFilter(), Locale.US);
    List<DataTablesResponseModel> data = response.getData();
    assertEquals("Has the correct number of samples", 1, data.size());
    DTProjectSamples sampleData = (DTProjectSamples) data.get(0);
    assertEquals("Has the correct sample", "Joined Sample", sampleData.getSampleName());
}
Also used : DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) UISampleFilter(ca.corefacility.bioinformatics.irida.ria.web.models.UISampleFilter) ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) Project(ca.corefacility.bioinformatics.irida.model.project.Project) DTProjectSamples(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTProjectSamples) Sort(org.springframework.data.domain.Sort) ImmutableList(com.google.common.collect.ImmutableList) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) DataTablesParams(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams) Test(org.junit.Test)

Aggregations

ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)1 Project (ca.corefacility.bioinformatics.irida.model.project.Project)1 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)1 DataTablesParams (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams)1 DataTablesResponse (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse)1 DataTablesResponseModel (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel)1 UISampleFilter (ca.corefacility.bioinformatics.irida.ria.web.models.UISampleFilter)1 DTProjectSamples (ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTProjectSamples)1 ImmutableList (com.google.common.collect.ImmutableList)1 Test (org.junit.Test)1 Sort (org.springframework.data.domain.Sort)1