Search in sources :

Example 46 with CypherQuery

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

the class ReportControllerTest method studies.

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

Example 47 with CypherQuery

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

the class ReportControllerTest method distinctSourceNoPrefix.

@Test
public void distinctSourceNoPrefix() throws IOException {
    CypherQuery source = new ReportController().sources("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("globi:someSourceId"));
    validate(source);
}
Also used : CypherQuery(org.eol.globi.util.CypherQuery) Test(org.junit.Test)

Example 48 with CypherQuery

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

the class ReportControllerTest method collections.

@Test
public void collections() throws IOException {
    CypherQuery source = new ReportController().collections();
    assertThat(source.getVersionedQuery(), is(CYPHER_VERSION + "START " + "report = node:reports('collection:*') " + "WHERE " + "not(exists(report.title)) " + "RETURN " + "null as study_citation, " + "null as study_url, " + "null 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"));
    validate(source);
}
Also used : CypherQuery(org.eol.globi.util.CypherQuery) Test(org.junit.Test)

Example 49 with CypherQuery

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

the class ReportControllerTest method distinctSourceOrgName.

@Test
public void distinctSourceOrgName() throws IOException {
    CypherQuery source = new ReportController().sourceOrgName("some", "name", 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/name"));
    validate(source);
}
Also used : CypherQuery(org.eol.globi.util.CypherQuery) Test(org.junit.Test)

Example 50 with CypherQuery

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

the class TaxonSearchUtilTest method createQueryWithSupportedId2.

@Test
public void createQueryWithSupportedId2() {
    CypherQuery query = TaxonSearchUtil.getCypherQuery("http://taxon-concept.plazi.org/id/Animalia/Caridae_Dana_1852", new HashMap());
    assertThat(query.getVersionedQuery(), Is.is("CYPHER 2.3 START someTaxon = node:taxons({pathQuery}) MATCH someTaxon-[:SAME_AS*0..1]->taxon WHERE exists(taxon.externalId) WITH DISTINCT(taxon.externalId) as externalId, taxon.externalUrl as externalUrl RETURN externalId as taxon_external_id,externalUrl as taxon_external_url"));
    assertThat(query.getParams().toString(), Is.is("{pathQuery=externalId:\"http://taxon-concept.plazi.org/id/Animalia/Caridae_Dana_1852\"}"));
    validate(query);
}
Also used : HashMap(java.util.HashMap) 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