use of org.eclipse.core.internal.databinding.observable.masterdetail.SetDetailValueObservableMap in project eclipse.platform.ui by eclipse-platform.
the class SetDetailValueObservableMapTest method testContainsValue.
@Test
public void testContainsValue() {
WritableSet masterKeySet = new WritableSet();
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(masterKeySet, BeansObservables.valueFactory("name"), String.class);
// Add a person with a given name.
SimplePerson person = new SimplePerson();
person.setName("name");
masterKeySet.add(person);
// Make sure the name of the person is contained.
assertTrue(sdom.containsValue(person.getName()));
// Remove the person and make sure that it's name cannot be found
// anymore.
masterKeySet.remove(person);
assertFalse(sdom.containsValue(person.getName()));
}
use of org.eclipse.core.internal.databinding.observable.masterdetail.SetDetailValueObservableMap in project eclipse.platform.ui by eclipse-platform.
the class SetDetailValueObservableMapTest method testMasterNull.
@Test
public void testMasterNull() {
WritableSet masterKeySet = new WritableSet();
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(masterKeySet, BeansObservables.valueFactory("name"), String.class);
// Make sure null values are handled gracefully.
masterKeySet.add(null);
assertEquals(1, sdom.size());
assertNull(sdom.get(null));
}
use of org.eclipse.core.internal.databinding.observable.masterdetail.SetDetailValueObservableMap in project eclipse.platform.ui by eclipse-platform.
the class SetDetailValueObservableMapTest method testMasterSetInitiallyNotEmpty.
@Test
public void testMasterSetInitiallyNotEmpty() {
WritableSet masterKeySet = new WritableSet();
SimplePerson person = new SimplePerson();
person.setName("name");
masterKeySet.add(person);
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(masterKeySet, BeansObservables.valueFactory("name"), String.class);
// Make sure that a non-empty master key set is initialized correctly.
assertEquals(masterKeySet.size(), sdom.size());
assertEquals(person.getName(), sdom.get(person));
}
use of org.eclipse.core.internal.databinding.observable.masterdetail.SetDetailValueObservableMap in project eclipse.platform.ui by eclipse-platform.
the class SetDetailValueObservableMapTest method testDisposeOnMasterDisposed.
@Test
public void testDisposeOnMasterDisposed() {
WritableSet masterKeySet = new WritableSet();
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(masterKeySet, BeansObservables.valueFactory("name"), String.class);
// Initially, nothing should be disposed.
assertFalse(masterKeySet.isDisposed());
assertFalse(sdom.isDisposed());
// Upon disposing the master list, the detail list should be disposed as
// well.
masterKeySet.dispose();
assertTrue(masterKeySet.isDisposed());
assertTrue(sdom.isDisposed());
}
use of org.eclipse.core.internal.databinding.observable.masterdetail.SetDetailValueObservableMap in project eclipse.platform.ui by eclipse-platform.
the class SetDetailValueObservableMapTest method testPut.
@Test
public void testPut() {
WritableSet masterKeySet = new WritableSet();
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(masterKeySet, BeansObservables.valueFactory("name"), String.class);
// Change the detail attribute explicitly.
SimplePerson person = new SimplePerson();
person.setName("name1");
masterKeySet.add(person);
assertEquals(person.getName(), sdom.get(person));
// Set a new name on the detail map.
sdom.put(person, "name2");
// Check that the name has been propagated to the master.
assertEquals("name2", person.getName());
assertEquals(person.getName(), sdom.get(person));
}
Aggregations