* exception. The catch is the first value produced at the very moment of
* establishing subscription, so order of initialization matters.
*/
@Test
public void property_values_stream_with_faulty_first_value_test() {
SimpleIntegerProperty intProperty = new SimpleIntegerProperty(-1);
List<String> emitted = new LinkedList<>();
List<Throwable> errors = new LinkedList<>();
EventStreams.valuesOf(intProperty)
.map(i -> {
if (i.intValue() < 0) {
throw new IllegalArgumentException("Accepting only positive numbers");
}
return String.valueOf(i);
})
.handleErrors(errors::add)
.subscribe(emitted::add);
intProperty.set(10);
intProperty.set(-2);
intProperty.set(0);
assertEquals(Arrays.asList("10", "0"), emitted);
assertEquals(2, errors.size());
}