### Question:
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);  }### Answer:
@Test public void testProcessBatchSuccessful() { queryHandler.processBatch(mockBatchStatement, mockQueryState, mockBatchOptions, customPayload); verify(mockAdapter, times(1)).auditBatch(eq(mockBatchStatement), any(UUID.class), eq(mockClientState), eq(mockBatchOptions), eq(Status.ATTEMPT), longThat(isCloseToNow())); verify(mockAdapter, times(1)).auditBatch(eq(mockBatchStatement), any(UUID.class), eq(mockClientState), eq(mockBatchOptions), eq(Status.SUCCEEDED), longThat(isCloseToNow())); verify(mockHandler, times(1)).processBatch(eq(mockBatchStatement), eq(mockQueryState), eq(mockBatchOptions), eq(customPayload)); }
@Test public void testProcessBatchFailed() { whenProcessBatchThrowUnavailable(); assertThatExceptionOfType(RequestExecutionException.class) .isThrownBy(() -> queryHandler.processBatch(mockBatchStatement, mockQueryState, mockBatchOptions, customPayload)); verify(mockAdapter, times(1)).auditBatch(eq(mockBatchStatement), any(UUID.class), eq(mockClientState), eq(mockBatchOptions), eq(Status.ATTEMPT), longThat(isCloseToNow())); verify(mockHandler, times(1)).processBatch(eq(mockBatchStatement), eq(mockQueryState), eq(mockBatchOptions), eq(customPayload)); verify(mockAdapter, times(1)).auditBatch(eq(mockBatchStatement), any(UUID.class), eq(mockClientState), eq(mockBatchOptions), eq(Status.FAILED), longThat(isCloseToNow())); }
@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); }