### Question:
AbstractStatefulLink extends AbstractLink<L> implements StatefulLink<L> { @Override public void addLinkEventListener(final LinkConnectionEventListener linkConnectionEventListener) { Objects.requireNonNull(linkConnectionEventListener); this.linkConnectionEventEmitter.addLinkConnectionEventListener(linkConnectionEventListener); } protected  AbstractStatefulLink(
      final Supplier<InterledgerAddress> operatorAddressSupplier,
      final L linkSettings,
      final LinkConnectionEventEmitter linkConnectionEventEmitter
  ); @Override final CompletableFuture<Void> connect(); abstract CompletableFuture<Void> doConnect(); @Override void close(); @Override final CompletableFuture<Void> disconnect(); abstract CompletableFuture<Void> doDisconnect(); @Override boolean isConnected(); @Override void addLinkEventListener(final LinkConnectionEventListener linkConnectionEventListener); @Override void removeLinkEventListener(final LinkConnectionEventListener linkConnectionEventListener);  }### Answer:
@Test public void addLinkEventListener() { final LinkConnectionEventListener linkConnectionEventListenerMock = new LinkConnectionEventListener() { @Override @Subscribe public void onConnect(LinkConnectedEvent event) { onConnectCalled.set(true); } @Override @Subscribe public void onDisconnect(LinkDisconnectedEvent event) { onDisconnectCalled.set(true); } }; final EventBus eventBus = new EventBus(); this.link = new TestAbstractStatefulLink( () -> OPERATOR_ADDRESS, LINK_SETTINGS, new EventBusConnectionEventEmitter(eventBus) ); link.setLinkId(LINK_ID); link.addLinkEventListener(linkConnectionEventListenerMock); assertThat(onConnectCalled.get()).isEqualTo(false); assertThat(onDisconnectCalled.get()).isEqualTo(false); link.connect(); assertThat(onConnectCalled.get()).isEqualTo(true); assertThat(onDisconnectCalled.get()).isEqualTo(false); link.sendPacket(mock(InterledgerPreparePacket.class)); assertThat(onConnectCalled.get()).isEqualTo(true); assertThat(onDisconnectCalled.get()).isEqualTo(false); link.disconnect(); assertThat(onConnectCalled.get()).isEqualTo(true); assertThat(onDisconnectCalled.get()).isEqualTo(true); link.sendPacket(mock(InterledgerPreparePacket.class)); assertThat(onConnectCalled.get()).isEqualTo(true); assertThat(onDisconnectCalled.get()).isEqualTo(true); }
@Test public void sendWhenDisconnected() { LinkConnectionEventListener linkConnectionEventListenerMock = mock(LinkConnectionEventListener.class); link.addLinkEventListener(linkConnectionEventListenerMock); link.sendPacket(mock(InterledgerPreparePacket.class)); assertThat(onConnectCalled.get()).isEqualTo(false); assertThat(onDisconnectCalled.get()).isEqualTo(false); }