protected void checkCassandraException(Exception e) { _mexceptions.incr(); if (e instanceof AlreadyExistsException || e instanceof AuthenticationException || e instanceof DriverException || e instanceof DriverInternalError || e instanceof InvalidConfigurationInQueryException || e instanceof InvalidQueryException || e instanceof InvalidTypeException || e instanceof QueryExecutionException || e instanceof QueryTimeoutException || e instanceof QueryValidationException || e instanceof ReadTimeoutException || e instanceof SyntaxError || e instanceof TraceRetrievalException || e instanceof TruncateException || e instanceof UnauthorizedException || e instanceof UnavailableException || e instanceof ReadTimeoutException || e instanceof WriteTimeoutException) { throw new ReportedFailedException(e); } else { throw new RuntimeException(e); } }
@Test public void testShouldReturnUnavailable() throws Exception { server.prime(when(query).then(unavailable(ConsistencyLevel.ALL, 5, 1))); thrown.expect(UnavailableException.class); thrown.expect( match( (UnavailableException uae) -> uae.getAliveReplicas() == 1 && uae.getRequiredReplicas() == 5 && uae.getConsistencyLevel() == com.datastax.driver.core.ConsistencyLevel.ALL)); query(); }