Search in sources :

Example 91 with CypherQuery

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

the class TaxonSearchImplIT method findCloseMatchesShortPartialFields.

@Test
public void findCloseMatchesShortPartialFields() throws IOException {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    when(request.getParameterMap()).thenReturn(new HashMap<String, String[]>() {

        {
            put("field", new String[] { "taxon_external_id", "taxon_name" });
        }
    });
    when(request.getParameter("limit")).thenReturn("10");
    CypherQuery cypherQuery = new TaxonSearchImpl().findCloseMatchesForCommonAndScientificNames("Homo s", request);
    CypherTestUtil.validate(cypherQuery, neo4j.getGraphDatabaseService());
    String response = new CypherQueryExecutor(cypherQuery).execute(request);
    assertThat(cypherQuery.getQuery(), StringContains.containsString("LIMIT 10"));
    assertThat(response, StringContains.containsString("taxon_external_id"));
    assertThat(response, StringContains.containsString("taxon_name"));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Matchers.containsString(org.hamcrest.Matchers.containsString) CypherQuery(org.eol.globi.util.CypherQuery) Test(org.junit.Test)

Example 92 with CypherQuery

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

the class CypherHttpMessageConverterTest method optimizeQuerySVG.

@Test
public void optimizeQuerySVG() {
    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 93 with CypherQuery

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

the class ReportControllerTest method sources.

@Test
public void sources() throws IOException {
    CypherQuery source = new ReportController().sources(null, null);
    assertThat(source.getVersionedQuery(), is(CYPHER_VERSION + "START report = node:reports('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().size(), is(0));
    validate(source);
}
Also used : CypherQuery(org.eol.globi.util.CypherQuery) Test(org.junit.Test)

Example 94 with CypherQuery

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

the class ReportControllerTest method studiesForSource.

@Test
public void studiesForSource() throws IOException {
    CypherQuery source = new ReportController().studies("a source", null);
    assertThat(source.getVersionedQuery(), is(CYPHER_VERSION + "START report = node:reports(source={source}) " + "WHERE exists(report.title) " + "RETURN report.citation as study_citation, " + "report.externalId as study_url, " + "report.doi as study_doi, " + "report.source 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 " + "SKIP 0 " + "LIMIT 1024"));
    assertThat(source.getParams().get("source"), is("a source"));
    validate(source);
}
Also used : CypherQuery(org.eol.globi.util.CypherQuery) Test(org.junit.Test)

Example 95 with CypherQuery

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

the class ReportControllerTest method distinctSourceOrg.

@Test
public void distinctSourceOrg() throws IOException {
    CypherQuery source = new ReportController().sourceOrg("some", null);
    assertThat(source.getVersionedQuery(), is(CYPHER_VERSION + "START dataset = node:datasets(namespace={namespace}), report = node:reports('sourceId:*') " + "WHERE ('globi:' + dataset.namespace) = report.sourceId " + "RETURN report.citation as study_citation, " + "report.externalId as study_url, " + "report.doi as study_doi, " + "dataset.citation 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, " + "dataset.doi as study_source_doi, " + "dataset.format as study_source_format, " + "dataset.archiveURI as study_source_archive_uri, " + "dataset.lastSeenAt as study_source_last_seen_at " + "SKIP 0 " + "LIMIT 1024"));
    assertThat(source.getParams().get("namespace"), is("some"));
    validate(source);
}
Also used : CypherQuery(org.eol.globi.util.CypherQuery) 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