Search in sources :

Example 21 with GraphResultSet

use of com.datastax.dse.driver.api.core.graph.GraphResultSet 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");
}
Also used : AsyncGraphResultSet(com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet) GraphResultSet(com.datastax.dse.driver.api.core.graph.GraphResultSet) GraphNode(com.datastax.dse.driver.api.core.graph.GraphNode) Test(org.junit.Test)

Example 22 with GraphResultSet

use of com.datastax.dse.driver.api.core.graph.GraphResultSet in project java-driver by datastax.

the class GraphResultSetsTest method should_create_result_set_from_multiple_pages.

@Test
public void should_create_result_set_from_multiple_pages() {
    // Given
    AsyncGraphResultSet page1 = mockPage(true, 0, 1, 2);
    AsyncGraphResultSet page2 = mockPage(true, 3, 4, 5);
    AsyncGraphResultSet page3 = mockPage(false, 6, 7, 8);
    complete(page1.fetchNextPage(), page2);
    complete(page2.fetchNextPage(), page3);
    // When
    GraphResultSet resultSet = GraphResultSets.toSync(page1);
    // Then
    assertThat(resultSet.iterator().hasNext()).isTrue();
    assertThat(resultSet.getRequestExecutionInfo()).isSameAs(page1.getRequestExecutionInfo());
    assertThat(((MultiPageGraphResultSet) resultSet).getRequestExecutionInfos()).containsExactly(page1.getRequestExecutionInfo());
    Iterator<GraphNode> iterator = resultSet.iterator();
    assertNextRow(iterator, 0);
    assertNextRow(iterator, 1);
    assertNextRow(iterator, 2);
    assertThat(iterator.hasNext()).isTrue();
    // This should have triggered the fetch of page2
    assertThat(resultSet.getRequestExecutionInfo()).isEqualTo(page2.getRequestExecutionInfo());
    assertThat(((MultiPageGraphResultSet) resultSet).getRequestExecutionInfos()).containsExactly(page1.getRequestExecutionInfo(), page2.getRequestExecutionInfo());
    assertNextRow(iterator, 3);
    assertNextRow(iterator, 4);
    assertNextRow(iterator, 5);
    assertThat(iterator.hasNext()).isTrue();
    // This should have triggered the fetch of page3
    assertThat(resultSet.getRequestExecutionInfo()).isEqualTo(page3.getRequestExecutionInfo());
    assertThat(((MultiPageGraphResultSet) resultSet).getRequestExecutionInfos()).containsExactly(page1.getRequestExecutionInfo(), page2.getRequestExecutionInfo(), page3.getRequestExecutionInfo());
    assertNextRow(iterator, 6);
    assertNextRow(iterator, 7);
    assertNextRow(iterator, 8);
}
Also used : AsyncGraphResultSet(com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet) AsyncGraphResultSet(com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet) GraphResultSet(com.datastax.dse.driver.api.core.graph.GraphResultSet) GraphNode(com.datastax.dse.driver.api.core.graph.GraphNode) Test(org.junit.Test)

Aggregations

GraphResultSet (com.datastax.dse.driver.api.core.graph.GraphResultSet)22 Test (org.junit.Test)22 AsyncGraphResultSet (com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet)18 GraphNode (com.datastax.dse.driver.api.core.graph.GraphNode)17 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)8 FluentGraphStatement (com.datastax.dse.driver.api.core.graph.FluentGraphStatement)4 GraphStatement (com.datastax.dse.driver.api.core.graph.GraphStatement)4 ScriptGraphStatement (com.datastax.dse.driver.api.core.graph.ScriptGraphStatement)4 Path (org.apache.tinkerpop.gremlin.process.traversal.Path)4 SocialTraversalSource (com.datastax.dse.driver.api.core.graph.SocialTraversalSource)3 GraphTestUtils.createGraphBinaryModule (com.datastax.dse.driver.internal.core.graph.GraphTestUtils.createGraphBinaryModule)2 GraphBinaryModule (com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule)2 InvalidQueryException (com.datastax.oss.driver.api.core.servererrors.InvalidQueryException)2 PoolBehavior (com.datastax.oss.driver.internal.core.cql.PoolBehavior)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 Map (java.util.Map)2 Edge (org.apache.tinkerpop.gremlin.structure.Edge)2 Graph (org.apache.tinkerpop.gremlin.structure.Graph)2 FluentGraphStatement.newInstance (com.datastax.dse.driver.api.core.graph.FluentGraphStatement.newInstance)1 TinkerGraphAssertions.assertThat (com.datastax.dse.driver.api.core.graph.TinkerGraphAssertions.assertThat)1