### Question:
ListenerVertx extends ListenerBase implements Listener { @Override public void close() { if (this.webSocket != null) { this.setUid(null); this.webSocket.close(); this.webSocket = null; } } ListenerVertx(
      HttpClient httpClient,
      String url,
      NamespaceRepository namespaceRepository,
      Observable<NetworkType> networkTypeObservable); @Override CompletableFuture<Void> open(); @Override void close();  }### Answer:
@Test public void shouldOpen() throws ExecutionException, InterruptedException, TimeoutException { Assertions.assertNull(listener.getUid()); Assertions.assertEquals( "Listener has not been opened yet. Please call the open method before subscribing.", Assertions.assertThrows(IllegalStateException.class, () -> listener.newBlock()) .getMessage()); simulateWebSocketStartup(); Assertions.assertNotNull(listener.newBlock()); Assertions.assertEquals(wsId, listener.getUid()); listener.close(); listener.close(); Assertions.assertNull(listener.getUid()); Assertions.assertEquals( "Listener has not been opened yet. Please call the open method before subscribing.", Assertions.assertThrows(IllegalStateException.class, () -> listener.newBlock()) .getMessage()); Map<String, String> sendPayload = new HashMap<>(); sendPayload.put("uid", wsId); sendPayload.put("subscribe", "block"); Mockito.verify(webSocketMock).writeTextMessage(jsonHelper.print(sendPayload)); Mockito.verify(webSocketMock).handler(Mockito.any()); Mockito.verify(webSocketMock).close(); }