### Question:
WebsocketProtocolClient implements ProtocolClient { @Override public Observable<Content> observeResource(Form form) throws ProtocolClientException { Object message = form.getOptional(WEBSOCKET_MESSAGE); if (message != null) { try { AbstractClientMessage clientMessage = JSON_MAPPER.convertValue(message, AbstractClientMessage.class); WebsocketClient client = getClientFor(form); return observe(client, clientMessage); } catch (IllegalArgumentException e) { throw new ProtocolClientException("Client is unable to parse given message: " + e.getMessage()); } } else { throw new ProtocolClientException("Client does not know what message should be written to the socket. This information must be provided in the Thing Description."); } } WebsocketProtocolClient();   WebsocketProtocolClient(Map<URI, WebsocketClient> clients,
                            Map<String, Consumer<AbstractServerMessage>> openRequests); @Override CompletableFuture<Content> readResource(Form form); @Override CompletableFuture<Content> writeResource(Form form, Content content); @Override CompletableFuture<Content> invokeResource(Form form, Content content); @Override Observable<Content> observeResource(Form form); void destroy();  }### Answer:
@Test public void observeResourceShouldSendMessageGivenInFormToSocket() throws ProtocolClientException { when(form.getOptional(any())).thenReturn(Map.of( WEBSOCKET_MESSAGE_TYPE, "SubscribeProperty", WEBSOCKET_MESSAGE_THING_ID, "counter", WEBSOCKET_MESSAGE_NAME, "count" )); when(form.getHref()).thenReturn("wss: when(clients.get(any())).thenReturn(websocketClient); when(websocketClient.isOpen()).thenReturn(true); WebsocketProtocolClient client = new WebsocketProtocolClient(clients, openRequests); client.observeResource(form).subscribe(); verify(websocketClient, timeout(1 * 1000L)).send(any(SubscribeProperty.class)); }