use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class ExecutionProfileMockUtil method mockNonDefaultGraphOptions.
static DriverExecutionProfile mockNonDefaultGraphOptions() {
DriverExecutionProfile profile = mockDefaultExecutionProfile();
when(profile.getString(GRAPH_TRAVERSAL_SOURCE, null)).thenReturn("non-default-graph");
return profile;
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class ExecutionProfileMockUtil method mockDefaultExecutionProfile.
static DriverExecutionProfile mockDefaultExecutionProfile() {
DriverExecutionProfile profile = mock(DriverExecutionProfile.class);
when(profile.getDuration(REQUEST_TIMEOUT)).thenReturn(Duration.ofMillis(100));
when(profile.getString(LOAD_BALANCING_POLICY_CLASS)).thenReturn("LoadBalancingPolicyImpl");
when(profile.isDefined(LOAD_BALANCING_DISTANCE_EVALUATOR_CLASS)).thenReturn(true);
when(profile.isDefined(LOAD_BALANCING_LOCAL_DATACENTER)).thenReturn(true);
when(profile.getString(LOAD_BALANCING_LOCAL_DATACENTER)).thenReturn(DEFAULT_LOCAL_DC);
when(profile.isDefined(SPECULATIVE_EXECUTION_MAX)).thenReturn(true);
when(profile.getInt(SPECULATIVE_EXECUTION_MAX)).thenReturn(SPECEX_MAX_DEFAULT);
when(profile.isDefined(SPECULATIVE_EXECUTION_DELAY)).thenReturn(true);
when(profile.getInt(SPECULATIVE_EXECUTION_DELAY)).thenReturn(SPECEX_DELAY_DEFAULT);
when(profile.getString(SPECULATIVE_EXECUTION_POLICY_CLASS)).thenReturn("SpeculativeExecutionImpl");
when(profile.getString(REQUEST_CONSISTENCY)).thenReturn("LOCAL_ONE");
when(profile.getString(REQUEST_SERIAL_CONSISTENCY)).thenReturn("SERIAL");
when(profile.getInt(CONNECTION_POOL_LOCAL_SIZE)).thenReturn(2);
when(profile.getInt(CONNECTION_POOL_REMOTE_SIZE)).thenReturn(1);
when(profile.getString(eq(PROTOCOL_COMPRESSION), any())).thenReturn("none");
when(profile.getDuration(HEARTBEAT_INTERVAL)).thenReturn(Duration.ofMillis(100));
when(profile.getDuration(RECONNECTION_BASE_DELAY)).thenReturn(Duration.ofMillis(100));
when(profile.isDefined(SSL_ENGINE_FACTORY_CLASS)).thenReturn(true);
when(profile.getString(eq(AUTH_PROVIDER_CLASS), any())).thenReturn("AuthProviderImpl");
when(profile.getString(GRAPH_TRAVERSAL_SOURCE, null)).thenReturn("src-graph");
return profile;
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class ExecutionProfilesInfoFinderTest method should_include_info_about_default_profile_and_only_difference_for_specific_profile.
@Test
@UseDataProvider("executionProfileProvider")
public void should_include_info_about_default_profile_and_only_difference_for_specific_profile(DriverExecutionProfile nonDefaultExecutionProfile, SpecificExecutionProfile expected) {
// given
DriverExecutionProfile defaultExecutionProfile = mockDefaultExecutionProfile();
Map<String, DriverExecutionProfile> profiles = ImmutableMap.of("default", defaultExecutionProfile, "non-default", nonDefaultExecutionProfile);
InternalDriverContext context = mockDriverContextWithProfiles(defaultExecutionProfile, profiles);
// when
Map<String, SpecificExecutionProfile> executionProfilesInfo = new ExecutionProfilesInfoFinder().getExecutionProfilesInfo(context);
// then
assertThat(executionProfilesInfo).isEqualTo(ImmutableMap.of("default", new SpecificExecutionProfile(100, new LoadBalancingInfo("LoadBalancingPolicyImpl", ImmutableMap.of("localDataCenter", "local-dc", "filterFunction", true), DEFAULT_LOAD_BALANCING_PACKAGE), new SpeculativeExecutionInfo("SpeculativeExecutionImpl", ImmutableMap.of("maxSpeculativeExecutions", 100, "delay", 20), DEFAULT_SPECULATIVE_EXECUTION_PACKAGE), "LOCAL_ONE", "SERIAL", ImmutableMap.of("source", "src-graph")), "non-default", expected));
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile 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.oss.driver.api.core.config.DriverExecutionProfile 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();
}
Aggregations