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));
}
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);
}
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();
}
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();
}
Aggregations