use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findInteractionsTaxaInteractionIndexTargetTaxaNumberOfInteractionsInteractionType.
@Test
public void findInteractionsTaxaInteractionIndexTargetTaxaNumberOfInteractionsInteractionType() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("targetTaxon", new String[] { "Arthropoda" });
put("field", new String[] { "source_taxon_name", "target_taxon_name", "interaction_type" });
}
};
CypherQuery query = buildInteractionQuery(params, MULTI_TAXON_DISTINCT_BY_NAME_ONLY);
assertThat(query.getQuery(), is("START targetTaxon = node:taxonPaths({target_taxon_name}) " + "MATCH sourceTaxon-[interaction:" + InteractUtil.interactionsCypherClause(INTERACTS_WITH) + "]->targetTaxon " + "RETURN sourceTaxon.name as source_taxon_name,targetTaxon.name as target_taxon_name,interaction.label? as interaction_type"));
Map<String, String> expected = new HashMap<String, String>() {
{
put("target_taxon_name", "path:\\\"Arthropoda\\\"");
}
};
assertThat(query.getParams(), is(expected));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class ReportControllerTest method distinctSourcePrefix.
@Test
public void distinctSourcePrefix() throws IOException {
CypherQuery source = new ReportController().sources("bla:someSourceId", null);
assertThat(source.getVersionedQuery(), is(CYPHER_VERSION + "START report = node:reports(sourceId={sourceId}) " + "RETURN report.citation as study_citation, " + "report.externalId as study_url, " + "report.doi as study_doi, " + "null as study_source_citation, " + "report.nInteractions as number_of_interactions, " + "report.nTaxa as number_of_distinct_taxa, " + "report.nStudies as number_of_studies, " + "report.nSources as number_of_sources, " + "report.nTaxaNoMatch as number_of_distinct_taxa_no_match, " + "report.sourceId as study_source_id " + "SKIP 0 " + "LIMIT 1024"));
assertThat(source.getParams().get("sourceId"), is("bla:someSourceId"));
validate(source);
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class TaxonSearchImplIT method findCloseMatchesShortPartial2.
@Test
public void findCloseMatchesShortPartial2() throws IOException {
CypherQuery cypherQuery = new TaxonSearchImpl().findCloseMatchesForCommonAndScientificNames("h s", null);
CypherTestUtil.validate(cypherQuery, neo4j.getGraphDatabaseService());
String response = new CypherQueryExecutor(cypherQuery).execute(null);
assertThat(response.startsWith(COLUMN_PREFIX), is(true));
// expect at least one common name
assertThat(response, StringContains.containsString("@en"));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class TaxonSearchImplIT method assertHuman.
private void assertHuman(String searchTerm) throws IOException {
CypherQuery cypherQuery = new TaxonSearchImpl().findCloseMatchesForCommonAndScientificNames(searchTerm, null);
CypherTestUtil.validate(cypherQuery, neo4j.getGraphDatabaseService());
String response = new CypherQueryExecutor(cypherQuery).execute(null);
assertThat(response, startsWith(COLUMN_PREFIX));
assertThat(response, StringContains.containsString("Homo sapiens"));
assertThat(response, StringContains.containsString("man"));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class TaxonSearchImplIT method findCloseMatchesScientificGenus.
@Test
public void findCloseMatchesScientificGenus() throws IOException {
CypherQuery cypherQuery = new TaxonSearchImpl().findCloseMatchesForCommonAndScientificNames("Ariidae", null);
CypherTestUtil.validate(cypherQuery, neo4j.getGraphDatabaseService());
String response = new CypherQueryExecutor(cypherQuery).execute(null);
JsonNode mapper = new ObjectMapper().readTree(response);
JsonNode data = mapper.get("data");
assertThat(data.isArray(), is(true));
assertThat(data.size() > 0, is(true));
assertThat(response, StringContains.containsString("Ariidae"));
}
Aggregations