### Question:
DistanceSensorImpl implements DistanceSensor { synchronized void receivedString(String string, StringBuilder sb) { for (char c : string.toCharArray()) { if (c != 10 && c != 13) { sb.append(c); } else { setCurrentSensorValue(sb.toString()); sb.delete(0, sb.length()); } } } 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);  }### Answer:
@Test @DisplayName("should build string from input") void receivedString() { StringBuilder sb = new StringBuilder(); sensorInstance.receivedString("100", sb); assertEquals("100", sb.toString()); }
@Test @DisplayName("should reset the StringBuilder on new line") void receivedString2() { StringBuilder sb = new StringBuilder(); sensorInstance.receivedString("100\n", sb); assertEquals("", sb.toString()); }