@Test @DisplayName("should transmit data to receivers") void transmitData() { final int[] called = new int[1]; called[0] = 0; DataReceiver receiver1 = new DataReceiver() { int[] call = called; @Override public void dataReceived(String data) { call[0]++; } }; DataReceiver receiver2 = new DataReceiver() { int[] call = called; @Override public void dataReceived(String data) { call[0]++; } }; DataReceiver receiver3 = new DataReceiver() { int[] call = called; @Override public void dataReceived(String data) { call[0]++; } }; comInstance.subscribe(Direction.INTERNAL, receiver1); comInstance.subscribe(Direction.INTERNAL, receiver2); comInstance.subscribe(Direction.INTERNAL, receiver3); comInstance.transmitData(value, Direction.INTERNAL); assertEquals(3, called[0]); }
@Override public void transmitData(String data, Direction direction) { for (DataReceiver dataReceiver : this.subscribers.get(direction)) { dataReceiver.dataReceived(data); } }
CommunicationsMediatorImpl implements CommunicationsMediator { @Override public void transmitData(String data, Direction direction) { for (DataReceiver dataReceiver : this.subscribers.get(direction)) { dataReceiver.dataReceived(data); } } }
CommunicationsMediatorImpl implements CommunicationsMediator { @Override public void transmitData(String data, Direction direction) { for (DataReceiver dataReceiver : this.subscribers.get(direction)) { dataReceiver.dataReceived(data); } } CommunicationsMediatorImpl(); }
CommunicationsMediatorImpl implements CommunicationsMediator { @Override public void transmitData(String data, Direction direction) { for (DataReceiver dataReceiver : this.subscribers.get(direction)) { dataReceiver.dataReceived(data); } } CommunicationsMediatorImpl(); @Override void transmitData(String data, Direction direction); @Override void subscribe(Direction direction, DataReceiver receiver); @Override void unsubscribe(Direction direction, DataReceiver receiver); }
CommunicationsMediatorImpl implements CommunicationsMediator { @Override public void transmitData(String data, Direction direction) { for (DataReceiver dataReceiver : this.subscribers.get(direction)) { dataReceiver.dataReceived(data); } } CommunicationsMediatorImpl(); @Override void transmitData(String data, Direction direction); @Override void subscribe(Direction direction, DataReceiver receiver); @Override void unsubscribe(Direction direction, DataReceiver receiver);  }