V2SampleAliasGenerator implements NameGenerator<Sample> { @Override public String generate(Sample sample) throws MisoNamingException, IOException { if (!LimsUtils.isDetailedSample(sample)) { throw new MisoNamingException("Can only generate an alias for detailed samples"); } DetailedSample detailed = (DetailedSample) sample; if (isIdentitySample(detailed)) { return generateIdentityAlias(detailed); } else if (isTissueSample(detailed)) { return generateTissueAlias(detailed); } else if (isAliquotSample(detailed)) { return generateAliquotAlias(detailed); } else { return generateLevel3Alias(detailed); } }  void setSiblingNumberGenerator(SiblingNumberGenerator siblingNumberGenerator); void setSampleNumberPerProjectService(SampleNumberPerProjectService sampleNumberPerProjectService); @Override String generate(Sample sample);  }
@Test public void generateForIdentityTest() throws Exception { Sample identity = makeIdentity(); Mockito.when(sampleNumberPerProjectService.nextNumber(Mockito.any(), Mockito.anyString())).thenReturn("0123"); assertEquals("PROJ_0123", sut.generate(identity)); }
@Test public void generateForTissueTest() throws Exception { mockFirstAvailableSiblingNumber(1); assertEquals("PROJ_0001_01", sut.generate(makeTissue())); }
@Test public void generateForTissueFromTissueTest() throws Exception { mockFirstAvailableSiblingNumber(2); assertEquals("PROJ_0001_02", sut.generate(makeTissueFromTissue())); }
@Test public void generateForTissueProcessingTest() throws Exception { mockFirstAvailableSiblingNumber(3); assertEquals("PROJ_0001_01_TL03", sut.generate(makeLcmTube())); }
@Test public void generateForStockFromTissueTest() throws Exception { mockFirstAvailableSiblingNumber(4); assertEquals("PROJ_0001_01_SG04", sut.generate(makeStockFromTissue())); }
@Test public void generateForStockFromProcessingTest() throws Exception { mockFirstAvailableSiblingNumber(5); assertEquals("PROJ_0001_01_SG05", sut.generate(makeStockFromProcessing())); }
@Test public void generateForStockFromStockTest() throws Exception { mockFirstAvailableSiblingNumber(6); assertEquals("PROJ_0001_01_SG06", sut.generate(makeStockFromStock())); }
@Test public void generateForAliquotFromStockTest() throws Exception { mockFirstAvailableSiblingNumber(7); assertEquals("PROJ_0001_01_SG04-07", sut.generate(makeAliquotFromStock())); }
@Test public void generateForAliquotFromAliquotTest() throws Exception { mockFirstAvailableSiblingNumber(8); assertEquals("PROJ_0001_01_SG04-08", sut.generate(makeAliquotFromAliquot())); }