Search in sources :

Example 6 with GraphStatement

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

the class GraphSupportCheckerTest method should_pickup_graph_protocol_from_statement.

@Test
@UseDataProvider(location = DseTestDataProviders.class, value = "supportedGraphProtocols")
public void should_pickup_graph_protocol_from_statement(GraphProtocol graphProtocol) {
    GraphStatement graphStatement = mock(GraphStatement.class);
    DriverExecutionProfile executionProfile = mock(DriverExecutionProfile.class);
    when(graphStatement.getSubProtocol()).thenReturn(graphProtocol.toInternalCode());
    GraphProtocol inferredProtocol = new GraphSupportChecker().inferGraphProtocol(graphStatement, executionProfile, mock(InternalDriverContext.class));
    assertThat(inferredProtocol).isEqualTo(graphProtocol);
    verifyZeroInteractions(executionProfile);
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) GraphStatement(com.datastax.dse.driver.api.core.graph.GraphStatement) InternalDriverContext(com.datastax.oss.driver.internal.core.context.InternalDriverContext) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 7 with GraphStatement

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

the class GraphTraversalITBase method should_allow_use_of_dsl_graphson.

/**
 * A simple smoke test to ensure that a user can supply a custom {@link GraphTraversalSource} for
 * use with DSLs.
 *
 * @test_category dse:graph
 */
@Test
public void should_allow_use_of_dsl_graphson() throws Exception {
    Assumptions.assumeThat(isGraphBinary()).isFalse();
    SocialTraversalSource gSocial = socialTraversalSource();
    GraphStatement gs = newInstance(gSocial.persons("marko").knows("vadas"));
    GraphResultSet rs = session().execute(gs);
    List<GraphNode> results = rs.all();
    assertThat(results.size()).isEqualTo(1);
    assertThat(results.get(0).asVertex()).hasProperty("name", "marko").hasProperty("age", 29).hasLabel("person");
}
Also used : GraphStatement(com.datastax.dse.driver.api.core.graph.GraphStatement) FluentGraphStatement(com.datastax.dse.driver.api.core.graph.FluentGraphStatement) ScriptGraphStatement(com.datastax.dse.driver.api.core.graph.ScriptGraphStatement) 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) SocialTraversalSource(com.datastax.dse.driver.api.core.graph.SocialTraversalSource) Test(org.junit.Test)

Example 8 with GraphStatement

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

the class GraphSupportCheckerTest method should_support_paging_when_statement_profile_not_present_but_context_profile_has_paging_enabled.

@Test
public void should_support_paging_when_statement_profile_not_present_but_context_profile_has_paging_enabled() {
    // given
    GraphStatement graphStatement = mock(GraphStatement.class);
    InternalDriverContext context = protocolWithPagingSupport(true);
    contextGraphPagingEnabled(context, ENABLED);
    addNodeWithDseVersion(context, Collections.singletonList(Version.parse("6.8.0")));
    // when
    boolean pagingEnabled = new GraphSupportChecker().isPagingEnabled(graphStatement, context);
    // then
    assertThat(pagingEnabled).isEqualTo(true);
}
Also used : GraphStatement(com.datastax.dse.driver.api.core.graph.GraphStatement) InternalDriverContext(com.datastax.oss.driver.internal.core.context.InternalDriverContext) Test(org.junit.Test)

Example 9 with GraphStatement

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

the class GraphSupportCheckerTest method should_check_if_paging_is_supported.

@UseDataProvider("graphPagingEnabledAndDseVersions")
@Test
public void should_check_if_paging_is_supported(boolean protocolWithPagingSupport, PagingEnabledOptions statementGraphPagingEnabled, PagingEnabledOptions contextGraphPagingEnabled, List<Version> nodeDseVersions, boolean expected) {
    // given
    GraphStatement graphStatement = mock(GraphStatement.class);
    InternalDriverContext context = protocolWithPagingSupport(protocolWithPagingSupport);
    statementGraphPagingEnabled(graphStatement, statementGraphPagingEnabled);
    contextGraphPagingEnabled(context, contextGraphPagingEnabled);
    addNodeWithDseVersion(context, nodeDseVersions);
    // when
    boolean pagingEnabled = new GraphSupportChecker().isPagingEnabled(graphStatement, context);
    // then
    assertThat(pagingEnabled).isEqualTo(expected);
}
Also used : GraphStatement(com.datastax.dse.driver.api.core.graph.GraphStatement) InternalDriverContext(com.datastax.oss.driver.internal.core.context.InternalDriverContext) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

GraphStatement (com.datastax.dse.driver.api.core.graph.GraphStatement)9 Test (org.junit.Test)9 InternalDriverContext (com.datastax.oss.driver.internal.core.context.InternalDriverContext)4 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)4 AsyncGraphResultSet (com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet)3 FluentGraphStatement (com.datastax.dse.driver.api.core.graph.FluentGraphStatement)3 GraphResultSet (com.datastax.dse.driver.api.core.graph.GraphResultSet)3 ScriptGraphStatement (com.datastax.dse.driver.api.core.graph.ScriptGraphStatement)3 DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)3 GraphNode (com.datastax.dse.driver.api.core.graph.GraphNode)2 SocialTraversalSource (com.datastax.dse.driver.api.core.graph.SocialTraversalSource)2 DefaultDriverContext (com.datastax.oss.driver.internal.core.context.DefaultDriverContext)2