@Test @DisplayName("should add DataReceiver as a subscriber") void subscribe() { DataReceiver receiver = new DataReceiver() { @Override public void dataReceived(String data) { assertEquals(value, data); } }; comInstance.subscribe(Direction.INTERNAL, receiver); comInstance.transmitData(value, Direction.INTERNAL); }
@Override public void subscribe(Direction direction, DataReceiver receiver) { List<DataReceiver> dataReceivers = this.subscribers.get(direction); if (!dataReceivers.contains(receiver)) { dataReceivers.add(receiver); } }
CommunicationsMediatorImpl implements CommunicationsMediator { @Override public void subscribe(Direction direction, DataReceiver receiver) { List<DataReceiver> dataReceivers = this.subscribers.get(direction); if (!dataReceivers.contains(receiver)) { dataReceivers.add(receiver); } } }
CommunicationsMediatorImpl implements CommunicationsMediator { @Override public void subscribe(Direction direction, DataReceiver receiver) { List<DataReceiver> dataReceivers = this.subscribers.get(direction); if (!dataReceivers.contains(receiver)) { dataReceivers.add(receiver); } } CommunicationsMediatorImpl(); }
CommunicationsMediatorImpl implements CommunicationsMediator { @Override public void subscribe(Direction direction, DataReceiver receiver) { List<DataReceiver> dataReceivers = this.subscribers.get(direction); if (!dataReceivers.contains(receiver)) { dataReceivers.add(receiver); } } 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 subscribe(Direction direction, DataReceiver receiver) { List<DataReceiver> dataReceivers = this.subscribers.get(direction); if (!dataReceivers.contains(receiver)) { dataReceivers.add(receiver); } } CommunicationsMediatorImpl(); @Override void transmitData(String data, Direction direction); @Override void subscribe(Direction direction, DataReceiver receiver); @Override void unsubscribe(Direction direction, DataReceiver receiver);  }