use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldBeAbleToUseResultingPointFromOneQueryAsParameterToNext.
@Test
public void shouldBeAbleToUseResultingPointFromOneQueryAsParameterToNext() throws Exception {
// given a point create by one cypher query
GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
Result execute = graphDb.execute("RETURN point({longitude: 144.317718, latitude: -37.031738}) AS p");
Point point = (Point) execute.next().get("p");
// when passing as params to a distance function
Result result = graphDb.execute("RETURN distance(point({longitude: 144.317718, latitude: -37.031738}),{previous}) AS dist", map("previous", point));
// then
Double dist = (Double) result.next().get("dist");
assertThat(dist, equalTo(0.0));
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldBeAbleToUseExternalPointArrayAsParameterToQuery.
@Test
public void shouldBeAbleToUseExternalPointArrayAsParameterToQuery() throws Exception {
// given a point created from public interface
GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
Point point = makeFakePoint(144.317718, -37.031738, makeWGS84());
Point[] points = new Point[] { point, point };
// when passing as params to a distance function
Result result = graphDb.execute("RETURN distance({points}[0],{points}[1]) AS dist", map("points", points));
// then
Double dist = (Double) result.next().get("dist");
assertThat(dist, equalTo(0.0));
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldBeAbleToUseExternalPointAsParameterToQuery.
@Test
public void shouldBeAbleToUseExternalPointAsParameterToQuery() throws Exception {
// given a point created from public interface
GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
Point point = makeFakePoint(144.317718, -37.031738, makeWGS84());
// when passing as params to a distance function
Result result = graphDb.execute("RETURN distance(point({longitude: 144.317718, latitude: -37.031738}),{previous}) AS dist", map("previous", point));
// then
Double dist = (Double) result.next().get("dist");
assertThat(dist, equalTo(0.0));
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldBeAbleToUseResultsOfPointProcedureAsInputToDistanceFunction.
@Test
public void shouldBeAbleToUseResultsOfPointProcedureAsInputToDistanceFunction() throws Exception {
// given procedure that produces a point
GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
Procedures procedures = ((GraphDatabaseAPI) graphDb).getDependencyResolver().resolveDependency(Procedures.class);
procedures.registerProcedure(PointProcs.class);
// when calling procedure that produces a point
Result result = graphDb.execute("CALL spatial.point(144.317718, -37.031738) YIELD point " + "RETURN distance(point({longitude: 144.317718, latitude: -37.031738}), point) AS dist");
// then
Double dist = (Double) result.next().get("dist");
assertThat(dist, equalTo(0.0));
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldNotReturnInternalPointWhenInArray.
@SuppressWarnings("unchecked")
@Test
public void shouldNotReturnInternalPointWhenInArray() throws Exception {
// given
GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
// when
Result execute = graphDb.execute("RETURN [point({longitude: 144.317718, latitude: -37.031738})] AS ps");
// then
List<Point> points = (List<Point>) execute.next().get("ps");
assertThat(points.get(0), Matchers.instanceOf(Point.class));
}
Aggregations