@Test public void sendResultMessageShouldCallMessageHandler() { WebSocket mockWebSocket = getMockWebSocket(); WampMessageHandler messageHandler = mock(WampMessageHandler.class); String callId = UUID.randomUUID().toString(); WebSocketWrapper wrapper = new WebSocketWrapper(CHARGING_STATION_ID, mockWebSocket, messageHandler, gson); WampMessage wampMessage = new WampMessage(WampMessage.CALL_RESULT, callId, MessageProcUri.START_TRANSACTION, "dummy payload"); wrapper.sendResultMessage(wampMessage); verify(messageHandler).handleWampCallResult(CHARGING_STATION_ID.getId(), wampMessage.toJson(gson), wampMessage.getCallId()); }
public void sendResultMessage(WampMessage wampMessage) { String wampMessageRaw = wampMessage.toJson(gson); try { writeToSocket(wampMessageRaw); if (wampMessageHandler != null) { wampMessageHandler.handleWampCallResult( chargingStationId.getId(), wampMessageRaw, wampMessage.getCallId() ); } } catch (IOException e) { LOG.error("IOException while writing to web socket [{}]: {}.", chargingStationId, wampMessageRaw, e); } }
WebSocketWrapper { public void sendResultMessage(WampMessage wampMessage) { String wampMessageRaw = wampMessage.toJson(gson); try { writeToSocket(wampMessageRaw); if (wampMessageHandler != null) { wampMessageHandler.handleWampCallResult( chargingStationId.getId(), wampMessageRaw, wampMessage.getCallId() ); } } catch (IOException e) { LOG.error("IOException while writing to web socket [{}]: {}.", chargingStationId, wampMessageRaw, e); } } }
WebSocketWrapper { public void sendResultMessage(WampMessage wampMessage) { String wampMessageRaw = wampMessage.toJson(gson); try { writeToSocket(wampMessageRaw); if (wampMessageHandler != null) { wampMessageHandler.handleWampCallResult( chargingStationId.getId(), wampMessageRaw, wampMessage.getCallId() ); } } catch (IOException e) { LOG.error("IOException while writing to web socket [{}]: {}.", chargingStationId, wampMessageRaw, e); } } WebSocketWrapper(ChargingStationId chargingStationId, WebSocket webSocket, WampMessageHandler wampMessageHandler,
                            Gson gson); }
WebSocketWrapper { public void sendResultMessage(WampMessage wampMessage) { String wampMessageRaw = wampMessage.toJson(gson); try { writeToSocket(wampMessageRaw); if (wampMessageHandler != null) { wampMessageHandler.handleWampCallResult( chargingStationId.getId(), wampMessageRaw, wampMessage.getCallId() ); } } catch (IOException e) { LOG.error("IOException while writing to web socket [{}]: {}.", chargingStationId, wampMessageRaw, e); } } WebSocketWrapper(ChargingStationId chargingStationId, WebSocket webSocket, WampMessageHandler wampMessageHandler,
                            Gson gson); WebSocket getWebSocket(); boolean isOpen(); void close(); void sendMessage(WampMessage wampMessage); void sendResultMessage(WampMessage wampMessage); }
WebSocketWrapper { public void sendResultMessage(WampMessage wampMessage) { String wampMessageRaw = wampMessage.toJson(gson); try { writeToSocket(wampMessageRaw); if (wampMessageHandler != null) { wampMessageHandler.handleWampCallResult( chargingStationId.getId(), wampMessageRaw, wampMessage.getCallId() ); } } catch (IOException e) { LOG.error("IOException while writing to web socket [{}]: {}.", chargingStationId, wampMessageRaw, e); } } WebSocketWrapper(ChargingStationId chargingStationId, WebSocket webSocket, WampMessageHandler wampMessageHandler,
                            Gson gson); WebSocket getWebSocket(); boolean isOpen(); void close(); void sendMessage(WampMessage wampMessage); void sendResultMessage(WampMessage wampMessage);  }