@Test public void testGetPreviousUnitsText() throws Exception { CSVRecordInfo<BrahmsCsvField> record = mock(CSVRecordInfo.class); ETLStatistics etlStatistics = new ETLStatistics(); BrahmsSpecimenTransformer brahmsSpecimenTransformer = new BrahmsSpecimenTransformer(etlStatistics); CommonReflectionUtil.setField(AbstractTransformer.class, brahmsSpecimenTransformer, "objectID", "L.3355550"); CommonReflectionUtil.setField(AbstractTransformer.class, brahmsSpecimenTransformer, "input", record); when(record.get(BrahmsCsvField.OLDBARCODE, true)).thenReturn("L 0020601"); when(record.get(BrahmsCsvField.ACCESSION, true)).thenReturn("125784"); Object obj = CommonReflectionUtil.callMethod(null, CSVRecordInfo.class, brahmsSpecimenTransformer, "getPreviousUnitsText"); String previousUnitsText = (String) obj; String expectedPreviousUnitsText = "L 0020601 | 125784"; assertNotNull("01", previousUnitsText); assertEquals( "02", expectedPreviousUnitsText, previousUnitsText); when(record.get(BrahmsCsvField.OLDBARCODE, true)).thenReturn("L 0020601"); when(record.get(BrahmsCsvField.ACCESSION, true)).thenReturn(null); obj = CommonReflectionUtil.callMethod(null, CSVRecordInfo.class, brahmsSpecimenTransformer, "getPreviousUnitsText"); previousUnitsText = (String) obj; expectedPreviousUnitsText = "L 0020601"; assertNotNull("03", previousUnitsText); assertEquals( "04", expectedPreviousUnitsText, previousUnitsText); when(record.get(BrahmsCsvField.OLDBARCODE, true)).thenReturn(null); when(record.get(BrahmsCsvField.ACCESSION, true)).thenReturn("125784"); obj = CommonReflectionUtil.callMethod(null, CSVRecordInfo.class, brahmsSpecimenTransformer, "getPreviousUnitsText"); previousUnitsText = (String) obj; expectedPreviousUnitsText = "125784"; assertNotNull("05", previousUnitsText); assertEquals( "06", expectedPreviousUnitsText, previousUnitsText); when(record.get(BrahmsCsvField.OLDBARCODE, true)).thenReturn(" L 0020601 "); when(record.get(BrahmsCsvField.ACCESSION, true)).thenReturn(" "); obj = CommonReflectionUtil.callMethod(null, CSVRecordInfo.class, brahmsSpecimenTransformer, "getPreviousUnitsText"); previousUnitsText = (String) obj; expectedPreviousUnitsText = "L 0020601"; assertNotNull("07", previousUnitsText); assertEquals( "08", expectedPreviousUnitsText, previousUnitsText); }
private String getPreviousUnitsText() { CSVRecordInfo<BrahmsCsvField> rec = input; String oldBarcode = rec.get(OLDBARCODE, true); String accession = rec.get(ACCESSION, true); String sep = ""; if (oldBarcode != null && oldBarcode.trim().length() > 0) { sep = " | "; } if (accession != null && accession.trim().length() > 0) { if (sep.length() > 0) { return oldBarcode.trim() + sep + accession.trim(); } return accession.trim(); } return sep.length() > 0 ? oldBarcode.trim() : null; }
BrahmsSpecimenTransformer extends BrahmsTransformer<Specimen> { private String getPreviousUnitsText() { CSVRecordInfo<BrahmsCsvField> rec = input; String oldBarcode = rec.get(OLDBARCODE, true); String accession = rec.get(ACCESSION, true); String sep = ""; if (oldBarcode != null && oldBarcode.trim().length() > 0) { sep = " | "; } if (accession != null && accession.trim().length() > 0) { if (sep.length() > 0) { return oldBarcode.trim() + sep + accession.trim(); } return accession.trim(); } return sep.length() > 0 ? oldBarcode.trim() : null; } }
BrahmsSpecimenTransformer extends BrahmsTransformer<Specimen> { private String getPreviousUnitsText() { CSVRecordInfo<BrahmsCsvField> rec = input; String oldBarcode = rec.get(OLDBARCODE, true); String accession = rec.get(ACCESSION, true); String sep = ""; if (oldBarcode != null && oldBarcode.trim().length() > 0) { sep = " | "; } if (accession != null && accession.trim().length() > 0) { if (sep.length() > 0) { return oldBarcode.trim() + sep + accession.trim(); } return accession.trim(); } return sep.length() > 0 ? oldBarcode.trim() : null; } BrahmsSpecimenTransformer(ETLStatistics stats); }
BrahmsSpecimenTransformer extends BrahmsTransformer<Specimen> { private String getPreviousUnitsText() { CSVRecordInfo<BrahmsCsvField> rec = input; String oldBarcode = rec.get(OLDBARCODE, true); String accession = rec.get(ACCESSION, true); String sep = ""; if (oldBarcode != null && oldBarcode.trim().length() > 0) { sep = " | "; } if (accession != null && accession.trim().length() > 0) { if (sep.length() > 0) { return oldBarcode.trim() + sep + accession.trim(); } return accession.trim(); } return sep.length() > 0 ? oldBarcode.trim() : null; } BrahmsSpecimenTransformer(ETLStatistics stats);  }
BrahmsSpecimenTransformer extends BrahmsTransformer<Specimen> { private String getPreviousUnitsText() { CSVRecordInfo<BrahmsCsvField> rec = input; String oldBarcode = rec.get(OLDBARCODE, true); String accession = rec.get(ACCESSION, true); String sep = ""; if (oldBarcode != null && oldBarcode.trim().length() > 0) { sep = " | "; } if (accession != null && accession.trim().length() > 0) { if (sep.length() > 0) { return oldBarcode.trim() + sep + accession.trim(); } return accession.trim(); } return sep.length() > 0 ? oldBarcode.trim() : null; } BrahmsSpecimenTransformer(ETLStatistics stats);   }