use of org.eclipse.jface.examples.databinding.model.SimpleCart in project eclipse.platform.ui by eclipse-platform.
the class CompositeMapTest method testChangeInFirstMapFromShared.
@Test
public void testChangeInFirstMapFromShared() {
SimplePerson person0 = new SimplePerson("p0", "a0", "c0", "s0");
person0.getCart().setNumItems(13);
persons.add(person0);
SimplePerson person1 = new SimplePerson("p1", "a1", "c1", "s1");
person1.setCart(person0.getCart());
persons.add(person1);
MapChangeEventTracker<Object, Object> tracker = new MapChangeEventTracker<>();
composedMap.addMapChangeListener(tracker);
assertEquals(0, tracker.count);
person1.setCart(new SimpleCart());
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(13), tracker.event.diff.getOldValue(person1));
assertEquals(Integer.valueOf(0), tracker.event.diff.getNewValue(person1));
assertEquals(Integer.valueOf(0), composedMap.get(person1));
}
use of org.eclipse.jface.examples.databinding.model.SimpleCart in project eclipse.platform.ui by eclipse-platform.
the class CompositeMapTest method testChangeInFirstMap.
@Test
public void testChangeInFirstMap() {
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(new SimpleCart());
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(0), tracker.event.diff.getNewValue(person1));
assertEquals(Integer.valueOf(0), composedMap.get(person1));
}
Aggregations