Search in sources :

Example 11 with MockedProperty

use of com.canoo.dp.impl.remoting.MockedProperty in project dolphin-platform by canoo.

the class FXBinderTest method testJavaFXDoubleUnidirectional.

@Test
public void testJavaFXDoubleUnidirectional() {
    Property<Double> doubleDolphinProperty = new MockedProperty<>();
    Property<Number> numberDolphinProperty = new MockedProperty<>();
    DoubleProperty doubleJavaFXProperty = new SimpleDoubleProperty();
    WritableDoubleValue writableDoubleValue = new SimpleDoubleProperty();
    doubleDolphinProperty.set(47.0);
    assertNotEquals(doubleJavaFXProperty.doubleValue(), 47.0, EPSILON);
    Binding binding = FXBinder.bind(doubleJavaFXProperty).to(doubleDolphinProperty);
    assertEquals(doubleJavaFXProperty.doubleValue(), 47.0, EPSILON);
    doubleDolphinProperty.set(100.0);
    assertEquals(doubleJavaFXProperty.doubleValue(), 100.0, EPSILON);
    doubleDolphinProperty.set(null);
    assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
    binding.unbind();
    doubleDolphinProperty.set(100.0);
    assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
    numberDolphinProperty.set(12.0);
    binding = FXBinder.bind(doubleJavaFXProperty).to(numberDolphinProperty);
    assertEquals(doubleJavaFXProperty.doubleValue(), 12.0, EPSILON);
    numberDolphinProperty.set(null);
    assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
    binding.unbind();
    numberDolphinProperty.set(100.0);
    assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
    doubleDolphinProperty.set(47.0);
    binding = FXBinder.bind(writableDoubleValue).to(doubleDolphinProperty);
    assertEquals(writableDoubleValue.get(), 47.0, EPSILON);
    doubleDolphinProperty.set(100.0);
    assertEquals(writableDoubleValue.get(), 100.0, EPSILON);
    doubleDolphinProperty.set(null);
    assertEquals(writableDoubleValue.get(), 0.0, EPSILON);
    binding.unbind();
    doubleDolphinProperty.set(100.0);
    assertEquals(writableDoubleValue.get(), 0.0, EPSILON);
}
Also used : Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) DoubleProperty(javafx.beans.property.DoubleProperty) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) WritableDoubleValue(javafx.beans.value.WritableDoubleValue) Test(org.testng.annotations.Test)

Example 12 with MockedProperty

use of com.canoo.dp.impl.remoting.MockedProperty in project dolphin-platform by canoo.

the class FXBinderTest method testJavaFXBooleanBidirectional.

@Test
public void testJavaFXBooleanBidirectional() {
    Property<Boolean> booleanDolphinProperty = new MockedProperty<>();
    BooleanProperty booleanJavaFXProperty = new SimpleBooleanProperty();
    booleanDolphinProperty.set(true);
    assertNotEquals(booleanJavaFXProperty.get(), true);
    Binding binding = FXBinder.bind(booleanJavaFXProperty).bidirectionalTo(booleanDolphinProperty);
    assertEquals(booleanJavaFXProperty.get(), true);
    booleanDolphinProperty.set(false);
    assertEquals(booleanJavaFXProperty.get(), false);
    booleanDolphinProperty.set(null);
    assertEquals(booleanJavaFXProperty.get(), false);
    booleanJavaFXProperty.set(true);
    assertEquals(booleanDolphinProperty.get().booleanValue(), true);
    booleanJavaFXProperty.setValue(null);
    assertEquals(booleanDolphinProperty.get().booleanValue(), false);
    binding.unbind();
    booleanDolphinProperty.set(true);
    assertEquals(booleanJavaFXProperty.get(), false);
}
Also used : Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Test(org.testng.annotations.Test)

Example 13 with MockedProperty

use of com.canoo.dp.impl.remoting.MockedProperty in project dolphin-platform by canoo.

the class FXBinderTest method testJavaFXDoubleBidirectional.

@Test
public void testJavaFXDoubleBidirectional() {
    Property<Double> doubleDolphinProperty = new MockedProperty<>();
    Property<Number> numberDolphinProperty = new MockedProperty<>();
    DoubleProperty doubleJavaFXProperty = new SimpleDoubleProperty();
    doubleDolphinProperty.set(47.0);
    assertNotEquals(doubleJavaFXProperty.doubleValue(), 47.0, EPSILON);
    Binding binding = FXBinder.bind(doubleJavaFXProperty).bidirectionalToNumeric(doubleDolphinProperty);
    assertEquals(doubleJavaFXProperty.doubleValue(), 47.0, EPSILON);
    doubleDolphinProperty.set(100.0);
    assertEquals(doubleJavaFXProperty.doubleValue(), 100.0, EPSILON);
    doubleDolphinProperty.set(null);
    assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
    doubleJavaFXProperty.set(12.0);
    assertEquals(doubleDolphinProperty.get().doubleValue(), 12.0, EPSILON);
    doubleJavaFXProperty.setValue(null);
    assertEquals(doubleDolphinProperty.get().doubleValue(), 0.0, EPSILON);
    binding.unbind();
    doubleDolphinProperty.set(100.0);
    assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
    numberDolphinProperty.set(12.0);
    binding = FXBinder.bind(doubleJavaFXProperty).bidirectionalTo(numberDolphinProperty);
    assertEquals(doubleJavaFXProperty.doubleValue(), 12.0, EPSILON);
    numberDolphinProperty.set(null);
    assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
    doubleJavaFXProperty.set(12.0);
    assertEquals(numberDolphinProperty.get().doubleValue(), 12.0, EPSILON);
    doubleJavaFXProperty.setValue(null);
    assertEquals(numberDolphinProperty.get().doubleValue(), 0.0, EPSILON);
    binding.unbind();
    numberDolphinProperty.set(100.0);
    assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
}
Also used : Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) DoubleProperty(javafx.beans.property.DoubleProperty) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) Test(org.testng.annotations.Test)

Example 14 with MockedProperty

use of com.canoo.dp.impl.remoting.MockedProperty in project dolphin-platform by canoo.

the class FXBinderTest method testJavaFXDoubleUnidirectionalWithConverter.

@Test
public void testJavaFXDoubleUnidirectionalWithConverter() {
    Property<String> stringDolphinProperty = new MockedProperty<>();
    DoubleProperty doubleJavaFXProperty = new SimpleDoubleProperty();
    WritableDoubleValue writableDoubleValue = new SimpleDoubleProperty();
    Converter<String, Double> stringDoubleConverter = s -> s == null ? null : Double.parseDouble(s);
    stringDolphinProperty.set("47.0");
    assertNotEquals(doubleJavaFXProperty.doubleValue(), 47.0, EPSILON);
    Binding binding = FXBinder.bind(doubleJavaFXProperty).to(stringDolphinProperty, stringDoubleConverter);
    assertEquals(doubleJavaFXProperty.doubleValue(), 47.0, EPSILON);
    stringDolphinProperty.set("100.0");
    assertEquals(doubleJavaFXProperty.doubleValue(), 100.0, EPSILON);
    stringDolphinProperty.set(null);
    assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
    binding.unbind();
    stringDolphinProperty.set("100.0");
    assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
    stringDolphinProperty.set("12.0");
    binding = FXBinder.bind(doubleJavaFXProperty).to(stringDolphinProperty, stringDoubleConverter);
    assertEquals(doubleJavaFXProperty.doubleValue(), 12.0, EPSILON);
    stringDolphinProperty.set(null);
    assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
    binding.unbind();
    stringDolphinProperty.set("100.0");
    assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
    stringDolphinProperty.set("47.0");
    binding = FXBinder.bind(writableDoubleValue).to(stringDolphinProperty, stringDoubleConverter);
    assertEquals(writableDoubleValue.get(), 47.0, EPSILON);
    stringDolphinProperty.set("100.0");
    assertEquals(writableDoubleValue.get(), 100.0, EPSILON);
    stringDolphinProperty.set(null);
    assertEquals(writableDoubleValue.get(), 0.0, EPSILON);
    binding.unbind();
    stringDolphinProperty.set("100.0");
    assertEquals(writableDoubleValue.get(), 0.0, EPSILON);
}
Also used : Binding(com.canoo.platform.core.functional.Binding) Arrays(java.util.Arrays) WritableBooleanValue(javafx.beans.value.WritableBooleanValue) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) FXCollections(javafx.collections.FXCollections) Assert.assertEquals(org.testng.Assert.assertEquals) DoubleProperty(javafx.beans.property.DoubleProperty) Test(org.testng.annotations.Test) FXBinder(com.canoo.platform.remoting.client.javafx.FXBinder) DefaultBidirectionalConverter(com.canoo.dp.impl.client.javafx.DefaultBidirectionalConverter) Property(com.canoo.platform.remoting.Property) IntegerProperty(javafx.beans.property.IntegerProperty) ArrayList(java.util.ArrayList) WritableStringValue(javafx.beans.value.WritableStringValue) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) ObservableArrayList(com.canoo.dp.impl.remoting.collections.ObservableArrayList) Assert.assertNotEquals(org.testng.Assert.assertNotEquals) ObservableList(com.canoo.platform.remoting.ObservableList) Converter(com.canoo.platform.remoting.client.javafx.Converter) BidirectionalConverter(com.canoo.platform.remoting.client.javafx.BidirectionalConverter) BooleanProperty(javafx.beans.property.BooleanProperty) List(java.util.List) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) WritableIntegerValue(javafx.beans.value.WritableIntegerValue) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) Assert.assertTrue(org.testng.Assert.assertTrue) StringProperty(javafx.beans.property.StringProperty) WritableDoubleValue(javafx.beans.value.WritableDoubleValue) Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) DoubleProperty(javafx.beans.property.DoubleProperty) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) WritableDoubleValue(javafx.beans.value.WritableDoubleValue) Test(org.testng.annotations.Test)

Example 15 with MockedProperty

use of com.canoo.dp.impl.remoting.MockedProperty in project dolphin-platform by canoo.

the class FXBinderTest method testJavaFXBooleanUnidirectional.

@Test
public void testJavaFXBooleanUnidirectional() {
    Property<Boolean> booleanDolphinProperty = new MockedProperty<>();
    BooleanProperty booleanJavaFXProperty = new SimpleBooleanProperty();
    WritableBooleanValue writableBooleanValue = new SimpleBooleanProperty();
    booleanDolphinProperty.set(true);
    assertNotEquals(booleanJavaFXProperty.get(), true);
    Binding binding = FXBinder.bind(booleanJavaFXProperty).to(booleanDolphinProperty);
    assertEquals(booleanJavaFXProperty.get(), true);
    booleanDolphinProperty.set(false);
    assertEquals(booleanJavaFXProperty.get(), false);
    booleanDolphinProperty.set(null);
    assertEquals(booleanJavaFXProperty.get(), false);
    binding.unbind();
    booleanDolphinProperty.set(true);
    assertEquals(booleanJavaFXProperty.get(), false);
    binding = FXBinder.bind(writableBooleanValue).to(booleanDolphinProperty);
    assertEquals(writableBooleanValue.get(), true);
    booleanDolphinProperty.set(false);
    assertEquals(writableBooleanValue.get(), false);
    booleanDolphinProperty.set(null);
    assertEquals(writableBooleanValue.get(), false);
    binding.unbind();
    booleanDolphinProperty.set(true);
    assertEquals(writableBooleanValue.get(), false);
}
Also used : Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) WritableBooleanValue(javafx.beans.value.WritableBooleanValue) Test(org.testng.annotations.Test)

Aggregations

MockedProperty (com.canoo.dp.impl.remoting.MockedProperty)15 Binding (com.canoo.platform.core.functional.Binding)15 Test (org.testng.annotations.Test)15 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)9 StringProperty (javafx.beans.property.StringProperty)9 BooleanProperty (javafx.beans.property.BooleanProperty)7 DoubleProperty (javafx.beans.property.DoubleProperty)7 IntegerProperty (javafx.beans.property.IntegerProperty)7 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)7 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)7 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)7 WritableBooleanValue (javafx.beans.value.WritableBooleanValue)6 WritableDoubleValue (javafx.beans.value.WritableDoubleValue)6 WritableIntegerValue (javafx.beans.value.WritableIntegerValue)6 WritableStringValue (javafx.beans.value.WritableStringValue)6 DefaultBidirectionalConverter (com.canoo.dp.impl.client.javafx.DefaultBidirectionalConverter)5 ObservableArrayList (com.canoo.dp.impl.remoting.collections.ObservableArrayList)5 ObservableList (com.canoo.platform.remoting.ObservableList)5 Property (com.canoo.platform.remoting.Property)5 BidirectionalConverter (com.canoo.platform.remoting.client.javafx.BidirectionalConverter)5