### Question:
MockDriver implements WaltzClientDriver { public void setFaultRate(double faultRate) { serverPartitions.values().forEach(p -> p.setFaultRate(faultRate)); } MockDriver();  MockDriver(int clientId, Map<Integer, MockServerPartition> serverPartitions); void initialize(WaltzClientCallbacks callbacks, WaltzClientConfig config); @Override ClusterManager getClusterManager(); @Override ManagedClient getManagedClient(); @Override RpcClient getRpcClient(); @Override StreamClient getStreamClient(); @Override void close(); void setMaxDelay(long maxDelayMillis); void setFaultRate(double faultRate); void forceNextAppendFail(); void forceNextLockFail(); void suspendFeed(); void resumeFeed();  }### Answer:
@Test public void testSetFaultRate() throws Exception { final int numTransactions = 200; MockDriver driver = new MockDriver(); DummyCallbacks callbacks = new DummyCallbacks(); callbacks.setClientHighWaterMark(0, -1L); driver.initialize(callbacks, config); driver.setFaultRate(0.5); StreamClient streamClient = driver.getStreamClient(); int numFaults = 0; int numSuccess = 0; for (int i = 0; i < numTransactions; i++) { DummyContext context = new DummyContext(0, "transaction" + i); TransactionBuilderImpl builder = streamClient.getTransactionBuilder(context); context.execute(builder); AppendRequest request = builder.buildRequest(); TransactionFuture future = streamClient.append(request, context); streamClient.flushTransactions(); if (!future.get(1000, TimeUnit.MILLISECONDS)) { numFaults++; } else { callbacks.awaitHighWaterMark(0, (long) numSuccess++, 1000); } } assertTrue(numFaults > 0); }