Search in sources :

Example 1 with NodeState

use of com.datastax.oss.driver.api.core.metadata.NodeState in project spring-boot by spring-projects.

the class CassandraDriverReactiveHealthIndicatorTests 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;
}
Also used : NodeState(com.datastax.oss.driver.api.core.metadata.NodeState) Node(com.datastax.oss.driver.api.core.metadata.Node) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) ArrayList(java.util.ArrayList) CqlSession(com.datastax.oss.driver.api.core.CqlSession)

Example 2 with NodeState

use of com.datastax.oss.driver.api.core.metadata.NodeState 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;
}
Also used : NodeState(com.datastax.oss.driver.api.core.metadata.NodeState) Node(com.datastax.oss.driver.api.core.metadata.Node) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) ArrayList(java.util.ArrayList) CqlSession(com.datastax.oss.driver.api.core.CqlSession)

Aggregations

CqlSession (com.datastax.oss.driver.api.core.CqlSession)2 Metadata (com.datastax.oss.driver.api.core.metadata.Metadata)2 Node (com.datastax.oss.driver.api.core.metadata.Node)2 NodeState (com.datastax.oss.driver.api.core.metadata.NodeState)2 ArrayList (java.util.ArrayList)2