use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class ParameterisedStatementTest method findByPropertyDecimal.
@Test
public void findByPropertyDecimal() throws Exception {
query = nodeQueryStatements.findByType("Asteroid", new Filters().add(new Filter("diameter", ComparisonOperator.EQUALS, 60.2)), 1);
assertThat(query.getStatement()).isEqualTo("MATCH (n:`Asteroid`) WHERE n.`diameter` = $`diameter_0` WITH n MATCH p=(n)-[*0..1]-(m) RETURN p, ID(n)");
assertThat(mapper.writeValueAsString(query.getParameters())).isEqualTo("{\"diameter_0\":60.2}");
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class ParameterisedStatementTest method findByPropertyEmbeddedDelimiter.
@Test
public void findByPropertyEmbeddedDelimiter() throws Exception {
query = nodeQueryStatements.findByType("Cookbooks", new Filters().add(new Filter("title", ComparisonOperator.EQUALS, "Mrs Beeton's Household Recipes")), 1);
assertThat(query.getStatement()).isEqualTo("MATCH (n:`Cookbooks`) WHERE n.`title` = $`title_0` WITH n MATCH p=(n)-[*0..1]-(m) RETURN p, ID(n)");
assertThat(mapper.writeValueAsString(query.getParameters())).isEqualTo("{\"title_0\":\"Mrs Beeton's Household Recipes\"}");
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class ParameterisedStatementTest method findByPropertyIntegralValue.
@Test
public void findByPropertyIntegralValue() throws Exception {
query = nodeQueryStatements.findByType("Asteroid", new Filters().add(new Filter("index", ComparisonOperator.EQUALS, 77)), 1);
assertThat(query.getStatement()).isEqualTo("MATCH (n:`Asteroid`) WHERE n.`index` = $`index_0` WITH n MATCH p=(n)-[*0..1]-(m) RETURN p, ID(n)");
assertThat(mapper.writeValueAsString(query.getParameters())).isEqualTo("{\"index_0\":77}");
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class RelationshipQueryStatementsTest method testFindByMultipleNestedPropertiesOnBothEnds.
// DATAGRAPH-632
@Test
public void testFindByMultipleNestedPropertiesOnBothEnds() {
Filter moonFilter = new Filter("name", ComparisonOperator.EQUALS, "Earth");
moonFilter.setNestedPropertyName("world");
moonFilter.setNestedEntityTypeLabel("Moon");
moonFilter.setRelationshipType("ORBITS");
moonFilter.setRelationshipDirection(Relationship.Direction.OUTGOING);
Filter planetFilter = new Filter("colour", ComparisonOperator.EQUALS, "Red");
planetFilter.setNestedPropertyName("colour");
planetFilter.setNestedEntityTypeLabel("Planet");
planetFilter.setRelationshipType("ORBITS");
planetFilter.setRelationshipDirection(Relationship.Direction.INCOMING);
assertThat(query.findByType("ORBITS", new Filters().add(moonFilter, planetFilter), 4).getStatement()).isEqualTo("MATCH (n:`Moon`) WHERE n.`name` = $`world_name_0` MATCH (m:`Planet`) WHERE m.`colour` = $`colour_colour_1` " + "MATCH (n)-[r0:`ORBITS`]->(m) WITH DISTINCT(r0) as r0,startnode(r0) AS n, endnode(r0) AS m " + "MATCH p1 = (n)-[*0..4]-() WITH r0, COLLECT(DISTINCT p1) AS startPaths, m " + "MATCH p2 = (m)-[*0..4]-() WITH r0, startPaths, COLLECT(DISTINCT p2) AS endPaths " + "WITH r0,startPaths + endPaths AS paths UNWIND paths AS p RETURN DISTINCT p, ID(r0)");
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class RelationshipQueryStatementsTest method testFindByMultipleNestedProperties.
// DATAGRAPH-632
@Test
public void testFindByMultipleNestedProperties() {
Filter planetNameFilter = new Filter("name", ComparisonOperator.EQUALS, "Earth");
planetNameFilter.setNestedPropertyName("world");
planetNameFilter.setNestedEntityTypeLabel("Planet");
planetNameFilter.setRelationshipType("ORBITS");
planetNameFilter.setRelationshipDirection(Relationship.Direction.OUTGOING);
Filter planetMoonsFilter = new Filter("moons", ComparisonOperator.EQUALS, "Earth");
planetMoonsFilter.setNestedPropertyName("moons");
planetMoonsFilter.setNestedEntityTypeLabel("Planet");
planetMoonsFilter.setRelationshipType("ORBITS");
planetMoonsFilter.setRelationshipDirection(Relationship.Direction.OUTGOING);
planetMoonsFilter.setBooleanOperator(BooleanOperator.AND);
assertThat(query.findByType("ORBITS", new Filters().add(planetNameFilter, planetMoonsFilter), 4).getStatement()).isEqualTo("MATCH (n:`Planet`) WHERE n.`name` = $`world_name_0` AND n.`moons` = $`moons_moons_1` " + "MATCH (n)-[r0:`ORBITS`]->(m) WITH DISTINCT(r0) as r0,startnode(r0) AS n, endnode(r0) AS m " + "MATCH p1 = (n)-[*0..4]-() WITH r0, COLLECT(DISTINCT p1) AS startPaths, m " + "MATCH p2 = (m)-[*0..4]-() WITH r0, startPaths, COLLECT(DISTINCT p2) AS endPaths " + "WITH r0,startPaths + endPaths AS paths " + "UNWIND paths AS p RETURN DISTINCT p, ID(r0)");
}
Aggregations