Search in sources :

Example 36 with CypherQuery

use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.

the class TaxonSearchImplIT method findCloseMatchesCommonNameFoxDutch.

@Test
public void findCloseMatchesCommonNameFoxDutch() throws IOException {
    CypherQuery cypherQuery = new TaxonSearchImpl().findCloseMatchesForCommonAndScientificNames("vos", null);
    CypherTestUtil.validate(cypherQuery, neo4j.getGraphDatabaseService());
    String response = new CypherQueryExecutor(cypherQuery).execute(null);
    assertThat(response, startsWith(COLUMN_PREFIX));
    assertThat(response, StringContains.containsString("vos"));
}
Also used : CypherQuery(org.eol.globi.util.CypherQuery) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 37 with CypherQuery

use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.

the class TaxonSearchImplIT method ensureSingleMatch.

@Test
@Ignore
public void ensureSingleMatch() throws IOException {
    CypherQuery cypherQuery = new TaxonSearchImpl().findCloseMatchesForCommonAndScientificNames("Ariopsis felis", null);
    CypherTestUtil.validate(cypherQuery, neo4j.getGraphDatabaseService());
    String response = new CypherQueryExecutor(cypherQuery).execute(null);
    JsonNode jsonNode = new ObjectMapper().readTree(response);
    assertThat(jsonNode.get("data").get(0).get(0).asText(), is("Ariopsis felis"));
    assertThat(jsonNode.get("data").size(), is(1));
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) CypherQuery(org.eol.globi.util.CypherQuery) Matchers.containsString(org.hamcrest.Matchers.containsString) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 38 with CypherQuery

use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.

the class CypherHttpMessageConverterTest method optimizeQuerySVG2.

@Test
public void optimizeQuerySVG2() {
    CypherQuery cypherQuery = CypherHttpMessageConverter.optimizeQueryForType(new CypherQuery("bla bal LIMIT 10"), new ResultFormatterSVG());
    assertThat(cypherQuery.getQuery(), Is.is("bla bal LIMIT 1"));
}
Also used : CypherQuery(org.eol.globi.util.CypherQuery) Test(org.junit.Test)

Example 39 with CypherQuery

use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.

the class CypherHttpMessageConverterTest method optimizeQueryNonSVG.

@Test
public void optimizeQueryNonSVG() {
    CypherHttpMessageConverter cypherHttpMessageConverter = new CypherHttpMessageConverter();
    Stream<MediaType> nonSvg = cypherHttpMessageConverter.getSupportedMediaTypes().stream().filter(x -> !x.getSubtype().contains("svg+xml"));
    nonSvg.forEach(x -> {
        CypherQuery cypherQuery = CypherHttpMessageConverter.optimizeQueryForType(new CypherQuery("bla bal LIMIT 10"), new ResultFormatterFactory().create(x));
        assertThat(cypherQuery.getQuery(), Is.is("bla bal LIMIT 10"));
    });
}
Also used : MediaType(org.springframework.http.MediaType) CypherQuery(org.eol.globi.util.CypherQuery) Test(org.junit.Test)

Example 40 with CypherQuery

use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.

the class CypherQueryExecutorIT method executeQuery.

@Test
public void executeQuery() throws IOException {
    CypherQuery query = new CypherQuery("START sourceTaxon = node:taxonPaths('path:\\\"Homo sapiens\\\"') MATCH sourceTaxon<-[:CLASSIFIED_AS]-sourceSpecimen-[interaction:PREYS_UPON]->targetSpecimen-[:CLASSIFIED_AS]->targetTaxon, sourceSpecimen<-[collected_rel:COLLECTED]-study-[:IN_DATASET]->dataset RETURN sourceTaxon.name as source_taxon_name,interaction.label as interaction_type,collect(distinct(targetTaxon.name)) as target_taxon_name SKIP 0 LIMIT 1024");
    String execute = new CypherQueryExecutor(query).execute(null);
    assertThat(execute, containsString("columns"));
    assertNotNull(new ObjectMapper().readTree(execute));
}
Also used : CypherQuery(org.eol.globi.util.CypherQuery) StringContains.containsString(org.hamcrest.core.StringContains.containsString) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

CypherQuery (org.eol.globi.util.CypherQuery)109 Test (org.junit.Test)92 HashMap (java.util.HashMap)66 Matchers.containsString (org.hamcrest.Matchers.containsString)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 Map (java.util.Map)4 ResultField (org.eol.globi.server.util.ResultField)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 TreeMap (java.util.TreeMap)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 JsonNode (org.codehaus.jackson.JsonNode)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 InteractionTypeExternal (org.eol.globi.server.util.InteractionTypeExternal)1 ResultFormatterCSV (org.eol.globi.server.util.ResultFormatterCSV)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1