### Question:
CDSProcessingClient implements AutoCloseable { public CountDownLatch sendRequest(ExecutionServiceInput input) { return handler.process(input, channel); } CDSProcessingClient(final CDSProcessingListener listener);   CDSProcessingClient(final ManagedChannel channel, final CDSProcessingHandler handler); CountDownLatch sendRequest(ExecutionServiceInput input); @Override void close();  }### Answer:
@Test public void testSendMessageFail() throws Exception { ExecutionServiceInput fakeRequest1 = ExecutionServiceInput.newBuilder() .setActionIdentifiers(ActionIdentifiers.newBuilder().setActionName("request1").build()).build(); CountDownLatch finishLatch = client.sendRequest(fakeRequest1); responseObserverRef.get().onError(new Throwable("fail test")); verify(listener).onError(any(Throwable.class)); assertTrue(finishLatch.await(1, TimeUnit.SECONDS)); }
@Test public void testSendMessage() throws Exception { ExecutionServiceInput fakeRequest1 = ExecutionServiceInput.newBuilder() .setActionIdentifiers(ActionIdentifiers.newBuilder().setActionName("request1").build()).build(); ExecutionServiceOutput fakeResponse1 = ExecutionServiceOutput.newBuilder() .setActionIdentifiers(ActionIdentifiers.newBuilder().setActionName("response1").build()).build(); ExecutionServiceOutput fakeResponse2 = ExecutionServiceOutput.newBuilder() .setActionIdentifiers(ActionIdentifiers.newBuilder().setActionName("response2").build()).build(); CountDownLatch finishLatch = client.sendRequest(fakeRequest1); assertTrue(allRequestsDelivered.await(1, TimeUnit.SECONDS)); assertEquals(Collections.singletonList("request1"), messagesDelivered); responseObserverRef.get().onNext(fakeResponse1); verify(listener).onMessage(fakeResponse1); responseObserverRef.get().onNext(fakeResponse2); verify(listener).onMessage(fakeResponse2); responseObserverRef.get().onCompleted(); assertTrue(finishLatch.await(1, TimeUnit.SECONDS)); }