@Test void testRecieveData() { CommunicationsMediator cm = new CommunicationsMediator() { private DataReceiver distanceSensor; @Override public void transmitData(String data, Direction direction) { distanceSensor.dataReceived(data); } @Override public void subscribe(Direction direction, DataReceiver receiver) { distanceSensor = receiver; } @Override public void unsubscribe(Direction direction, DataReceiver receiver) { } }; DistanceSensor ds = new DistanceSensorImpl(cm, ardMock, new LowPassFilter(LP_WEIGHT)); cm.transmitData(CAM_TGT_DIST + ",1.0\n", Direction.INTERNAL); assertEquals(0.7, ds.getDistance(),0.01); }
@Override public double getDistance() { return currentSensorValue; }
DistanceSensorImpl implements DistanceSensor { @Override public double getDistance() { return currentSensorValue; } }
DistanceSensorImpl implements DistanceSensor { @Override public double getDistance() { return currentSensorValue; } DistanceSensorImpl(CommunicationsMediator communicationsMediator,
                       ArduinoCommunicator arduinoCommunicator,
                       Filter filter); }
DistanceSensorImpl implements DistanceSensor { @Override public double getDistance() { return currentSensorValue; } 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 double getDistance() { return currentSensorValue; } 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);  }