@Test public void testTimeBaseUuidIsCreatedForBatchId() { queryHandler.processBatch(mockBatchStatement, mockQueryState, mockBatchOptions, customPayload); verify(mockAdapter).auditBatch(any(), uuidCaptor.capture(), any(), any(), eq(Status.ATTEMPT), anyLong()); reset(mockAdapter, mockHandler); assertThat(uuidCaptor.getValue().version()).as("UUID version should be time-based").isEqualTo(1); }
@Override public ResultMessage processBatch(BatchStatement statement, QueryState state, BatchQueryOptions options, Map<String, ByteBuffer> customPayload) throws RequestExecutionException, RequestValidationException { UUID uuid = UUIDGen.getTimeUUID(); long timestamp = System.currentTimeMillis(); auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.ATTEMPT, timestamp); try { ResultMessage result = wrappedQueryHandler.processBatch(statement, state, options, customPayload); auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.SUCCEEDED, timestamp); return result; } catch (RuntimeException e) { auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.FAILED, timestamp); throw e; } }
AuditQueryHandler implements QueryHandler { @Override public ResultMessage processBatch(BatchStatement statement, QueryState state, BatchQueryOptions options, Map<String, ByteBuffer> customPayload) throws RequestExecutionException, RequestValidationException { UUID uuid = UUIDGen.getTimeUUID(); long timestamp = System.currentTimeMillis(); auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.ATTEMPT, timestamp); try { ResultMessage result = wrappedQueryHandler.processBatch(statement, state, options, customPayload); auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.SUCCEEDED, timestamp); return result; } catch (RuntimeException e) { auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.FAILED, timestamp); throw e; } } }
AuditQueryHandler implements QueryHandler { @Override public ResultMessage processBatch(BatchStatement statement, QueryState state, BatchQueryOptions options, Map<String, ByteBuffer> customPayload) throws RequestExecutionException, RequestValidationException { UUID uuid = UUIDGen.getTimeUUID(); long timestamp = System.currentTimeMillis(); auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.ATTEMPT, timestamp); try { ResultMessage result = wrappedQueryHandler.processBatch(statement, state, options, customPayload); auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.SUCCEEDED, timestamp); return result; } catch (RuntimeException e) { auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.FAILED, timestamp); throw e; } } AuditQueryHandler();  AuditQueryHandler(QueryHandler queryHandler); @VisibleForTesting  AuditQueryHandler(QueryHandler queryHandler, AuditAdapter auditAdapter); }
AuditQueryHandler implements QueryHandler { @Override public ResultMessage processBatch(BatchStatement statement, QueryState state, BatchQueryOptions options, Map<String, ByteBuffer> customPayload) throws RequestExecutionException, RequestValidationException { UUID uuid = UUIDGen.getTimeUUID(); long timestamp = System.currentTimeMillis(); auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.ATTEMPT, timestamp); try { ResultMessage result = wrappedQueryHandler.processBatch(statement, state, options, customPayload); auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.SUCCEEDED, timestamp); return result; } catch (RuntimeException e) { auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.FAILED, timestamp); throw e; } } AuditQueryHandler();  AuditQueryHandler(QueryHandler queryHandler); @VisibleForTesting  AuditQueryHandler(QueryHandler queryHandler, AuditAdapter auditAdapter); @Override ResultMessage process(String query, QueryState state, QueryOptions options,
                                 Map<String, ByteBuffer> customPayload); @Override ResultMessage processPrepared(CQLStatement statement, QueryState state, QueryOptions options,
                                         Map<String, ByteBuffer> customPayload); @Override ResultMessage processBatch(BatchStatement statement, QueryState state, BatchQueryOptions options,
                                      Map<String, ByteBuffer> customPayload); @Override Prepared prepare(String query, QueryState state, Map<String, ByteBuffer> customPayload); @Override ParsedStatement.Prepared getPrepared(MD5Digest id); @Override ParsedStatement.Prepared getPreparedForThrift(Integer id); }
AuditQueryHandler implements QueryHandler { @Override public ResultMessage processBatch(BatchStatement statement, QueryState state, BatchQueryOptions options, Map<String, ByteBuffer> customPayload) throws RequestExecutionException, RequestValidationException { UUID uuid = UUIDGen.getTimeUUID(); long timestamp = System.currentTimeMillis(); auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.ATTEMPT, timestamp); try { ResultMessage result = wrappedQueryHandler.processBatch(statement, state, options, customPayload); auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.SUCCEEDED, timestamp); return result; } catch (RuntimeException e) { auditAdapter.auditBatch(statement, uuid, state.getClientState(), options, Status.FAILED, timestamp); throw e; } } AuditQueryHandler();  AuditQueryHandler(QueryHandler queryHandler); @VisibleForTesting  AuditQueryHandler(QueryHandler queryHandler, AuditAdapter auditAdapter); @Override ResultMessage process(String query, QueryState state, QueryOptions options,
                                 Map<String, ByteBuffer> customPayload); @Override ResultMessage processPrepared(CQLStatement statement, QueryState state, QueryOptions options,
                                         Map<String, ByteBuffer> customPayload); @Override ResultMessage processBatch(BatchStatement statement, QueryState state, BatchQueryOptions options,
                                      Map<String, ByteBuffer> customPayload); @Override Prepared prepare(String query, QueryState state, Map<String, ByteBuffer> customPayload); @Override ParsedStatement.Prepared getPrepared(MD5Digest id); @Override ParsedStatement.Prepared getPreparedForThrift(Integer id);  }