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());
}
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");
}
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"));
}
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")));
}
Aggregations