use of com.google.spanner.v1.Session in project cypher-for-gremlin by opencypher.
the class GremlinNeo4jDriverTest method returnNodeAndRelationship.
@Test
public void returnNodeAndRelationship() {
Driver driver = GremlinDatabase.driver("//localhost:" + server.getPort());
try (Session session = driver.session()) {
StatementResult result = session.run("CREATE (n1:Person {name: 'Marko'})-[r:knows {since:1999}]->(n2:Person)" + "RETURN n1,r,n2", parameters("message", "Hello"));
Record record = result.single();
Node n1 = record.get("n1").asNode();
Relationship r = record.get("r").asRelationship();
Node n2 = record.get("n2").asNode();
assertThat(n1.hasLabel("Person")).isTrue();
assertThat(n1.get("name").asString()).isEqualTo("Marko");
assertThat(r.hasType("knows")).isTrue();
assertThat(r.startNodeId()).isEqualTo(n1.id());
assertThat(r.endNodeId()).isEqualTo(n2.id());
assertThat(r.get("since").asLong()).isEqualTo(1999L);
assertThat(n2.hasLabel("Person")).isTrue();
}
}
use of com.google.spanner.v1.Session in project cypher-for-gremlin by opencypher.
the class GremlinNeo4jDriverTest method withMultipleParameters.
@Test
public void withMultipleParameters() {
Driver driver = GremlinDatabase.driver("//localhost:" + server.getPort());
Map<String, Object> properties = new HashMap<>();
properties.put("p1", 1L);
properties.put("p2", 2L);
try (Session session = driver.session()) {
StatementResult result = session.run("CREATE (a:Greeting) " + "SET a.p1 = $p1, " + "a.p2 = $p2 " + "RETURN a.p1, a.p2", properties);
Record record = result.single();
assertThat(record.get("a.p1").asLong()).isEqualTo(1L);
assertThat(record.get("a.p2").asLong()).isEqualTo(2L);
}
}
use of com.google.spanner.v1.Session in project cypher-for-gremlin by opencypher.
the class GremlinNeo4jDriverTest method invalidSyntax.
@Test
public void invalidSyntax() {
Driver driver = GremlinDatabase.driver("//localhost:" + server.getPort());
try (Session session = driver.session()) {
StatementResult result = session.run("INVALID");
Throwable throwable = catchThrowable(result::list);
assertThat(throwable).hasMessageContaining("Invalid input");
}
}
use of com.google.spanner.v1.Session in project cypher-for-gremlin by opencypher.
the class GremlinNeo4jDriverTest method invalidSyntaxInTranslation.
@Test
public void invalidSyntaxInTranslation() {
Config config = Config.build().withTranslation(TranslatorFlavor.gremlinServer()).toConfig();
Driver driver = GremlinDatabase.driver("//localhost:" + server.getPort(), config);
try (Session session = driver.session()) {
StatementResult result = session.run("INVALID");
Throwable throwable = catchThrowable(result::list);
assertThat(throwable).hasMessageContaining("Invalid input");
}
}
use of com.google.spanner.v1.Session in project cypher-for-gremlin by opencypher.
the class GremlinNeo4jDriverTest method simple.
@Test
public void simple() {
Driver adam = GremlinDatabase.driver("//localhost:" + server.getPort());
try (Session session = adam.session()) {
StatementResult result = session.run("MATCH (n:person) RETURN count(n) as count");
int count = result.single().get("count").asInt();
assertThat(count).isEqualTo(4);
}
}
Aggregations