use of com.datastax.oss.driver.api.core.CqlSession in project spring-boot by spring-projects.
the class CassandraMockConfiguration method cqlSession.
@Bean
CqlSession cqlSession() {
DriverContext context = mock(DriverContext.class);
given(context.getCodecRegistry()).willReturn(this.codecRegistry);
CqlSession cqlSession = mock(CqlSession.class);
given(cqlSession.getContext()).willReturn(context);
return cqlSession;
}
use of com.datastax.oss.driver.api.core.CqlSession in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method healthWithOneForcedDownNodeShouldReturnDown.
@Test
void healthWithOneForcedDownNodeShouldReturnDown() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.FORCED_DOWN);
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
}
use of com.datastax.oss.driver.api.core.CqlSession in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method healthWithOneHealthyNodeAndOneUnknownNodeShouldReturnUp.
@Test
void healthWithOneHealthyNodeAndOneUnknownNodeShouldReturnUp() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.UP, NodeState.UNKNOWN);
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
}
use of com.datastax.oss.driver.api.core.CqlSession in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method mockCqlSessionWithNodeState.
private CqlSession mockCqlSessionWithNodeState(NodeState... nodeStates) {
CqlSession session = mock(CqlSession.class);
Metadata metadata = mock(Metadata.class);
List<Node> nodes = new ArrayList<>();
for (NodeState nodeState : nodeStates) {
Node node = mock(Node.class);
given(node.getState()).willReturn(nodeState);
nodes.add(node);
}
given(session.getMetadata()).willReturn(metadata);
given(metadata.getNodes()).willReturn(createNodesWithRandomUUID(nodes));
return session;
}
use of com.datastax.oss.driver.api.core.CqlSession in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method healthWithOneHealthyNodeShouldReturnUp.
@Test
void healthWithOneHealthyNodeShouldReturnUp() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.UP);
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
}
Aggregations