use of org.opencypher.Config in project cypher-for-gremlin by opencypher.
the class GremlinNeo4jDriverTest method translating.
@Test
public void translating() {
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("MATCH (n:person) RETURN count(n) as count");
int count = result.single().get("count").asInt();
assertThat(count).isEqualTo(4);
}
}
use of org.opencypher.Config 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 org.opencypher.Config in project cypher-for-gremlin by opencypher.
the class CypherGremlinNeo4jDriver method createUseDriver.
@Test
public void createUseDriver() throws Exception {
int port = gremlinServer.getPort();
// freshReadmeSnippet: createConfiguration
Config config = Config.build().withTranslation().toConfig();
String uri = "//localhost:" + port;
Driver driver = GremlinDatabase.driver(uri, config);
// freshReadmeSnippet: useDriver
try (Session session = driver.session()) {
StatementResult result = session.run("CREATE (a:Greeting) " + "SET a.message = $message " + "RETURN a.message", parameters("message", "Hello"));
String message = result.single().get(0).asString();
assertThat(message).isEqualTo("Hello");
}
// freshReadmeSnippet: useDriver
}
Aggregations