@Test public void testLoadTaxa() { String[] names = {"bombus affinis"}; Object actual = ReflectionUtil.callStatic(EnrichmentUtil.class, "loadTaxa", new Class[] {String[].class}, new Object[] {names}); QueryResult<Taxon> result = (QueryResult<Taxon>) actual; QueryResultItem<Taxon> actualObj = result.get(0); Taxon taxon = actualObj.getItem(); String expectedId = "6931870@COL"; String expectedScientificNameGroup = "bombus affinis"; String expectedAuthorshipVerbatim = "Cresson, 1863"; String expectedFullScientificName = "Bombus affinis Cresson, 1863"; assertEquals("01", expectedId, taxon.getId()); assertEquals("02", expectedScientificNameGroup, taxon.getAcceptedName().getScientificNameGroup()); assertEquals("03", expectedFullScientificName, taxon.getAcceptedName().getFullScientificName()); assertEquals("04", expectedAuthorshipVerbatim, taxon.getAcceptedName().getAuthorshipVerbatim()); }
private static QueryResult<Taxon> loadTaxa(String[] names) { String field = "acceptedName.scientificNameGroup"; QueryCondition condition = new QueryCondition(field, "IN", names); QuerySpec query = new QuerySpec(); query.addCondition(condition); query.setConstantScore(true); query.setSize(50000); TaxonDao dao = new TaxonDao(); QueryResult<Taxon> result; try { result = dao.query(query); if (result.getTotalSize() > 50000) { throw new ETLRuntimeException("Too many taxa"); } } catch (InvalidQueryException e) { throw new ETLRuntimeException(e); } return result; }
EnrichmentUtil { private static QueryResult<Taxon> loadTaxa(String[] names) { String field = "acceptedName.scientificNameGroup"; QueryCondition condition = new QueryCondition(field, "IN", names); QuerySpec query = new QuerySpec(); query.addCondition(condition); query.setConstantScore(true); query.setSize(50000); TaxonDao dao = new TaxonDao(); QueryResult<Taxon> result; try { result = dao.query(query); if (result.getTotalSize() > 50000) { throw new ETLRuntimeException("Too many taxa"); } } catch (InvalidQueryException e) { throw new ETLRuntimeException(e); } return result; } }
EnrichmentUtil { private static QueryResult<Taxon> loadTaxa(String[] names) { String field = "acceptedName.scientificNameGroup"; QueryCondition condition = new QueryCondition(field, "IN", names); QuerySpec query = new QuerySpec(); query.addCondition(condition); query.setConstantScore(true); query.setSize(50000); TaxonDao dao = new TaxonDao(); QueryResult<Taxon> result; try { result = dao.query(query); if (result.getTotalSize() > 50000) { throw new ETLRuntimeException("Too many taxa"); } } catch (InvalidQueryException e) { throw new ETLRuntimeException(e); } return result; }  }
EnrichmentUtil { private static QueryResult<Taxon> loadTaxa(String[] names) { String field = "acceptedName.scientificNameGroup"; QueryCondition condition = new QueryCondition(field, "IN", names); QuerySpec query = new QuerySpec(); query.addCondition(condition); query.setConstantScore(true); query.setSize(50000); TaxonDao dao = new TaxonDao(); QueryResult<Taxon> result; try { result = dao.query(query); if (result.getTotalSize() > 50000) { throw new ETLRuntimeException("Too many taxa"); } } catch (InvalidQueryException e) { throw new ETLRuntimeException(e); } return result; }  static List<TaxonomicEnrichment> createEnrichments(List<Taxon> taxa); }
EnrichmentUtil { private static QueryResult<Taxon> loadTaxa(String[] names) { String field = "acceptedName.scientificNameGroup"; QueryCondition condition = new QueryCondition(field, "IN", names); QuerySpec query = new QuerySpec(); query.addCondition(condition); query.setConstantScore(true); query.setSize(50000); TaxonDao dao = new TaxonDao(); QueryResult<Taxon> result; try { result = dao.query(query); if (result.getTotalSize() > 50000) { throw new ETLRuntimeException("Too many taxa"); } } catch (InvalidQueryException e) { throw new ETLRuntimeException(e); } return result; }  static List<TaxonomicEnrichment> createEnrichments(List<Taxon> taxa);  }