Package org.reactfx.inhibeans.property

Examples of org.reactfx.inhibeans.property.SimpleIntegerProperty


     * 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());
    }
View Full Code Here


     * {@link EventStream#watch(java.util.function.Consumer, java.util.function.Consumer)}
     * method.
     */
    @Test
    public void property_values_stream_with_faulty_first_value_test2() {
        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);
                })
                .subscribe(emitted::add, errors::add);

        intProperty.set(10);
        intProperty.set(-2);
        intProperty.set(0);

        assertEquals(Arrays.asList("10", "0"), emitted);
        assertEquals(2, errors.size());
    }
View Full Code Here

TOP

Related Classes of org.reactfx.inhibeans.property.SimpleIntegerProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.