Search in sources :

Example 1 with SimpleCart

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));
}
Also used : MapChangeEventTracker(org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker) SimpleCart(org.eclipse.jface.examples.databinding.model.SimpleCart) SimplePerson(org.eclipse.jface.examples.databinding.model.SimplePerson) Test(org.junit.Test)

Example 2 with SimpleCart

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));
}
Also used : MapChangeEventTracker(org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker) SimpleCart(org.eclipse.jface.examples.databinding.model.SimpleCart) SimplePerson(org.eclipse.jface.examples.databinding.model.SimplePerson) Test(org.junit.Test)

Aggregations

MapChangeEventTracker (org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker)2 SimpleCart (org.eclipse.jface.examples.databinding.model.SimpleCart)2 SimplePerson (org.eclipse.jface.examples.databinding.model.SimplePerson)2 Test (org.junit.Test)2