### Question:
RetryNTimesRetryPolicy implements RetryPolicy { @Override public RetryDecision onReadTimeout(Statement statement, ConsistencyLevel cl, int requiredResponses, int receivedResponses, boolean dataRetrieved, int nbRetry) { return retry(cl, nbRetry); } RetryNTimesRetryPolicy(CassandraConfiguration cassandraConfiguration); @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 onReadTimeoutShouldRetryWhenMaxRetriesNotReached() { int numberOfRetry = MAX_NUMBER_OF_RETRY - 1; control.replay(); RetryNTimesRetryPolicy retryNTimesRetryPolicy = new RetryNTimesRetryPolicy(cassandraConfiguration); RetryDecision retryDecision = retryNTimesRetryPolicy.onReadTimeout(statement, ConsistencyLevel.QUORUM, 1, 1, true, numberOfRetry); control.verify(); assertThat(retryDecision.getType()).isEqualTo(RetryDecision.Type.RETRY); assertThat(retryDecision.getRetryConsistencyLevel()).isEqualTo(ConsistencyLevel.QUORUM); }
@Test public void onReadTimeoutShouldRethrowWhenMaxRetriesReached() { int numberOfRetry = MAX_NUMBER_OF_RETRY; control.replay(); RetryNTimesRetryPolicy retryNTimesRetryPolicy = new RetryNTimesRetryPolicy(cassandraConfiguration); RetryDecision retryDecision = retryNTimesRetryPolicy.onReadTimeout(statement, ConsistencyLevel.QUORUM, 1, 1, true, numberOfRetry); control.verify(); assertThat(retryDecision.getType()).isEqualTo(RetryDecision.Type.RETHROW); }