use of com.datastax.dse.driver.api.core.graph.GraphNode in project java-driver by datastax.
the class GraphTraversalITBase method should_resolve_path_with_labels.
/**
* Validates that when traversing a path and labeling all of the elements during the traversal
* that the output elements are properly labeled.
*
* @test_category dse:graph
*/
@Test
public void should_resolve_path_with_labels() {
GraphResultSet rs = session().execute(newInstance(graphTraversalSource().V().hasLabel("person").has("name", "marko").as("a").outE("knows").as("b").inV().as("c", "d").outE("created").as("e", "f", "g").inV().as("h").path()));
List<GraphNode> results = rs.all();
assertThat(results.size()).isEqualTo(2);
for (GraphNode result : results) {
Path path = result.asPath();
validatePathObjects(path);
assertThat(path.labels()).hasSize(5);
assertThat(path).hasLabel(0, "a").hasLabel(1, "b").hasLabel(2, "c", "d").hasLabel(3, "e", "f", "g").hasLabel(4, "h");
}
}
use of com.datastax.dse.driver.api.core.graph.GraphNode in project java-driver by datastax.
the class GraphTraversalITBase method should_handle_asynchronous_execution_graph_binary.
@Test
public void should_handle_asynchronous_execution_graph_binary() {
Assumptions.assumeThat(isGraphBinary()).isTrue();
StringBuilder names = new StringBuilder();
CompletionStage<AsyncGraphResultSet> future = session().executeAsync(FluentGraphStatement.newInstance(graphTraversalSource().V().hasLabel("person")));
try {
// dumb processing to make sure the completable future works correctly and correct results are
// returned
Iterable<GraphNode> results = future.thenApply(AsyncGraphResultSet::currentPage).toCompletableFuture().get();
for (GraphNode gn : results) {
names.append(gn.asVertex().id());
}
} catch (InterruptedException | ExecutionException e) {
fail("Shouldn't have thrown an exception waiting for the result to complete");
}
assertThat(names.toString()).contains("peter", "marko", "vadas", "josh");
}
use of com.datastax.dse.driver.api.core.graph.GraphNode in project java-driver by datastax.
the class GraphTraversalITBase method should_handle_asynchronous_execution_graphson.
@Test
public void should_handle_asynchronous_execution_graphson() {
Assumptions.assumeThat(isGraphBinary()).isFalse();
StringBuilder names = new StringBuilder();
CompletionStage<AsyncGraphResultSet> future = session().executeAsync(FluentGraphStatement.newInstance(graphTraversalSource().V().hasLabel("person")));
try {
// dumb processing to make sure the completable future works correctly and correct results are
// returned
Iterable<GraphNode> results = future.thenApply(AsyncGraphResultSet::currentPage).toCompletableFuture().get();
for (GraphNode gn : results) {
names.append(gn.asVertex().property("name").value());
}
} catch (InterruptedException | ExecutionException e) {
fail("Shouldn't have thrown an exception waiting for the result to complete");
}
assertThat(names.toString()).contains("peter", "marko", "vadas", "josh");
}
use of com.datastax.dse.driver.api.core.graph.GraphNode in project java-driver by datastax.
the class GraphTraversalITBase method should_resolve_path_with_some_labels.
/**
* Validates that when traversing a path and labeling some of the elements during the traversal
* that the output elements are properly labeled.
*
* @test_category dse:graph
*/
@Test
public void should_resolve_path_with_some_labels() {
GraphResultSet rs = session().execute(newInstance(graphTraversalSource().V().hasLabel("person").has("name", "marko").as("a").outE("knows").inV().as("c", "d").outE("created").as("e", "f", "g").inV().path()));
List<GraphNode> results = rs.all();
assertThat(results.size()).isEqualTo(2);
for (GraphNode result : results) {
Path path = result.asPath();
validatePathObjects(path);
assertThat(path.labels()).hasSize(5);
assertThat(path).hasLabel(0, "a").hasNoLabel(1).hasLabel(2, "c", "d").hasLabel(3, "e", "f", "g").hasNoLabel(4);
}
}
use of com.datastax.dse.driver.api.core.graph.GraphNode in project java-driver by datastax.
the class GraphTraversalITBase method should_return_correct_results_when_bulked.
/**
* Ensures that traversals with barriers (which return results bulked) contain the correct amount
* of end results.
*
* <p>This will fail if ran against DSE < 5.0.9 or DSE < 5.1.2.
*/
@Test
public void should_return_correct_results_when_bulked() {
Assumptions.assumeThat(ccmRule().getCcmBridge().getDseVersion().get().compareTo(Version.parse("5.1.2")) > 0).isTrue();
GraphResultSet rs = session().execute(newInstance(graphTraversalSource().E().label().barrier()));
List<String> results = rs.all().stream().map(GraphNode::asString).sorted().collect(Collectors.toList());
assertThat(results).hasSize(6).containsSequence("created", "created", "created", "created").containsSequence("knows", "knows");
}
Aggregations