@Test public void testExtractNamesFromSpecimens() { ScientificName scientificName = new ScientificName(); scientificName.setFullScientificName("Bombus affinis Cresson, 1863"); scientificName.setScientificNameGroup("bombus affinis"); SpecimenIdentification identification = new SpecimenIdentification(); identification.setScientificName(scientificName); Specimen specimen = new Specimen(); specimen.addIndentification(identification); List<Specimen> specimens = new ArrayList<>(); specimens.add(specimen); Object actual = ReflectionUtil.callStatic(EnrichmentUtil.class, "extractNamesFromSpecimens", new Class[] {List.class}, new Object[] {specimens}); String[] resultArray = (String[]) actual; String expectedName = "bombus affinis"; assertNotNull("01", resultArray); assertEquals("02", expectedName, resultArray[0]); }
private static String[] extractNamesFromSpecimens(List<Specimen> specimens) { HashSet<String> names = new HashSet<>(specimens.size() * 3); for (Specimen s : specimens) { for (SpecimenIdentification identification : s.getIdentifications()) { names.add(identification.getScientificName().getScientificNameGroup()); } } return names.toArray(new String[names.size()]); }
EnrichmentUtil { private static String[] extractNamesFromSpecimens(List<Specimen> specimens) { HashSet<String> names = new HashSet<>(specimens.size() * 3); for (Specimen s : specimens) { for (SpecimenIdentification identification : s.getIdentifications()) { names.add(identification.getScientificName().getScientificNameGroup()); } } return names.toArray(new String[names.size()]); } }
EnrichmentUtil { private static String[] extractNamesFromSpecimens(List<Specimen> specimens) { HashSet<String> names = new HashSet<>(specimens.size() * 3); for (Specimen s : specimens) { for (SpecimenIdentification identification : s.getIdentifications()) { names.add(identification.getScientificName().getScientificNameGroup()); } } return names.toArray(new String[names.size()]); }  }
EnrichmentUtil { private static String[] extractNamesFromSpecimens(List<Specimen> specimens) { HashSet<String> names = new HashSet<>(specimens.size() * 3); for (Specimen s : specimens) { for (SpecimenIdentification identification : s.getIdentifications()) { names.add(identification.getScientificName().getScientificNameGroup()); } } return names.toArray(new String[names.size()]); }  static List<TaxonomicEnrichment> createEnrichments(List<Taxon> taxa); }
EnrichmentUtil { private static String[] extractNamesFromSpecimens(List<Specimen> specimens) { HashSet<String> names = new HashSet<>(specimens.size() * 3); for (Specimen s : specimens) { for (SpecimenIdentification identification : s.getIdentifications()) { names.add(identification.getScientificName().getScientificNameGroup()); } } return names.toArray(new String[names.size()]); }  static List<TaxonomicEnrichment> createEnrichments(List<Taxon> taxa);  }