Search in sources :

Example 6 with ScriptGraphStatement

use of com.datastax.dse.driver.api.core.graph.ScriptGraphStatement 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

ScriptGraphStatement (com.datastax.dse.driver.api.core.graph.ScriptGraphStatement)6 RawBytesQuery (com.datastax.dse.protocol.internal.request.RawBytesQuery)4 Query (com.datastax.oss.protocol.internal.request.Query)4 DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)3 IOException (java.io.IOException)3 UncheckedIOException (java.io.UncheckedIOException)3 ByteBuffer (java.nio.ByteBuffer)3 Buffer (org.apache.tinkerpop.gremlin.structure.io.Buffer)3 Test (org.junit.Test)3 GraphTestUtils.createGraphBinaryModule (com.datastax.dse.driver.internal.core.graph.GraphTestUtils.createGraphBinaryModule)2 GraphBinaryModule (com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule)2 DseQueryOptions (com.datastax.dse.protocol.internal.request.query.DseQueryOptions)2 ConsistencyLevel (com.datastax.oss.driver.api.core.ConsistencyLevel)2 DefaultConsistencyLevel (com.datastax.oss.driver.api.core.DefaultConsistencyLevel)2 Message (com.datastax.oss.protocol.internal.Message)2 ContinuousPagingOptions (com.datastax.dse.protocol.internal.request.query.ContinuousPagingOptions)1 ProtocolVersion (com.datastax.oss.driver.api.core.ProtocolVersion)1 ExecutionInfo (com.datastax.oss.driver.api.core.cql.ExecutionInfo)1 NullAllowingImmutableMap (com.datastax.oss.protocol.internal.util.collection.NullAllowingImmutableMap)1 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)1