@Test public void testHasSynonym() throws Exception { CSVRecordInfo<CoLTaxonCsvField> record = mock(CSVRecordInfo.class); when(record.get(CoLTaxonCsvField.taxonID)).thenReturn("6931870"); when(record.get(CoLTaxonCsvField.identifier)).thenReturn( "urn:lsid:catalogueoflife.org:taxon:6703cbb5-e478-11e5-86e7-bc764e092680:col20150315"); when(record.get(CoLTaxonCsvField.datasetID)).thenReturn("67"); when(record.get(CoLTaxonCsvField.datasetName)) .thenReturn("ITIS Bees in Species 2000 & ITIS Catalogue of Life: 23rd March 2016"); when(record.get(CoLTaxonCsvField.acceptedNameUsageID)).thenReturn("6931870"); when(record.get(CoLTaxonCsvField.parentNameUsageID)).thenReturn("27000241"); when(record.get(CoLTaxonCsvField.taxonomicStatus)).thenReturn("accepted name"); when(record.get(CoLTaxonCsvField.taxonRank)).thenReturn("species"); when(record.get(CoLTaxonCsvField.verbatimTaxonRank)).thenReturn("test_verbatimTaxonRank"); when(record.get(CoLTaxonCsvField.scientificName)).thenReturn("Bombus affinis Cresson, 1863"); when(record.get(CoLTaxonCsvField.kingdom)).thenReturn("Animalia"); when(record.get(CoLTaxonCsvField.phylum)).thenReturn("Arthropoda"); when(record.get(CoLTaxonCsvField.classRank)).thenReturn("Insecta"); when(record.get(CoLTaxonCsvField.superfamily)).thenReturn("Apoidea"); when(record.get(CoLTaxonCsvField.genericName)).thenReturn("Bombus"); when(record.get(CoLTaxonCsvField.subgenus)).thenReturn("test_subgenus"); when(record.get(CoLTaxonCsvField.specificEpithet)).thenReturn("affinis"); when(record.get(CoLTaxonCsvField.infraspecificEpithet)).thenReturn(""); when(record.get(CoLTaxonCsvField.scientificNameAuthorship)).thenReturn("Cresson, 1863"); when(record.get(CoLTaxonCsvField.source)).thenReturn("test_source"); when(record.get(CoLTaxonCsvField.namePublishedIn)).thenReturn(""); when(record.get(CoLTaxonCsvField.nameAccordingTo)).thenReturn(""); when(record.get(CoLTaxonCsvField.modified)).thenReturn("30-Sep-2008"); when(record.get(CoLTaxonCsvField.description)).thenReturn(""); when(record.get(CoLTaxonCsvField.taxonConceptID)).thenReturn(""); when(record.get(CoLTaxonCsvField.scientificNameID)).thenReturn("ITS-714782"); when(record.get(CoLTaxonCsvField.references)).thenReturn( "http: when(record.get(CoLTaxonCsvField.isExtinct)).thenReturn("false"); ArrayList<CSVRecordInfo<CoLTaxonCsvField>> arrayList = new ArrayList<>(); arrayList.add(record); Object retLookup = ReflectionUtil.callStatic(CoLSynonymBatchTransformer.class, "createLookupTable", new Class[] {ArrayList.class}, new Object[] {arrayList}); HashMap<String, Taxon> actualTaxonMap = (HashMap<String, Taxon>) retLookup; Taxon taxon = actualTaxonMap.get("6931870"); Object retScientificName = ReflectionUtil.callStatic(CoLSynonymBatchTransformer.class, "createSynonym", new Class[] {CSVRecordInfo.class}, new Object[] {record}); ScientificName actual = (ScientificName) retScientificName; taxon.addSynonym(actual); Object returned = ReflectionUtil.callStatic(CoLSynonymBatchTransformer.class, "hasSynonym", new Class[] {Taxon.class, ScientificName.class}, new Object[] {taxon, actual}); boolean hasSyn = (boolean) returned; assertTrue(hasSyn); }
private static boolean hasSynonym(Taxon taxon, ScientificName syn) { for (ScientificName sn : taxon.getSynonyms()) { if (equals(sn.getFullScientificName(), syn.getFullScientificName()) && sn.getTaxonomicStatus() == syn.getTaxonomicStatus() && equals(sn.getAuthorshipVerbatim(), syn.getAuthorshipVerbatim()) && equals(sn.getYear(), syn.getYear()) && sn.getScientificNameGroup().equals(syn.getScientificNameGroup())) { return true; } } return false; }
CoLSynonymBatchTransformer { private static boolean hasSynonym(Taxon taxon, ScientificName syn) { for (ScientificName sn : taxon.getSynonyms()) { if (equals(sn.getFullScientificName(), syn.getFullScientificName()) && sn.getTaxonomicStatus() == syn.getTaxonomicStatus() && equals(sn.getAuthorshipVerbatim(), syn.getAuthorshipVerbatim()) && equals(sn.getYear(), syn.getYear()) && sn.getScientificNameGroup().equals(syn.getScientificNameGroup())) { return true; } } return false; } }
CoLSynonymBatchTransformer { private static boolean hasSynonym(Taxon taxon, ScientificName syn) { for (ScientificName sn : taxon.getSynonyms()) { if (equals(sn.getFullScientificName(), syn.getFullScientificName()) && sn.getTaxonomicStatus() == syn.getTaxonomicStatus() && equals(sn.getAuthorshipVerbatim(), syn.getAuthorshipVerbatim()) && equals(sn.getYear(), syn.getYear()) && sn.getScientificNameGroup().equals(syn.getScientificNameGroup())) { return true; } } return false; } CoLSynonymBatchTransformer(); }
CoLSynonymBatchTransformer { private static boolean hasSynonym(Taxon taxon, ScientificName syn) { for (ScientificName sn : taxon.getSynonyms()) { if (equals(sn.getFullScientificName(), syn.getFullScientificName()) && sn.getTaxonomicStatus() == syn.getTaxonomicStatus() && equals(sn.getAuthorshipVerbatim(), syn.getAuthorshipVerbatim()) && equals(sn.getYear(), syn.getYear()) && sn.getScientificNameGroup().equals(syn.getScientificNameGroup())) { return true; } } return false; } CoLSynonymBatchTransformer();  }
CoLSynonymBatchTransformer { private static boolean hasSynonym(Taxon taxon, ScientificName syn) { for (ScientificName sn : taxon.getSynonyms()) { if (equals(sn.getFullScientificName(), syn.getFullScientificName()) && sn.getTaxonomicStatus() == syn.getTaxonomicStatus() && equals(sn.getAuthorshipVerbatim(), syn.getAuthorshipVerbatim()) && equals(sn.getYear(), syn.getYear()) && sn.getScientificNameGroup().equals(syn.getScientificNameGroup())) { return true; } } return false; } CoLSynonymBatchTransformer();   }