### Question:
DirectUpdateHandler implements UpdateHandler { @Override public void onSubscriptionQueryResponse(SubscriptionQueryResponse response) { logger.debug("SubscriptionQueryResponse for subscription Id {} send to client.", response.getSubscriptionIdentifier()); destination.publish(response); } DirectUpdateHandler(Publisher<SubscriptionQueryResponse> destination); @Override void onSubscriptionQueryResponse(SubscriptionQueryResponse response);  }### Answer:
@Test public void onUpdate() { List<SubscriptionQueryResponse> messages = new LinkedList<>(); DirectUpdateHandler directUpdateHandler = new DirectUpdateHandler(messages::add); QueryUpdate update = QueryUpdate.newBuilder().build(); SubscriptionQueryResponse response = SubscriptionQueryResponse.newBuilder().setUpdate(update).build(); directUpdateHandler.onSubscriptionQueryResponse(response); assertEquals(1, messages.size()); assertEquals(update, messages.get(0).getUpdate()); }
@Test public void onComplete() { List<SubscriptionQueryResponse> messages = new LinkedList<>(); DirectUpdateHandler directUpdateHandler = new DirectUpdateHandler(messages::add); QueryUpdateComplete updateComplete = QueryUpdateComplete.newBuilder().build(); SubscriptionQueryResponse response = SubscriptionQueryResponse.newBuilder().setComplete(updateComplete).build(); directUpdateHandler.onSubscriptionQueryResponse(response); directUpdateHandler.onSubscriptionQueryResponse(response); assertEquals(2, messages.size()); assertEquals(updateComplete, messages.get(0).getComplete()); }
@Test public void onCompleteExceptionally() { List<SubscriptionQueryResponse> messages = new LinkedList<>(); DirectUpdateHandler directUpdateHandler = new DirectUpdateHandler(messages::add); QueryUpdateCompleteExceptionally completeExceptionally = QueryUpdateCompleteExceptionally.newBuilder().build(); SubscriptionQueryResponse response = SubscriptionQueryResponse.newBuilder() .setCompleteExceptionally(completeExceptionally) .build(); directUpdateHandler.onSubscriptionQueryResponse(response); assertEquals(1, messages.size()); assertEquals(completeExceptionally, messages.get(0).getCompleteExceptionally()); }