Search in sources :

Example 1 with SampleImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl in project miso-lims by miso-lims.

the class DefaultSampleServiceTest method testValidateRelationshipForSimpleSample.

@Test
public void testValidateRelationshipForSimpleSample() throws Exception {
    // Simple sample has no DetailedSample attributes.
    Sample child = new SampleImpl();
    // Simple sample has no parent.
    Sample parent = null;
    assertTrue("Simple sample with a null parent and null DetailedSample is a valid relationship", sut.isValidRelationship(parent, child));
}
Also used : DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) SampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl) Test(org.junit.Test)

Example 2 with SampleImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl in project miso-lims by miso-lims.

the class DefaultSampleServiceTest method testPlainSampleIdentificationBarcodeGeneration.

@Test
public void testPlainSampleIdentificationBarcodeGeneration() throws Exception {
    Sample sample = new SampleImpl();
    sample.setAlias("alias");
    mockShellProjectWithRealLookup(sample);
    assertNull("identificationBarcode should be null before save for test", sample.getIdentificationBarcode());
    sut.setAutoGenerateIdBarcodes(true);
    Mockito.when(sampleStore.getSample(Mockito.anyLong())).thenReturn(sample);
    sut.create(sample);
    ArgumentCaptor<Sample> updatedCapture = ArgumentCaptor.forClass(Sample.class);
    Mockito.verify(sampleStore).update(updatedCapture.capture());
    Sample updated = updatedCapture.getValue();
    assertNotNull("identificationBarcode should be generated", updated.getIdentificationBarcode());
}
Also used : DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) SampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl) Test(org.junit.Test)

Example 3 with SampleImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl in project miso-lims by miso-lims.

the class DefaultSampleServiceTest method makePlainSample.

private Sample makePlainSample() {
    Sample sample = new SampleImpl();
    sample.setId(77L);
    sample.setAlias("alias");
    sample.setName("name");
    return sample;
}
Also used : DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) SampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl)

Example 4 with SampleImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl in project miso-lims by miso-lims.

the class DefaultSampleServiceTest method testCreatePlainSample.

@Test
public void testCreatePlainSample() throws Exception {
    Sample sample = new SampleImpl();
    String expectedAlias = "not_generated";
    sample.setAlias(expectedAlias);
    Project expectedProject = mockShellProjectWithRealLookup(sample);
    User expectedLastModifier = mockUser();
    String expectedName = "generated_name";
    Mockito.when(namingScheme.generateNameFor((Sample) Mockito.any())).thenReturn(expectedName);
    Mockito.when(namingScheme.generateSampleAlias((Sample) Mockito.any())).thenReturn("bad");
    Mockito.when(sampleStore.getSample(Mockito.anyLong())).thenReturn(sample);
    sut.create(sample);
    ArgumentCaptor<Sample> createdCapture = ArgumentCaptor.forClass(Sample.class);
    Mockito.verify(sampleStore).create(createdCapture.capture());
    Sample created = createdCapture.getValue();
    assertEquals("shell project should be replaced by real project", expectedProject.getAlias(), created.getProject().getAlias());
    assertNotNull("modification details should be added", created.getLastModifier());
    assertEquals("modification details should be added", expectedLastModifier.getId(), created.getLastModifier().getId());
    assertTrue("expected a plain sample", LimsUtils.isPlainSample(created));
    // name generators get called after initial save
    ArgumentCaptor<Sample> updatedCapture = ArgumentCaptor.forClass(Sample.class);
    Mockito.verify(sampleStore).update(updatedCapture.capture());
    Sample updated = updatedCapture.getValue();
    assertEquals("name should be generated", expectedName, updated.getName());
    assertEquals("alias should not be generated", expectedAlias, updated.getAlias());
    assertNull("identificationBarcode should not be generated", updated.getIdentificationBarcode());
    assertTrue("expected a plain sample", LimsUtils.isPlainSample(updated));
}
Also used : Project(uk.ac.bbsrc.tgac.miso.core.data.Project) User(com.eaglegenomics.simlims.core.User) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) SampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl) Test(org.junit.Test)

Example 5 with SampleImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl in project miso-lims by miso-lims.

the class DefaultSampleServiceTest method notTemporarySampleNameTest.

@Test
public void notTemporarySampleNameTest() throws Exception {
    Sample sample = new SampleImpl();
    sample.setName("RealSampleName");
    assertFalse("Real sample names must return false.", hasTemporaryName(sample));
}
Also used : DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) SampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl) Test(org.junit.Test)

Aggregations

SampleImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl)26 Sample (uk.ac.bbsrc.tgac.miso.core.data.Sample)22 DetailedSample (uk.ac.bbsrc.tgac.miso.core.data.DetailedSample)20 Test (org.junit.Test)16 DetailedSampleImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.DetailedSampleImpl)6 LibraryImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryImpl)5 ProjectImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.ProjectImpl)5 TransferSample (uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferSample)5 IlluminaNotificationDto (ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto)4 NotificationDto (ca.on.oicr.gsi.runscanner.dto.NotificationDto)4 OxfordNanoporeNotificationDto (ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto)4 User (com.eaglegenomics.simlims.core.User)4 Library (uk.ac.bbsrc.tgac.miso.core.data.Library)4 Project (uk.ac.bbsrc.tgac.miso.core.data.Project)4 DetailedLibraryImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.DetailedLibraryImpl)4 IdentityView (uk.ac.bbsrc.tgac.miso.core.data.impl.view.IdentityView)4 WorksetSample (uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetSample)4 OrderAliquotDto (uk.ac.bbsrc.tgac.miso.dto.PoolOrderDto.OrderAliquotDto)4 QcHierarchyNodeDto (uk.ac.bbsrc.tgac.miso.dto.dashi.QcHierarchyNodeDto)4 IlluminaRunDto (uk.ac.bbsrc.tgac.miso.dto.run.IlluminaRunDto)4