use of org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class CompositeMapTest method testAddToFirstMap.
@Test
public void testAddToFirstMap() {
MapChangeEventTracker<Object, Object> tracker = new MapChangeEventTracker<>();
composedMap.addMapChangeListener(tracker);
assertEquals(0, tracker.count);
SimplePerson newPerson = new SimplePerson("p1", "a1", "c1", "s1");
newPerson.getCart().setNumItems(42);
persons.add(newPerson);
assertEquals(1, tracker.count);
assertEquals(0, tracker.event.diff.getRemovedKeys().size());
assertEquals(0, tracker.event.diff.getChangedKeys().size());
assertEquals(Collections.singleton(newPerson), tracker.event.diff.getAddedKeys());
assertEquals(Integer.valueOf(42), tracker.event.diff.getNewValue(newPerson));
assertEquals(Integer.valueOf(42), composedMap.get(newPerson));
}
use of org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class CompositeMapTest method testAddSharedToFirstMap.
@Test
public void testAddSharedToFirstMap() {
SimplePerson person1 = new SimplePerson("p1", "a1", "c1", "s1");
person1.getCart().setNumItems(42);
persons.add(person1);
MapChangeEventTracker<Object, Object> tracker = new MapChangeEventTracker<>();
composedMap.addMapChangeListener(tracker);
assertEquals(0, tracker.count);
SimplePerson person2 = new SimplePerson("p1", "a1", "c1", "s1");
person2.setCart(person1.getCart());
persons.add(person2);
assertEquals(1, tracker.count);
assertEquals(0, tracker.event.diff.getRemovedKeys().size());
assertEquals(0, tracker.event.diff.getChangedKeys().size());
assertEquals(Collections.singleton(person2), tracker.event.diff.getAddedKeys());
assertEquals(Integer.valueOf(42), tracker.event.diff.getNewValue(person2));
assertEquals(Integer.valueOf(42), composedMap.get(person2));
assertEquals(Integer.valueOf(42), composedMap.get(person1));
}
use of org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class CompositeMapTest method testChangeInFirstMapToShared.
@Test
public void testChangeInFirstMapToShared() {
SimplePerson person0 = new SimplePerson("p0", "a0", "c0", "s0");
person0.getCart().setNumItems(13);
persons.add(person0);
SimplePerson person1 = new SimplePerson("p1", "a1", "c1", "s1");
person1.getCart().setNumItems(42);
persons.add(person1);
MapChangeEventTracker<Object, Object> tracker = new MapChangeEventTracker<>();
composedMap.addMapChangeListener(tracker);
assertEquals(0, tracker.count);
person1.setCart(person0.getCart());
assertEquals(1, tracker.count);
assertEquals(0, tracker.event.diff.getAddedKeys().size());
assertEquals(0, tracker.event.diff.getRemovedKeys().size());
assertEquals(Collections.singleton(person1), tracker.event.diff.getChangedKeys());
assertEquals(Integer.valueOf(42), tracker.event.diff.getOldValue(person1));
assertEquals(Integer.valueOf(13), tracker.event.diff.getNewValue(person1));
assertEquals(Integer.valueOf(13), composedMap.get(person1));
}
Aggregations