use of org.apache.tinkerpop.gremlin.driver.Client in project cypher-for-gremlin by opencypher.
the class OpProcessorCypherGremlinClientTest method submitToNonExistentAlias.
@Test
public void submitToNonExistentAlias() {
Client gremlinClient = gremlinServer.gremlinClient().alias("does_not_exist");
OpProcessorCypherGremlinClient client = new OpProcessorCypherGremlinClient(gremlinClient);
String cypher = "MATCH (p:person) RETURN p.name AS name";
assertThatThrownBy(() -> client.submit(cypher).all()).hasMessageContaining("Traversable alias 'does_not_exist' not found");
}
use of org.apache.tinkerpop.gremlin.driver.Client in project cypher-for-gremlin by opencypher.
the class OpProcessorCypherGremlinClientTest method invalidSyntax.
@Test
public void invalidSyntax() {
Client gremlinClient = gremlinServer.gremlinClient();
OpProcessorCypherGremlinClient client = new OpProcessorCypherGremlinClient(gremlinClient);
CypherResultSet resultSet = client.submit("INVALID");
Throwable throwable = catchThrowable(resultSet::all);
assertThat(throwable).hasMessageContaining("Invalid input");
}
use of org.apache.tinkerpop.gremlin.driver.Client in project cypher-for-gremlin by opencypher.
the class OpProcessorCypherGremlinClientTest method submitToAlias.
private void submitToAlias(String alias) {
Client gremlinClient = gremlinServer.gremlinClient().alias(alias);
OpProcessorCypherGremlinClient client = new OpProcessorCypherGremlinClient(gremlinClient);
String cypher = "MATCH (p:person) RETURN p.name AS name";
List<Map<String, Object>> results = client.submit(cypher).all();
assertThat(results).extracting("name").containsExactlyInAnyOrder("marko", "vadas", "josh", "peter");
}
use of org.apache.tinkerpop.gremlin.driver.Client in project cypher-for-gremlin by opencypher.
the class CypherGremlinServerClient method gremlinStyle.
@Test
public void gremlinStyle() throws Exception {
BaseConfiguration configuration = new BaseConfiguration();
configuration.setProperty("port", gremlinServer.getPort());
configuration.setProperty("hosts", Arrays.asList("localhost"));
// freshReadmeSnippet: gremlinStyle
Cluster cluster = Cluster.open(configuration);
Client gremlinClient = cluster.connect();
CypherGremlinClient cypherGremlinClient = CypherGremlinClient.plugin(gremlinClient);
String cypher = "MATCH (p:person) WHERE p.age > 25 RETURN p.name";
CypherResultSet resultSet = cypherGremlinClient.submit(cypher);
List<Map<String, Object>> results = resultSet.all();
// freshReadmeSnippet: gremlinStyle
assertThat(results).extracting("p.name").containsExactly("marko", "vadas", "josh", "peter");
}
use of org.apache.tinkerpop.gremlin.driver.Client in project cypher-for-gremlin by opencypher.
the class GremlinServerDriver method session.
@Override
public Session session() {
Client gremlinClient = cluster.connect();
CypherGremlinClient cypherGremlinClient = config.translationEnabled() ? CypherGremlinClient.translating(gremlinClient, config.flavor()) : CypherGremlinClient.plugin(gremlinClient);
return new GremlinServerSession(serverInfo, cypherGremlinClient);
}
Aggregations