use of com.datastax.dse.driver.api.core.graph.GraphStatement in project java-driver by datastax.
the class GraphTraversalITBase method should_return_zero_results_graphson_2.
/**
* Ensures a traversal that yields no results is properly retrieved and is empty, using GraphSON2
* and the TinkerPop transform results function.
*
* @test_category dse:graph
*/
@Test
public void should_return_zero_results_graphson_2() {
Assumptions.assumeThat(isGraphBinary()).isFalse();
GraphStatement simpleGraphStatement = ScriptGraphStatement.newInstance("g.V().hasLabel('notALabel')");
GraphResultSet rs = session().execute(simpleGraphStatement);
assertThat(rs.one()).isNull();
}
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_graph_binary.
/**
* 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_graph_binary() throws Exception {
Assumptions.assumeThat(isGraphBinary()).isTrue();
SocialTraversalSource gSocial = socialTraversalSource();
GraphStatement gs = newInstance(gSocial.persons("marko").knows("vadas").elementMap("name", "age"));
GraphResultSet rs = session().execute(gs);
List<GraphNode> results = rs.all();
assertThat(results.size()).isEqualTo(1);
assertThatContainsProperties(results.get(0).asMap(), "name", "marko", "age", 29);
Assertions.assertThat(results.get(0).asMap().values()).contains("person");
}
use of com.datastax.dse.driver.api.core.graph.GraphStatement in project java-driver by datastax.
the class GraphSupportCheckerTest method should_pickup_graph_protocol_and_parse_from_string_config.
@Test
@UseDataProvider("graphProtocolStringsAndDseVersions")
public void should_pickup_graph_protocol_and_parse_from_string_config(String stringConfig, Version dseVersion) {
GraphStatement graphStatement = mock(GraphStatement.class);
DriverExecutionProfile executionProfile = mock(DriverExecutionProfile.class);
when(executionProfile.isDefined(DseDriverOption.GRAPH_SUB_PROTOCOL)).thenReturn(Boolean.TRUE);
when(executionProfile.getString(eq(DseDriverOption.GRAPH_SUB_PROTOCOL))).thenReturn(stringConfig);
DefaultDriverContext context = mockNodesInMetadataWithVersions(mock(DefaultDriverContext.class), true, dseVersion);
GraphProtocol inferredProtocol = new GraphSupportChecker().inferGraphProtocol(graphStatement, executionProfile, context);
assertThat(inferredProtocol.toInternalCode()).isEqualTo(stringConfig);
}
use of com.datastax.dse.driver.api.core.graph.GraphStatement in project java-driver by datastax.
the class GraphSupportCheckerTest method should_not_support_paging_when_statement_profile_not_present.
@Test
public void should_not_support_paging_when_statement_profile_not_present() {
// given
GraphStatement graphStatement = mock(GraphStatement.class);
InternalDriverContext context = protocolWithPagingSupport(true);
contextGraphPagingEnabled(context, DISABLED);
addNodeWithDseVersion(context, Collections.singletonList(Version.parse("6.8.0")));
// when
boolean pagingEnabled = new GraphSupportChecker().isPagingEnabled(graphStatement, context);
// then
assertThat(pagingEnabled).isEqualTo(false);
}
use of com.datastax.dse.driver.api.core.graph.GraphStatement in project java-driver by datastax.
the class GraphSupportCheckerTest method should_use_correct_default_protocol_when_parsing.
@Test
@UseDataProvider("dseVersions6")
public void should_use_correct_default_protocol_when_parsing(Version dseVersion) {
GraphStatement graphStatement = mock(GraphStatement.class);
DriverExecutionProfile executionProfile = mock(DriverExecutionProfile.class);
DefaultDriverContext context = mockNodesInMetadataWithVersions(mock(DefaultDriverContext.class), true, dseVersion);
GraphProtocol inferredProtocol = new GraphSupportChecker().inferGraphProtocol(graphStatement, executionProfile, context);
// For DSE 6.8 and newer, the default should be GraphSON binary
// for DSE older than 6.8, the default should be GraphSON2
assertThat(inferredProtocol).isEqualTo((dseVersion.compareTo(Version.parse("6.8.0")) < 0) ? GraphProtocol.GRAPHSON_2_0 : GraphProtocol.GRAPH_BINARY_1_0);
}
Aggregations