### Question:
WebsocketProtocolClient implements ProtocolClient { @Override public CompletableFuture<Content> writeResource(Form form, Content content) { log.debug("Write resource '{}' with content '{}'", form, content); return sendMessageWithContent(form, content); } 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 writeResourceShouldSendMessageGivenInFormToSocket() { when(form.getOptional(any())).thenReturn(Map.of( WEBSOCKET_MESSAGE_TYPE, "WriteProperty", 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.writeResource(form, content); verify(websocketClient, timeout(1 * 1000L)).send(any(WriteProperty.class)); }