### Question:
RlpxConnection { public static RlpxConnection outboundConnection( final Peer peer, final CompletableFuture<PeerConnection> future) { return new LocallyInitiatedRlpxConnection(peer, future); } private  RlpxConnection(final CompletableFuture<PeerConnection> future); static RlpxConnection inboundConnection(final PeerConnection peerConnection); static RlpxConnection outboundConnection(
      final Peer peer, final CompletableFuture<PeerConnection> future); abstract Peer getPeer(); abstract void disconnect(DisconnectReason reason); Bytes getId(); abstract PeerConnection getPeerConnection(); CompletableFuture<PeerConnection> getFuture(); abstract boolean isActive(); abstract boolean isPending(); abstract boolean isFailedOrDisconnected(); abstract boolean initiatedRemotely(); void subscribeConnectionEstablished(
      final RlpxConnectCallback successCallback, final RlpxConnectFailedCallback failedCallback); boolean initiatedLocally(); long getInitiatedAt();  }### Answer:
@Test public void getPeerConnection_pendingOutboundConnection() { final Peer peer = createPeer(); final CompletableFuture<PeerConnection> future = new CompletableFuture<>(); final RlpxConnection conn = RlpxConnection.outboundConnection(peer, future); assertThatThrownBy(conn::getPeerConnection) .isInstanceOf(ConnectionNotEstablishedException.class); }
@Test public void getPeerConnection_failedOutboundConnection() { final Peer peer = createPeer(); final CompletableFuture<PeerConnection> future = new CompletableFuture<>(); final RlpxConnection conn = RlpxConnection.outboundConnection(peer, future); future.completeExceptionally(new IllegalStateException("whoops")); assertThatThrownBy(conn::getPeerConnection) .isInstanceOf(ConnectionNotEstablishedException.class); }