Search in sources :

Example 21 with GraphBinaryModule

use of com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule in project java-driver by datastax.

the class GraphNodeTest method setup.

@Before
public void setup() {
    DefaultDriverContext dseDriverContext = mock(DefaultDriverContext.class);
    when(dseDriverContext.getCodecRegistry()).thenReturn(CodecRegistry.DEFAULT);
    when(dseDriverContext.getProtocolVersion()).thenReturn(DseProtocolVersion.DSE_V2);
    TypeSerializerRegistry registry = GraphBinaryModule.createDseTypeSerializerRegistry(dseDriverContext);
    graphBinaryModule = new GraphBinaryModule(new GraphBinaryReader(registry), new GraphBinaryWriter(registry));
}
Also used : GraphBinaryWriter(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter) TypeSerializerRegistry(org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry) GraphBinaryReader(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryReader) DefaultDriverContext(com.datastax.oss.driver.internal.core.context.DefaultDriverContext) GraphBinaryModule(com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule) Before(org.junit.Before)

Example 22 with GraphBinaryModule

use of com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule in project java-driver by datastax.

the class GraphRequestHandlerTest method should_create_query_message_from_fluent_statement.

@Test
@UseDataProvider(location = DseTestDataProviders.class, value = "supportedGraphProtocols")
public void should_create_query_message_from_fluent_statement(GraphProtocol graphProtocol) throws IOException {
    // initialization
    GraphRequestHandlerTestHarness harness = GraphRequestHandlerTestHarness.builder().build();
    GraphTraversal<?, ?> traversalTest = DseGraph.g.V().has("person", "name", "marko").has("p1", 1L).has("p2", Uuids.random());
    GraphStatement<?> graphStatement = FluentGraphStatement.newInstance(traversalTest);
    GraphBinaryModule module = createGraphBinaryModule(harness.getContext());
    // when
    DriverExecutionProfile executionProfile = Conversions.resolveExecutionProfile(graphStatement, harness.getContext());
    Message m = GraphConversions.createMessageFromGraphStatement(graphStatement, graphProtocol, executionProfile, harness.getContext(), module);
    Map<String, ByteBuffer> createdCustomPayload = GraphConversions.createCustomPayload(graphStatement, graphProtocol, executionProfile, harness.getContext(), module);
    // checks
    assertThat(m).isInstanceOf(RawBytesQuery.class);
    testQueryRequestAndPayloadContents(((RawBytesQuery) m), createdCustomPayload, GraphConversions.bytecodeToSerialize(graphStatement), graphProtocol, module);
}
Also used : RawBytesQuery(com.datastax.dse.protocol.internal.request.RawBytesQuery) Message(com.datastax.oss.protocol.internal.Message) DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) GraphTestUtils.createGraphBinaryModule(com.datastax.dse.driver.internal.core.graph.GraphTestUtils.createGraphBinaryModule) GraphBinaryModule(com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 23 with GraphBinaryModule

use of com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule in project java-driver by datastax.

the class GraphRequestHandlerTest method should_not_set_graph_name_on_system_queries.

@Test
@UseDataProvider(location = DseTestDataProviders.class, value = "supportedGraphProtocols")
public void should_not_set_graph_name_on_system_queries(GraphProtocol subProtocol) {
    // initialization
    GraphRequestHandlerTestHarness harness = GraphRequestHandlerTestHarness.builder().build();
    GraphStatement<?> graphStatement = ScriptGraphStatement.newInstance("mockQuery").setSystemQuery(true);
    GraphBinaryModule module = createGraphBinaryModule(harness.getContext());
    // when
    DriverExecutionProfile executionProfile = Conversions.resolveExecutionProfile(graphStatement, harness.getContext());
    Map<String, ByteBuffer> requestPayload = GraphConversions.createCustomPayload(graphStatement, subProtocol, executionProfile, harness.getContext(), module);
    // checks
    assertThat(requestPayload.get(GraphConversions.GRAPH_NAME_OPTION_KEY)).isNull();
    assertThat(requestPayload.get(GraphConversions.GRAPH_SOURCE_OPTION_KEY)).isNull();
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) GraphTestUtils.createGraphBinaryModule(com.datastax.dse.driver.internal.core.graph.GraphTestUtils.createGraphBinaryModule) GraphBinaryModule(com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 24 with GraphBinaryModule

use of com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule in project java-driver by datastax.

the class GraphRequestHandlerTest method should_create_query_message_from_script_statement.

@Test
@UseDataProvider(location = DseTestDataProviders.class, value = "supportedGraphProtocols")
public void should_create_query_message_from_script_statement(GraphProtocol graphProtocol) throws IOException {
    // initialization
    GraphRequestHandlerTestHarness harness = GraphRequestHandlerTestHarness.builder().build();
    ScriptGraphStatement graphStatement = ScriptGraphStatement.newInstance("mockQuery").setQueryParam("p1", 1L).setQueryParam("p2", Uuids.random());
    GraphBinaryModule module = createGraphBinaryModule(harness.getContext());
    // when
    DriverExecutionProfile executionProfile = Conversions.resolveExecutionProfile(graphStatement, harness.getContext());
    Message m = GraphConversions.createMessageFromGraphStatement(graphStatement, graphProtocol, executionProfile, harness.getContext(), module);
    // checks
    assertThat(m).isInstanceOf(Query.class);
    Query q = ((Query) m);
    assertThat(q.query).isEqualTo("mockQuery");
    assertThat(q.options.positionalValues).containsExactly(serialize(graphStatement.getQueryParams(), graphProtocol, module));
    assertThat(q.options.namedValues).isEmpty();
}
Also used : Message(com.datastax.oss.protocol.internal.Message) Query(com.datastax.oss.protocol.internal.request.Query) RawBytesQuery(com.datastax.dse.protocol.internal.request.RawBytesQuery) DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) ScriptGraphStatement(com.datastax.dse.driver.api.core.graph.ScriptGraphStatement) GraphTestUtils.createGraphBinaryModule(com.datastax.dse.driver.internal.core.graph.GraphTestUtils.createGraphBinaryModule) GraphBinaryModule(com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

GraphBinaryModule (com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule)24 GraphTestUtils.createGraphBinaryModule (com.datastax.dse.driver.internal.core.graph.GraphTestUtils.createGraphBinaryModule)23 Test (org.junit.Test)23 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)20 PoolBehavior (com.datastax.oss.driver.internal.core.cql.PoolBehavior)14 DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)11 AsyncGraphResultSet (com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet)9 SpeculativeExecutionPolicy (com.datastax.oss.driver.api.core.specex.SpeculativeExecutionPolicy)8 CapturedTimeout (com.datastax.oss.driver.internal.core.util.concurrent.CapturingTimer.CapturedTimeout)8 Node (com.datastax.oss.driver.api.core.metadata.Node)7 DefaultNode (com.datastax.oss.driver.internal.core.metadata.DefaultNode)7 RawBytesQuery (com.datastax.dse.protocol.internal.request.RawBytesQuery)5 Message (com.datastax.oss.protocol.internal.Message)5 ByteBuffer (java.nio.ByteBuffer)5 Error (com.datastax.oss.protocol.internal.response.Error)4 GraphNode (com.datastax.dse.driver.api.core.graph.GraphNode)3 ExecutionInfo (com.datastax.oss.driver.api.core.cql.ExecutionInfo)3 DefaultDriverContext (com.datastax.oss.driver.internal.core.context.DefaultDriverContext)3 RequestHandlerTestHarness (com.datastax.oss.driver.internal.core.cql.RequestHandlerTestHarness)3 Query (com.datastax.oss.protocol.internal.request.Query)3