@Test public void testGetSystemClassification() { List<Monomial> expectedList = new ArrayList<>(); Monomial monomial_1 = new Monomial(); monomial_1.setName("Plantae"); monomial_1.setRank("kingdom"); expectedList.add(monomial_1); Monomial monomial_2 = new Monomial(); monomial_2.setName("Rhododendron"); monomial_2.setRank("genus"); expectedList.add(monomial_2); Monomial monomial_3 = new Monomial(); monomial_3.setName("ferrugineum"); monomial_3.setRank("species"); expectedList.add(monomial_3); Monomial monomial_4 = new Monomial(); monomial_4.setName(""); monomial_4.setRank("subspecies"); expectedList.add(monomial_4); @SuppressWarnings("unchecked") CSVRecordInfo<BrahmsCsvField> record = mock(CSVRecordInfo.class); when(record.get(SPECIES)).thenReturn("Rhododendron ferrugineum L."); when(record.get(AUTHOR2)).thenReturn("L."); when(record.get(GENUS)).thenReturn("Rhododendron"); when(record.get(SP1)).thenReturn("ferrugineum"); when(record.get(RANK2)).thenReturn(""); when(record.get(SP2)).thenReturn(""); ScientificName scientificName = new ScientificName(); scientificName.setFullScientificName("Rhododendron ferrugineum (L.)"); scientificName.setAuthorshipVerbatim("L."); scientificName.setGenusOrMonomial("Rhododendron"); scientificName.setSpecificEpithet("ferrugineum"); scientificName.setScientificNameGroup("rhododendron ferrugineum "); scientificName.setInfraspecificMarker(""); scientificName.setInfraspecificEpithet(""); DefaultClassification classification = BrahmsImportUtil.getDefaultClassification(record, scientificName); List<Monomial> list = BrahmsImportUtil.getSystemClassification(classification); Map<String, String> actualResult = list.stream().collect(Collectors.toMap(Monomial::getName, Monomial::getRank)); Map<String, String> expectedResult = expectedList.stream().collect(Collectors.toMap(Monomial::getName, Monomial::getRank)); assertNotNull("01",list); assertEquals("02",4, list.size()); assertEquals("03",expectedResult, actualResult); assertArrayEquals("04",actualResult.keySet().toArray(), expectedResult.keySet().toArray()); assertArrayEquals("05", actualResult.values().toArray(), expectedResult.values().toArray()); }
public static List<Monomial> getSystemClassification(DefaultClassification dc) { List<Monomial> sc = new ArrayList<>(8); if (dc.getKingdom() != null) { sc.add(new Monomial(TaxonomicRank.KINGDOM, dc.getKingdom())); } if (dc.getOrder() != null) { sc.add(new Monomial(TaxonomicRank.ORDER, dc.getOrder())); } if (dc.getFamily() != null) { sc.add(new Monomial(TaxonomicRank.FAMILY, dc.getFamily())); } if (dc.getGenus() != null) { sc.add(new Monomial(TaxonomicRank.GENUS, dc.getGenus())); } if (dc.getSpecificEpithet() != null) { sc.add(new Monomial(TaxonomicRank.SPECIES, dc.getSpecificEpithet())); } if (dc.getInfraspecificEpithet() != null) { sc.add(new Monomial(TaxonomicRank.SUBSPECIES, dc.getInfraspecificEpithet())); } return sc; }
BrahmsImportUtil { public static List<Monomial> getSystemClassification(DefaultClassification dc) { List<Monomial> sc = new ArrayList<>(8); if (dc.getKingdom() != null) { sc.add(new Monomial(TaxonomicRank.KINGDOM, dc.getKingdom())); } if (dc.getOrder() != null) { sc.add(new Monomial(TaxonomicRank.ORDER, dc.getOrder())); } if (dc.getFamily() != null) { sc.add(new Monomial(TaxonomicRank.FAMILY, dc.getFamily())); } if (dc.getGenus() != null) { sc.add(new Monomial(TaxonomicRank.GENUS, dc.getGenus())); } if (dc.getSpecificEpithet() != null) { sc.add(new Monomial(TaxonomicRank.SPECIES, dc.getSpecificEpithet())); } if (dc.getInfraspecificEpithet() != null) { sc.add(new Monomial(TaxonomicRank.SUBSPECIES, dc.getInfraspecificEpithet())); } return sc; } }
BrahmsImportUtil { public static List<Monomial> getSystemClassification(DefaultClassification dc) { List<Monomial> sc = new ArrayList<>(8); if (dc.getKingdom() != null) { sc.add(new Monomial(TaxonomicRank.KINGDOM, dc.getKingdom())); } if (dc.getOrder() != null) { sc.add(new Monomial(TaxonomicRank.ORDER, dc.getOrder())); } if (dc.getFamily() != null) { sc.add(new Monomial(TaxonomicRank.FAMILY, dc.getFamily())); } if (dc.getGenus() != null) { sc.add(new Monomial(TaxonomicRank.GENUS, dc.getGenus())); } if (dc.getSpecificEpithet() != null) { sc.add(new Monomial(TaxonomicRank.SPECIES, dc.getSpecificEpithet())); } if (dc.getInfraspecificEpithet() != null) { sc.add(new Monomial(TaxonomicRank.SUBSPECIES, dc.getInfraspecificEpithet())); } return sc; } BrahmsImportUtil(); }
BrahmsImportUtil { public static List<Monomial> getSystemClassification(DefaultClassification dc) { List<Monomial> sc = new ArrayList<>(8); if (dc.getKingdom() != null) { sc.add(new Monomial(TaxonomicRank.KINGDOM, dc.getKingdom())); } if (dc.getOrder() != null) { sc.add(new Monomial(TaxonomicRank.ORDER, dc.getOrder())); } if (dc.getFamily() != null) { sc.add(new Monomial(TaxonomicRank.FAMILY, dc.getFamily())); } if (dc.getGenus() != null) { sc.add(new Monomial(TaxonomicRank.GENUS, dc.getGenus())); } if (dc.getSpecificEpithet() != null) { sc.add(new Monomial(TaxonomicRank.SPECIES, dc.getSpecificEpithet())); } if (dc.getInfraspecificEpithet() != null) { sc.add(new Monomial(TaxonomicRank.SUBSPECIES, dc.getInfraspecificEpithet())); } return sc; } BrahmsImportUtil(); static File[] getCsvFiles(); static void backup(); static void removeBackupExtension(); static ScientificName getScientificName(CSVRecordInfo<BrahmsCsvField> record); static DefaultClassification getDefaultClassification(CSVRecordInfo<BrahmsCsvField> record,
			ScientificName sn); static List<Monomial> getSystemClassification(DefaultClassification dc); static String getAuthor(CSVRecordInfo<BrahmsCsvField> record); static String getInfraspecificMarker(CSVRecordInfo<BrahmsCsvField> record); static String getInfraspecificEpithet(CSVRecordInfo<BrahmsCsvField> record); static String getTaxonRank(CSVRecordInfo<BrahmsCsvField> record); static File getDataDir(); }
BrahmsImportUtil { public static List<Monomial> getSystemClassification(DefaultClassification dc) { List<Monomial> sc = new ArrayList<>(8); if (dc.getKingdom() != null) { sc.add(new Monomial(TaxonomicRank.KINGDOM, dc.getKingdom())); } if (dc.getOrder() != null) { sc.add(new Monomial(TaxonomicRank.ORDER, dc.getOrder())); } if (dc.getFamily() != null) { sc.add(new Monomial(TaxonomicRank.FAMILY, dc.getFamily())); } if (dc.getGenus() != null) { sc.add(new Monomial(TaxonomicRank.GENUS, dc.getGenus())); } if (dc.getSpecificEpithet() != null) { sc.add(new Monomial(TaxonomicRank.SPECIES, dc.getSpecificEpithet())); } if (dc.getInfraspecificEpithet() != null) { sc.add(new Monomial(TaxonomicRank.SUBSPECIES, dc.getInfraspecificEpithet())); } return sc; } BrahmsImportUtil(); static File[] getCsvFiles(); static void backup(); static void removeBackupExtension(); static ScientificName getScientificName(CSVRecordInfo<BrahmsCsvField> record); static DefaultClassification getDefaultClassification(CSVRecordInfo<BrahmsCsvField> record,
			ScientificName sn); static List<Monomial> getSystemClassification(DefaultClassification dc); static String getAuthor(CSVRecordInfo<BrahmsCsvField> record); static String getInfraspecificMarker(CSVRecordInfo<BrahmsCsvField> record); static String getInfraspecificEpithet(CSVRecordInfo<BrahmsCsvField> record); static String getTaxonRank(CSVRecordInfo<BrahmsCsvField> record); static File getDataDir();  }