NameParserGbifV1 implements NameParser { @Override public ParsedName parseQuietly(String scientificName, @Nullable Rank rank) { ParsedName p; try { p = parse(scientificName, rank); } catch (UnparsableException e) { p = new ParsedName(); p.setScientificName(scientificName); p.setRank(rank); p.setType(e.type); p.setParsed(false); p.setParsedPartially(false); } return p; } NameParserGbifV1();  NameParserGbifV1(long timeout);  NameParserGbifV1(org.gbif.nameparser.api.NameParser parser); @Override ParsedName parse(String s, @Nullable Rank rank); @Override ParsedName parse(String scientificName); @Override ParsedName parseQuietly(String scientificName, @Nullable Rank rank); @Override ParsedName parseQuietly(String scientificName); @Override // parses the name without authorship and returns the ParsedName.canonicalName() string String parseToCanonical(String scientificName, @Nullable Rank rank); @Override String parseToCanonical(String scientificName); String parseToCanonicalOrScientificName(String scientificName); String parseToCanonicalOrScientificName(String scientificName, @Nullable Rank rank);  }
@Test public void parseQuietly() throws Exception { ParsedName pn = parser.parseQuietly("Navicula var. fasciata", Rank.VARIETY); assertNull(pn.getSpecificEpithet()); assertEquals(NameType.INFORMAL, pn.getType()); assertEquals("Abies alba", parser.parseQuietly("Abies alba Mill.").canonicalName()); pn = parser.parseQuietly("Abies alba x Pinus graecus L."); assertEquals("Abies alba x Pinus graecus L.", pn.getScientificName()); assertEquals(NameType.HYBRID, pn.getType()); assertNull(pn.getGenusOrAbove()); assertFalse(parser.parseQuietly("Protoscenium simplex (Cleve, 1899), Jørgensen, 1905 ", Rank.SPECIES).isParsedPartially()); assertFalse(parser.parseQuietly("Plagiacanthidae", Rank.SPECIES).isParsedPartially()); pn = parser.parseQuietly("Plagiacanthidae WhatTheHeck @%&/ (please dont parse me[ he?5789])", Rank.SPECIES); assertTrue(pn.isParsed()); assertTrue(pn.isParsedPartially()); assertEquals("Plagiacanthidae", pn.getGenusOrAbove()); }
@Test public void assertScientificName() throws Exception { ParsedName pn = parser.parseQuietly("Abies sp."); assertEquals("Abies sp.", pn.getScientificName()); assertEquals("Abies spec.", pn.canonicalName()); assertEquals("Abies", pn.getGenusOrAbove()); assertEquals(Rank.SPECIES, pn.getRank()); assertNull(pn.getSpecificEpithet()); pn = parser.parseQuietly("×Abies Mill."); assertEquals("×Abies Mill.", pn.getScientificName()); assertEquals("Abies", pn.canonicalName()); assertEquals("Abies", pn.getGenusOrAbove()); assertNull(pn.getRank()); assertNull(pn.getSpecificEpithet()); assertEquals(NamePart.GENERIC, pn.getNotho()); pn = parser.parseQuietly("? hostilis Gravenhorst, 1829"); assertEquals("? hostilis Gravenhorst, 1829", pn.getScientificName()); assertEquals("? hostilis", pn.canonicalName()); assertEquals("?", pn.getGenusOrAbove()); assertEquals(Rank.SPECIES, pn.getRank()); assertEquals("hostilis", pn.getSpecificEpithet()); pn = parser.parseQuietly("unassigned Asteraceae"); assertEquals("unassigned Asteraceae", pn.getScientificName()); assertNull(pn.canonicalName()); assertNull(pn.getGenusOrAbove()); assertNull(pn.getRank()); assertNull(pn.getSpecificEpithet()); pn = parser.parseQuietly("OdontellidaeGEN"); assertEquals(NameType.PLACEHOLDER, pn.getType()); assertEquals("OdontellidaeGEN", pn.getScientificName()); assertEquals("Odontellidae", pn.canonicalName()); assertEquals("Odontellidae", pn.getGenusOrAbove()); assertEquals("GEN", pn.getStrain()); assertNull(pn.getRank()); assertNull(pn.getSpecificEpithet()); assertNull(pn.getAuthorship()); }