### Question:
NonResolvingTaxonIndex implements TaxonIndex { @Override public TaxonNode getOrCreateTaxon(Taxon taxon) throws NodeFactoryException { TaxonNode taxonNode = findTaxon(taxon); if (taxonNode == null) { taxonNode = TaxonUtil.isResolved(taxon) ? createAndIndexTaxon(taxon, taxon) : addNoMatchTaxon(taxon); } return taxonNode == null ? createAndIndexTaxon(taxon, taxon) : taxonNode; } NonResolvingTaxonIndex(GraphDatabaseService graphDbService); @Override TaxonNode getOrCreateTaxon(Taxon taxon); @Override TaxonNode findTaxonById(String externalId); @Override TaxonNode findTaxonByName(String name); IndexHits<Node> findCloseMatchesForTaxonName(String taxonName);  }### Answer:
@Test public final void createTaxon() throws NodeFactoryException { Taxon taxon1 = new TaxonImpl("bla bla", null); taxon1.setPath(null); TaxonNode taxon = taxonService.getOrCreateTaxon(taxon1); assertThat(taxon, is(notNullValue())); assertEquals("bla bla", taxon.getName()); }
@Test public final void createNullTaxon() throws NodeFactoryException { Taxon taxon1 = new TaxonImpl(null, "EOL:1234"); taxon1.setPath(null); TaxonNode taxon = taxonService.getOrCreateTaxon(taxon1); assertThat(taxon, is(notNullValue())); assertEquals("no name", taxon.getName()); }
@Test public void createTaxonWithExplicitRanks() throws NodeFactoryException { Taxon taxon1 = new TaxonImpl("foo", "foo:123"); taxon1.setPath("a kingdom name | a phylum name | boo name | a class name | an order name | a family name | a genus name | a species name"); taxon1.setPathIds("a kingdom id | a phylum id | boo id | a class id | an order id | a family id | a genus id | a species id"); taxon1.setPathNames("kingdom | phylum | boo | class | order | family | genus | species"); TaxonNode taxon = taxonService.getOrCreateTaxon(taxon1); assertThat(propertyOf(taxon, "kingdomName"), is("a kingdom name")); assertThat(propertyOf(taxon, "kingdomId"), is("a kingdom id")); assertThat(propertyOf(taxon, "phylumName"), is("a phylum name")); assertThat(propertyOf(taxon, "phylumId"), is("a phylum id")); assertThat(propertyOf(taxon, "orderName"), is("an order name")); assertThat(propertyOf(taxon, "orderId"), is("an order id")); assertThat(propertyOf(taxon, "className"), is("a class name")); assertThat(propertyOf(taxon, "classId"), is("a class id")); assertThat(propertyOf(taxon, "familyName"), is("a family name")); assertThat(propertyOf(taxon, "familyId"), is("a family id")); assertThat(propertyOf(taxon, "genusName"), is("a genus name")); assertThat(propertyOf(taxon, "genusId"), is("a genus id")); assertThat(propertyOf(taxon, "speciesName"), is("a species name")); assertThat(propertyOf(taxon, "speciesId"), is("a species id")); }