Search in sources :

Example 1 with PagingAndSortingQuery

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

the class NodeQueryStatementsTest method testFindOneZeroDepthPrimaryIndex.

@Test
public void testFindOneZeroDepthPrimaryIndex() {
    PagingAndSortingQuery query = primaryQueryStatements.findOne("test-uuid", 0);
    assertThat(query.getStatement()).isEqualTo("MATCH (n) WHERE n.`uuid` = $id WITH n RETURN n");
}
Also used : PagingAndSortingQuery(org.neo4j.ogm.cypher.query.PagingAndSortingQuery) Test(org.junit.Test)

Example 2 with PagingAndSortingQuery

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

the class NodeQueryStatementsTest method testFindOnePrimaryIndex.

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

Example 3 with PagingAndSortingQuery

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

the class NodeQueryStatementsTest method testFindOneByTypePrimaryIndex.

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

Example 4 with PagingAndSortingQuery

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

the class NodeQueryStatementsTest method testFindByPropertyWithInfiniteValue.

// DATAGRAPH-781
@Test
public void testFindByPropertyWithInfiniteValue() {
    PagingAndSortingQuery pagingAndSortingQuery = queryStatements.findByType("Asteroid", new Filters().add(new Filter("albedo", ComparisonOperator.EQUALS, -12.2)), 0);
    assertThat(pagingAndSortingQuery.getStatement()).isEqualTo("MATCH (n:`Asteroid`) WHERE n.`albedo` = $`albedo_0` WITH n RETURN n");
    assertThat((double) pagingAndSortingQuery.getParameters().get("albedo_0")).isEqualTo(-12.2, within(0.005));
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) PagingAndSortingQuery(org.neo4j.ogm.cypher.query.PagingAndSortingQuery) Test(org.junit.Test)

Example 5 with PagingAndSortingQuery

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

the class ParameterisedStatementsTest method testStatement.

@Test
public void testStatement() throws Exception {
    List<Statement> statements = new ArrayList<>();
    PagingAndSortingQuery query = new NodeQueryStatements().findOne(123L, 1);
    statements.add(new DefaultGraphModelRequest(query.getStatement(), query.getParameters()));
    String cypher = mapper.writeValueAsString(new Statements(statements));
    assertThat(cypher).isEqualTo("{\"statements\":[{\"statement\":\"MATCH (n) WHERE ID(n) = $id WITH n MATCH p=(n)-[*0..1]-(m) RETURN p\",\"parameters\":{\"id\":123},\"resultDataContents\":[\"graph\"],\"includeStats\":false}]}");
}
Also used : DefaultGraphModelRequest(org.neo4j.ogm.cypher.query.DefaultGraphModelRequest) Statement(org.neo4j.ogm.request.Statement) ArrayList(java.util.ArrayList) Statements(org.neo4j.ogm.request.Statements) 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