-
Bug
-
Resolution: Unresolved
-
P4
-
8u40
-
8u40b23
ListChangeEvent.Change is documented to:
" The Change may consist of one or more actual changes and must be iterated by next() method. Each change must be one of the following: [wasPremutated, wasAdded, wasRemoved, wasUpdated]"
This contract is violated when setting an empty list to a property with null/empty list as value.
@Test
public void testListPropertyChangeOnSetEmptyToEmpty() {
ListProperty listProperty = new SimpleListProperty(FXCollections.observableArrayList());
ListChangeReport report = new ListChangeReport(listProperty);
listProperty.set(FXCollections.observableArrayList());
Change c = report.getLastChange();
while(c.next()) {
boolean type = c.wasAdded() || c.wasRemoved() || c.wasPermutated() || c.wasUpdated();
assertTrue("at least one of the change types must be true", type);
}
}
@Test
public void testListPropertyChangeOnSetEmptyToNull() {
ListProperty listProperty = new SimpleListProperty();
ListChangeReport report = new ListChangeReport(listProperty);
listProperty.set(FXCollections.observableArrayList());
Change c = report.getLastChange();
while(c.next()) {
boolean type = c.wasAdded() || c.wasRemoved() || c.wasPermutated() || c.wasUpdated();
assertTrue("at least one of the change types must be true", type);
}
}
" The Change may consist of one or more actual changes and must be iterated by next() method. Each change must be one of the following: [wasPremutated, wasAdded, wasRemoved, wasUpdated]"
This contract is violated when setting an empty list to a property with null/empty list as value.
@Test
public void testListPropertyChangeOnSetEmptyToEmpty() {
ListProperty listProperty = new SimpleListProperty(FXCollections.observableArrayList());
ListChangeReport report = new ListChangeReport(listProperty);
listProperty.set(FXCollections.observableArrayList());
Change c = report.getLastChange();
while(c.next()) {
boolean type = c.wasAdded() || c.wasRemoved() || c.wasPermutated() || c.wasUpdated();
assertTrue("at least one of the change types must be true", type);
}
}
@Test
public void testListPropertyChangeOnSetEmptyToNull() {
ListProperty listProperty = new SimpleListProperty();
ListChangeReport report = new ListChangeReport(listProperty);
listProperty.set(FXCollections.observableArrayList());
Change c = report.getLastChange();
while(c.next()) {
boolean type = c.wasAdded() || c.wasRemoved() || c.wasPermutated() || c.wasUpdated();
assertTrue("at least one of the change types must be true", type);
}
}