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));
}
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());
}
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;
}
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));
}
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));
}
Aggregations