### Question:
AltsHandshakerStub { public void close() { writer.onCompleted(); } AltsHandshakerStub(HandshakerServiceStub serviceStub); @VisibleForTesting  AltsHandshakerStub(); @VisibleForTesting  AltsHandshakerStub(StreamObserver<HandshakerReq> writer); HandshakerResp send(HandshakerReq req); void close();  }### Answer:
@Test public void sendSuccessfulMessageTest() throws Exception { writer.setServiceStatus(Status.OK); sendSuccessfulMessage(); stub.close(); }
@Test public void getServiceErrorTest() throws InterruptedException { writer.setServiceStatus(Status.ERROR); sendAndExpectError(); stub.close(); }
@Test public void getServiceCompleteTest() throws Exception { writer.setServiceStatus(Status.COMPLETE); sendAndExpectComplete(); stub.close(); }
@Test public void getUnexpectedMessageTest() throws Exception { writer.setServiceStatus(Status.OK); writer.sendUnexpectedResponse(); sendAndExpectUnexpectedMessage(); stub.close(); }
@Test public void closeEarlyTest() throws InterruptedException { stub.close(); sendAndExpectComplete(); }