use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findInteractionForLocationOnly.
@Test
public void findInteractionForLocationOnly() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("bbox", new String[] { "-67.87,12.79,-57.08,23.32" });
}
};
CypherQuery query = buildInteractionQuery(params, MULTI_TAXON_ALL);
assertThat(query.getQuery(), is("START loc = node:locations('latitude:*') " + EXPECTED_MATCH_CLAUSE_SPATIAL + "WHERE has(loc.latitude) AND has(loc.longitude) AND loc.latitude < 23.32 AND loc.longitude > -67.87 AND loc.latitude > 12.79 AND loc.longitude < -57.08 " + EXPECTED_RETURN_CLAUSE));
assertThat(query.getParams().isEmpty(), is(true));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findInteractionsTaxaInteractionIndexTargetTaxaNumberOfInteractionsExactNameMatchOnly.
@Test
public void findInteractionsTaxaInteractionIndexTargetTaxaNumberOfInteractionsExactNameMatchOnly() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("exactNameMatchOnly", new String[] { "true" });
put("targetTaxon", new String[] { "Arthropoda" });
put("field", new String[] { "source_taxon_name", "target_taxon_name", "number_of_interactions" });
}
};
CypherQuery query = buildInteractionQuery(params, MULTI_TAXON_DISTINCT_BY_NAME_ONLY);
assertThat(query.getQuery(), is("START targetTaxon = node:taxons({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.count as number_of_interactions"));
Map<String, String> expected = new HashMap<String, String>() {
{
put("target_taxon_name", "name:\\\"Arthropoda\\\"");
}
};
assertThat(query.getParams(), is(expected));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findSymbioticInteractions.
@Test
public void findSymbioticInteractions() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("sourceTaxon", new String[] { "Arthropoda" });
put("targetTaxon", new String[] { "Mammalia" });
put("interactionType", new String[] { "symbiontOf" });
}
};
String expectedQuery = "START sourceTaxon = node:taxonPaths({source_taxon_name}) " + expectedMatchClause(expectedInteractionClause(SYMBIONT_OF), false, true) + EXTERNAL_WHERE_CLAUSE_MAMMALIA + EXPECTED_RETURN_CLAUSE;
CypherQuery query = buildInteractionQuery(params, MULTI_TAXON_ALL);
assertThat(query.getQuery(), is(expectedQuery));
assertThat(query.getParams().toString(), is("{source_taxon_name=path:\\\"Arthropoda\\\", target_taxon_name=path:\\\"Mammalia\\\"}"));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findAnyInteractions.
@Test
public void findAnyInteractions() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("sourceTaxon", new String[] { "Arthropoda" });
put("targetTaxon", new String[] { "Mammalia" });
put("interactionType", new String[] { "interactsWith" });
}
};
String expectedQuery = "START sourceTaxon = node:taxonPaths({source_taxon_name}) " + expectedMatchClause(EXPECTED_INTERACTION_CLAUSE_ALL_INTERACTIONS, false, true) + EXTERNAL_WHERE_CLAUSE_MAMMALIA + EXPECTED_RETURN_CLAUSE;
CypherQuery query = buildInteractionQuery(params, MULTI_TAXON_ALL);
assertThat(query.getQuery(), is(expectedQuery));
assertThat(query.getParams().toString(), is("{source_taxon_name=path:\\\"Arthropoda\\\", target_taxon_name=path:\\\"Mammalia\\\"}"));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findPreyObservationsNoLocation.
@Test
public void findPreyObservationsNoLocation() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>();
CypherQuery query = buildInteractionQuery("Homo sapiens", "preysOn", null, params, SINGLE_TAXON_ALL);
assertThat(query.getQuery(), is("START sourceTaxon = node:taxonPaths({source_taxon_name}) MATCH sourceTaxon<-[:CLASSIFIED_AS]-sourceSpecimen-[interaction:" + InteractUtil.interactionsCypherClause(PREYS_UPON) + "]->targetSpecimen-[:CLASSIFIED_AS]->targetTaxon, sourceSpecimen<-[collected_rel:COLLECTED]-study, sourceSpecimen-[?:COLLECTED_AT]->loc " + expectedReturnClause()));
assertThat(query.getParams().toString(), is("{source_taxon_name=path:\\\"Homo sapiens\\\"}"));
}
Aggregations