use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldNotReturnInternalCartesianPointType.
@Test
public void shouldNotReturnInternalCartesianPointType() throws Exception {
// given
GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
// when
Result execute = graphDb.execute("RETURN point({x: 13.37, y: 13.37, crs:'cartesian'}) AS p");
// then
Object obj = execute.next().get("p");
assertThat(obj, Matchers.instanceOf(Point.class));
Point point = (Point) obj;
assertThat(point.getCoordinate(), equalTo(new Coordinate(13.37, 13.37)));
CRS crs = point.getCRS();
assertThat(crs.getCode(), equalTo(7203));
assertThat(crs.getType(), equalTo("cartesian"));
assertThat(crs.getHref(), equalTo("http://spatialreference.org/ref/sr-org/7203/"));
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class DatabaseImporterTest method provideStoreDirectory.
private File provideStoreDirectory() {
File storeDir = testDir.graphDbDir();
GraphDatabaseService db = null;
try {
db = new TestGraphDatabaseFactory().newEmbeddedDatabase(storeDir);
try (Transaction transaction = db.beginTx()) {
db.createNode();
transaction.success();
}
} finally {
if (db != null) {
db.shutdown();
}
}
return storeDir;
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldExecuteCypher.
@Test
public void shouldExecuteCypher() throws Exception {
// given
GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
final long before, after;
try (Transaction tx = graphDb.beginTx()) {
before = Iterables.count(graphDb.getAllNodes());
tx.success();
}
// when
graphDb.execute("CREATE (n:Foo{bar:\"baz\"})");
// then
try (Transaction tx = graphDb.beginTx()) {
after = Iterables.count(graphDb.getAllNodes());
tx.success();
}
assertEquals(before + 1, after);
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldBeAbleToUseExternalGeometryAsParameterToQuery.
@Test
public void shouldBeAbleToUseExternalGeometryAsParameterToQuery() throws Exception {
// given a point created from public interface
GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
Geometry geometry = makeFakePointAsGeometry(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", geometry));
// 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 shouldNotReturnInternalPointWhenInMap.
@SuppressWarnings("unchecked")
@Test
public void shouldNotReturnInternalPointWhenInMap() throws Exception {
// given
GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
// when
Result execute = graphDb.execute("RETURN {p: point({longitude: 144.317718, latitude: -37.031738})} AS m");
// then
Map<String, Object> points = (Map<String, Object>) execute.next().get("m");
assertThat(points.get("p"), Matchers.instanceOf(Point.class));
}
Aggregations