MessagingConnectionService implements ConnectionListener { public void notifyDroneAttributeMessageReceivers(Message message) { try { for (DroneAttributeUpdateReceiver droneAttributeUpdateReceiver : droneAttributeUpdateReceivers) { droneAttributeUpdateReceiver.onDroneAttributeUpdate((DroneDtoMessage) message); } } catch (ClassCastException e) { Log.d("Error", "Could not cast to" + message.getPayloadType(), e); } } @Inject  MessagingConnectionService(); void connect(); void disconnect(); void addConnectionListener(MessagingConnectionListener listener); void removeConnectionListener(MessagingConnectionListener listener); void addMissionMessageReceiver(MessageReceiver listener); void removeMissionMessageReceiver(MessageReceiver listener); void addDroneAttributeUpdateReceiver(DroneAttributeUpdateReceiver droneAttributesUpdateListener); void removeDroneAttributeUpdateReceiver(DroneAttributeUpdateReceiver droneAttributesUpdateListener); void notifyMissionMessageReceivers(Message message); void notifyDroneAttributeMessageReceivers(Message message); void sendMessage(String message); @Override void onChannelRecovery(Connection connection); @Override void onCreate(Connection connection); @Override void onCreateFailure(Throwable failure); @Override void onRecovery(Connection connection); @Override void onRecoveryFailure(Connection connection, Throwable failure); void setServerIP(String serverIP); void setIsLocalConnection(boolean localConnection); void setRabbitMqUser(String rabbitMqUser); void setRabbitMqPassword(String rabbitMqPassword); MissionDto getCurrentMission(); void setCurrentMission(MissionDto currentMission); String getRabbitMqServerAddress(); void setDroneToken(String droneToken); ConnectionState getConnectionState();  }
@Test public void droneAttributeUpdateTest(){ DroneDto droneDto = new DroneDto(); droneDto.setActive(true); droneDto.setPayload(300); droneDto.setName("myTestDrone"); DroneDtoMessage droneDtoMessage = new DroneDtoMessage(); droneDtoMessage.setDroneDto(droneDto); String messageStr = messageConverter.parseMessageToString(droneDtoMessage); JsonBasedMessageConverter jsonBasedMessageConverter = new JsonBasedMessageConverter(); Message message = jsonBasedMessageConverter.parseStringToMessage(messageStr); service.notifyDroneAttributeMessageReceivers(message); verify(droneMessageReceiver).onDroneAttributeUpdate(droneDtoMessage); }