### Question:
ClientTlsManager implements InboundHandler { public void handshake( final State state, final FrameSender sender, final Consumer<State> stateSetter, final Promise<Void> promise) { this.promise = promise; if (state == State.Started) { sendInitialPacket(sender); stateSetter.accept(State.BeforeHello); } else { throw new IllegalStateException("Can't handshake in state " + state); } } ClientTlsManager(
      final ConnectionId connectionId,
      final TransportParameters transportParameters,
      final CertificateValidator certificateValidator); void resetTlsSession(final ConnectionId connectionId); void handshake(
      final State state,
      final FrameSender sender,
      final Consumer<State> stateSetter,
      final Promise<Void> promise); @Override void onReceivePacket(final Packet packet, final PipelineContext ctx); boolean available(final EncryptionLevel encLevel); AEAD getAEAD(final EncryptionLevel level);  }### Answer:
@Test public void handshake() { final DefaultPromise<Void> handshakeFuture = new DefaultPromise(GlobalEventExecutor.INSTANCE); final PipelineContext ctx = mock(PipelineContext.class); final FrameSender sender = mock(FrameSender.class); final Consumer<State> stateSetter = mock(Consumer.class); manager.handshake(State.Started, sender, stateSetter, handshakeFuture); final ArgumentCaptor<CryptoFrame> chFrame = ArgumentCaptor.forClass(CryptoFrame.class); verify(sender).send(chFrame.capture(), any(PaddingFrame.class)); verify(stateSetter).accept(State.BeforeHello); final byte[] ch = chFrame.getValue().getCryptoData(); final ServerHelloAndHandshake shah = serverTlsSession.handleClientHello(ch); final InitialPacket shPacket = ip(shah.getServerHello()); when(ctx.getState()).thenReturn(State.BeforeHello); manager.onReceivePacket(shPacket, ctx); verify(ctx, never()).send(any(CryptoFrame.class)); verify(ctx).setState(State.BeforeHandshake); verify(ctx).next(shPacket); final HandshakePacket handshakePacket = hp(shah.getServerHandshake()); when(ctx.getState()).thenReturn(State.BeforeHandshake); manager.onReceivePacket(handshakePacket, ctx); verify(ctx).send(any(CryptoFrame.class)); verify(ctx).setState(State.Ready); verify(ctx).next(handshakePacket); }