### Question:
BoundNode extends AbstractNode<BoundCluster, BoundDataCenter> implements BoundTopic<NodeConnectionReport, NodeQueryLogReport> { @Override public StubStore getStubStore() { return stubStore; } BoundNode(
      SocketAddress address,
      NodeSpec delegate,
      Map<String, Object> peerInfo,
      BoundCluster cluster,
      BoundDataCenter parent,
      Server server,
      Timer timer,
      Channel channel,
      boolean activityLogging); @Override Long getActiveConnections(); @Override CompletionStage<Void> acceptConnectionsAsync(); @Override @JsonIgnore NodeQueryLogReport getLogs(); @Override @JsonIgnore NodeQueryLogReport getLogs(boolean primed); @Override void clearLogs(); @Override void registerQueryListener(
      QueryListener queryListener, boolean after, Predicate<QueryLog> filter); @Override CompletionStage<Void> rejectConnectionsAsync(int after, RejectScope scope); @Override StubStore getStubStore(); @Override int clearPrimes(boolean nested); @Override CompletionStage<BoundCluster> unregisterAsync(); int clearPrimes(); @Override NodeConnectionReport getConnections(); @Override CompletionStage<NodeConnectionReport> closeConnectionsAsync(CloseType closeType); @Override NodeConnectionReport pauseRead(); @Override NodeConnectionReport resumeRead(); @Override CompletionStage<NodeConnectionReport> closeConnectionAsync(
      SocketAddress connection, CloseType type); @Override Collection<BoundNode> getNodes(); @Override Server getServer(); @Override @JsonIgnore FrameCodecWrapper getFrameCodec();  }### Answer:
@Test public void shouldRespondWithStubActionsWhenMatched() { String query = "select * from foo where bar = ?"; RowsMetadata rowsMetadata = new RowsMetadata(Collections.emptyList(), null, new int[0], null); Prepared response = new Prepared(new byte[] {1, 7, 9}, null, rowsMetadata, rowsMetadata); node.getStubStore() .register( new StubMapping() { @Override public boolean matches(Frame frame) { Message msg = frame.message; if (msg instanceof Prepare) { Prepare p = (Prepare) msg; return p.cqlQuery.equals(query); } return false; } @Override public List<Action> getActions(AbstractNode node, Frame frame) { return Collections.singletonList(new MessageResponseAction(response)); } }); channel.writeInbound(FrameUtils.wrapRequest(new Prepare(query))); Frame frame = channel.readOutbound(); assertThat(frame.message).isSameAs(response); }
@Test public void shouldRespondWithDelay() throws Exception { String query = "select * from foo where bar = ?"; RowsMetadata rowsMetadata = new RowsMetadata(Collections.emptyList(), null, new int[0], null); Prepared response = new Prepared(new byte[] {1, 7, 9}, null, rowsMetadata, rowsMetadata); node.getStubStore() .register( new StubMapping() { @Override public boolean matches(Frame frame) { Message msg = frame.message; if (msg instanceof Prepare) { Prepare p = (Prepare) msg; return p.cqlQuery.equals(query); } return false; } @Override public List<Action> getActions(AbstractNode node, Frame frame) { List<Action> actions = new ArrayList<>(); actions.add(new MessageResponseAction(response, 500)); actions.add(new MessageResponseAction(Options.INSTANCE)); return actions; } }); channel.writeInbound(FrameUtils.wrapRequest(new Prepare(query))); Frame frame = channel.readOutbound(); assertThat(frame).isNull(); TimeUnit.SECONDS.sleep(1); frame = channel.readOutbound(); assertThat(frame.message).isSameAs(response); frame = channel.readOutbound(); assertThat(frame.message).isSameAs(Options.INSTANCE); }