@Test @DisplayName("should unsubscribe a consumer") void unsubscribe() { Consumer<Double> consumer = new ConsumerImpl(); Consumer<Double> consumerSpy = spy(consumer); StringBuilder sb = new StringBuilder(); sensorInstance.subscribe(consumerSpy); sensorInstance.receivedString("0.3\n", sb); verify(consumerSpy, times(1)).accept(any()); sensorInstance.unsubscribe(consumerSpy); sensorInstance.receivedString("0.3\n", sb); verify(consumerSpy, times(1)).accept(any()); }
@Override public void unsubscribe(Consumer<Double> dataConsumer) { dataConsumers.remove(dataConsumer); }
DistanceSensorImpl implements DistanceSensor { @Override public void unsubscribe(Consumer<Double> dataConsumer) { dataConsumers.remove(dataConsumer); } }
DistanceSensorImpl implements DistanceSensor { @Override public void unsubscribe(Consumer<Double> dataConsumer) { dataConsumers.remove(dataConsumer); } DistanceSensorImpl(CommunicationsMediator communicationsMediator,
                       ArduinoCommunicator arduinoCommunicator,
                       Filter filter); }
DistanceSensorImpl implements DistanceSensor { @Override public void unsubscribe(Consumer<Double> dataConsumer) { dataConsumers.remove(dataConsumer); } DistanceSensorImpl(CommunicationsMediator communicationsMediator,
                       ArduinoCommunicator arduinoCommunicator,
                       Filter filter); @Override double getDistance(); @Override double getValue(); @Override void subscribe(Consumer<Double> dataConsumer); @Override void unsubscribe(Consumer<Double> dataConsumer); }
DistanceSensorImpl implements DistanceSensor { @Override public void unsubscribe(Consumer<Double> dataConsumer) { dataConsumers.remove(dataConsumer); } DistanceSensorImpl(CommunicationsMediator communicationsMediator,
                       ArduinoCommunicator arduinoCommunicator,
                       Filter filter); @Override double getDistance(); @Override double getValue(); @Override void subscribe(Consumer<Double> dataConsumer); @Override void unsubscribe(Consumer<Double> dataConsumer);  }