use of com.google.spanner.v1.Session in project cypher-for-gremlin by opencypher.
the class GremlinNeo4jDriverTest method multipleRows.
@Test
public void multipleRows() {
Cluster cluster = Cluster.build().addContactPoints("localhost").port(server.getPort()).create();
Driver driver = GremlinDatabase.driver(cluster);
try (Session session = driver.session()) {
StatementResult result = session.run("MATCH (p:person) RETURN p.name, p.age");
List<String> rows = result.list(r -> r.get("p.name").asString() + r.get("p.age").asInt());
assertThat(rows).containsExactly("marko29", "vadas27", "josh32", "peter35");
}
}
use of com.google.spanner.v1.Session 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
}
use of com.google.spanner.v1.Session in project open-kilda by telstra.
the class NeoDriver method getFlowInfo.
/**
* {@inheritDoc}
*/
@Override
public List<FlowInfo> getFlowInfo() {
List<FlowInfo> flows = new ArrayList<>();
String subject = "MATCH (:switch)-[f:flow]->(:switch) " + "RETURN f.flowid as flow_id, " + " f.cookie as cookie, " + " f.meter_id as meter_id, " + " f.transit_vlan as transit_vlan, " + " f.src_switch as src_switch";
Session session = driver.session();
StatementResult result = session.run(subject);
for (Record record : result.list()) {
flows.add(new FlowInfo().setFlowId(record.get("flow_id").asString()).setSrcSwitchId(record.get("src_switch").asString()).setCookie(record.get("cookie").asLong()).setMeterId(record.get("meter_id").asInt()).setTransitVlanId(record.get("transit_vlan").asInt()));
}
return flows;
}
use of com.google.spanner.v1.Session in project acceptance-test-harness by jenkinsci.
the class Ssh method executeRemoteCommand.
public int executeRemoteCommand(String cmd, OutputStream os) {
Session session = null;
try {
session = connection.openSession();
int status = connection.exec(cmd, os);
if (status != 0) {
throw new RuntimeException("Failed to execute command: " + cmd + ", exit code = " + status);
}
return status;
} catch (InterruptedException | IOException e) {
throw new AssertionError(e);
} finally {
if (session != null) {
session.close();
}
}
}
use of com.google.spanner.v1.Session in project tutorials by eugenp.
the class Neo4JServerLiveTest method standAloneDriver.
@Test
public void standAloneDriver() {
Driver driver = GraphDatabase.driver("bolt://localhost:7687", AuthTokens.basic("neo4j", "12345"));
Session session = driver.session();
session.run("CREATE (baeldung:Company {name:\"Baeldung\"}) " + "-[:owns]-> (tesla:Car {make: 'tesla', model: 'modelX'})" + "RETURN baeldung, tesla");
StatementResult result = session.run("MATCH (company:Company)-[:owns]-> (car:Car)" + "WHERE car.make='tesla' and car.model='modelX'" + "RETURN company.name");
Assert.assertTrue(result.hasNext());
Assert.assertEquals(result.next().get("company.name").asString(), "Baeldung");
session.close();
driver.close();
}
Aggregations