### Question:
RetryOrCLDowngradeRetryPolicy implements RetryPolicy { @Override public RetryDecision onUnavailable(Statement statement, ConsistencyLevel cl, int requiredReplica, int aliveReplica, int nbRetry) { if (nbRetry >= maxNbRetry) { return RetryDecision.rethrow(); } LOGGER.warn("Opush is downgrading the consistency-level of a Cassandra request as it cannot reach enough replicas to get the QUORUM. " + "A 'nodetool repair' might be done on each node when your cluster gets back to a healthy state. Read http: return DowngradingConsistencyRetryPolicy.INSTANCE.onUnavailable(statement, cl, requiredReplica, aliveReplica, 0); } RetryOrCLDowngradeRetryPolicy(CassandraConfiguration cassandraConfiguration, RetryPolicy readAndWriteRetryPolicy); @Override RetryDecision onReadTimeout(Statement statement, ConsistencyLevel cl, int requiredResponses, int receivedResponses, boolean dataRetrieved, int nbRetry); @Override RetryDecision onWriteTimeout(Statement statement, ConsistencyLevel cl, WriteType writeType, int requiredAcks, int receivedAcks, int nbRetry); @Override RetryDecision onUnavailable(Statement statement, ConsistencyLevel cl, int requiredReplica, int aliveReplica, int nbRetry);  }### Answer:
@Test public void onUnavailableShouldRetryWhenMaxRetriesNotReached() { int numberOfRetry = MAX_NUMBER_OF_RETRY - 1; control.replay(); RetryOrCLDowngradeRetryPolicy retryOrCLDowngradeRetryPolicy = new RetryOrCLDowngradeRetryPolicy(cassandraConfiguration, readAndWriteRetryPolicy); RetryDecision retryDecision = retryOrCLDowngradeRetryPolicy.onUnavailable(statement, ConsistencyLevel.QUORUM, 1, 1, numberOfRetry); control.verify(); assertThat(retryDecision.getType()).isEqualTo(RetryDecision.Type.RETRY); assertThat(retryDecision.getRetryConsistencyLevel()).isEqualTo(ConsistencyLevel.ONE); }
@Test public void onUnavailableShouldRethrowWhenMaxRetriesReached() { int numberOfRetry = MAX_NUMBER_OF_RETRY; control.replay(); RetryOrCLDowngradeRetryPolicy retryOrCLDowngradeRetryPolicy = new RetryOrCLDowngradeRetryPolicy(cassandraConfiguration, readAndWriteRetryPolicy); RetryDecision retryDecision = retryOrCLDowngradeRetryPolicy.onUnavailable(statement, ConsistencyLevel.QUORUM, 1, 1, numberOfRetry); control.verify(); assertThat(retryDecision.getType()).isEqualTo(RetryDecision.Type.RETHROW); }