Search in sources :

Example 16 with PagingAndSortingQuery

use of org.neo4j.ogm.cypher.query.PagingAndSortingQuery in project neo4j-ogm by neo4j.

the class NodeQueryStatementsTest method testFindOneByType.

@Test
public void testFindOneByType() {
    PagingAndSortingQuery query = queryStatements.findOneByType("Orbit", 0L, 2);
    assertThat(query.getStatement()).isEqualTo("MATCH (n:`Orbit`) WHERE ID(n) = $id WITH n MATCH p=(n)-[*0..2]-(m) RETURN p");
    assertThat(query.getParameters()).containsEntry("id", 0L);
    // Also assert that an empty label is the same as using the typeless variant
    assertThat(queryStatements.findOne(0L, 2).getStatement()).isEqualTo(queryStatements.findOneByType("", 0L, 2).getStatement());
    assertThat(queryStatements.findOne(0L, 2).getStatement()).isEqualTo(queryStatements.findOneByType(null, 0L, 2).getStatement());
}
Also used : PagingAndSortingQuery(org.neo4j.ogm.cypher.query.PagingAndSortingQuery) Test(org.junit.Test)

Example 17 with PagingAndSortingQuery

use of org.neo4j.ogm.cypher.query.PagingAndSortingQuery in project neo4j-ogm by neo4j.

the class NodeQueryStatementsTest method testFindOneByTypePrimaryIndexInfiniteDepth.

@Test
public void testFindOneByTypePrimaryIndexInfiniteDepth() {
    PagingAndSortingQuery query = primaryQueryStatements.findOneByType("Orbit", "test-uuid", -1);
    assertThat(query.getStatement()).isEqualTo("MATCH (n:`Orbit`) WHERE n.`uuid` = $id WITH n MATCH p=(n)-[*0..]-(m) RETURN p");
    assertThat(query.getParameters()).containsEntry("id", "test-uuid");
}
Also used : PagingAndSortingQuery(org.neo4j.ogm.cypher.query.PagingAndSortingQuery) Test(org.junit.Test)

Example 18 with PagingAndSortingQuery

use of org.neo4j.ogm.cypher.query.PagingAndSortingQuery in project neo4j-ogm by neo4j.

the class RelationshipQueryStatementsTest method testFindOneByTypePrimaryIndex.

@Test
public void testFindOneByTypePrimaryIndex() {
    PagingAndSortingQuery pagingAndSortingQuery = primaryQuery.findOneByType("ORBITS", "test-uuid", 2);
    assertThat(pagingAndSortingQuery.getStatement()).isEqualTo("MATCH ()-[r0:`ORBITS`]->() WHERE r0.`uuid`=$id  " + "WITH r0, STARTNODE(r0) AS n, ENDNODE(r0) AS m MATCH p1 = (n)-[*0..2]-() " + "WITH r0, COLLECT(DISTINCT p1) AS startPaths, m MATCH p2 = (m)-[*0..2]-() " + "WITH r0, startPaths, COLLECT(DISTINCT p2) AS endPaths " + "WITH r0,startPaths + endPaths  AS paths UNWIND paths AS p RETURN DISTINCT p, ID(r0)");
    assertThat(pagingAndSortingQuery.getParameters()).contains(entry("id", "test-uuid"));
}
Also used : PagingAndSortingQuery(org.neo4j.ogm.cypher.query.PagingAndSortingQuery) Test(org.junit.Test)

Example 19 with PagingAndSortingQuery

use of org.neo4j.ogm.cypher.query.PagingAndSortingQuery in project neo4j-ogm by neo4j.

the class RelationshipQueryStatementsTest method testFindAllByTypePrimaryIndex.

@Test
public void testFindAllByTypePrimaryIndex() {
    PagingAndSortingQuery pagingAndSortingQuery = primaryQuery.findAllByType("ORBITS", Arrays.asList("test-uuid-1", "test-uuid-2"), 2);
    assertThat(pagingAndSortingQuery.getStatement()).isEqualTo("MATCH ()-[r0:`ORBITS`]-() WHERE r0.`uuid` IN $ids  " + "WITH DISTINCT(r0) as r0, startnode(r0) AS n, endnode(r0) AS m MATCH p1 = (n)-[*0..2]-() " + "WITH r0, COLLECT(DISTINCT p1) AS startPaths, m MATCH p2 = (m)-[*0..2]-() " + "WITH r0, startPaths, COLLECT(DISTINCT p2) AS endPaths " + "WITH r0,startPaths + endPaths  AS paths " + "UNWIND paths AS p RETURN DISTINCT p, ID(r0)");
    assertThat(pagingAndSortingQuery.getParameters()).contains(entry("ids", Arrays.asList("test-uuid-1", "test-uuid-2")));
}
Also used : PagingAndSortingQuery(org.neo4j.ogm.cypher.query.PagingAndSortingQuery) Test(org.junit.Test)

Aggregations

PagingAndSortingQuery (org.neo4j.ogm.cypher.query.PagingAndSortingQuery)19 Test (org.junit.Test)14 DefaultGraphModelRequest (org.neo4j.ogm.cypher.query.DefaultGraphModelRequest)4 GraphRowModelMapper (org.neo4j.ogm.context.GraphRowModelMapper)3 SortOrder (org.neo4j.ogm.cypher.query.SortOrder)3 GraphModel (org.neo4j.ogm.model.GraphModel)3 GraphModelRequest (org.neo4j.ogm.request.GraphModelRequest)3 ClassInfo (org.neo4j.ogm.metadata.ClassInfo)2 FilteredQuery (org.neo4j.ogm.session.request.FilteredQuery)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1 GraphRowListModelMapper (org.neo4j.ogm.context.GraphRowListModelMapper)1 Filter (org.neo4j.ogm.cypher.Filter)1 Filters (org.neo4j.ogm.cypher.Filters)1 DefaultGraphRowListModelRequest (org.neo4j.ogm.cypher.query.DefaultGraphRowListModelRequest)1 Pagination (org.neo4j.ogm.cypher.query.Pagination)1 InvalidDepthException (org.neo4j.ogm.exception.core.InvalidDepthException)1 FieldInfo (org.neo4j.ogm.metadata.FieldInfo)1 GraphRowListModel (org.neo4j.ogm.model.GraphRowListModel)1