Search in sources :

Example 1 with ObservableList

use of io.requery.util.ObservableList in project requery by requery.

the class ObservableCollectionTest method observableCollections.

@Parameterized.Parameters
public static <T extends Collection<Phone> & ObservableCollection<Phone>> Collection<T> observableCollections() {
    Person person = new Person();
    // ObservableList
    List<Phone> observableList = person.getPhoneNumbersList();
    assertTrue(observableList instanceof ObservableList);
    // ObservableSet
    Set<Phone> observableSet = person.getPhoneNumbersSet();
    assertTrue(observableSet instanceof ObservableSet);
    return Arrays.asList((T) observableList, (T) observableSet);
}
Also used : ObservableList(io.requery.util.ObservableList) Phone(io.requery.test.model.Phone) Person(io.requery.test.model.Person) ObservableSet(io.requery.util.ObservableSet)

Example 2 with ObservableList

use of io.requery.util.ObservableList in project requery by requery.

the class CollectionChangesTest method setUp.

@Before
public void setUp() {
    // Create some mock objects (Person has a to-many relationship to Phone)
    phone1 = new Phone();
    phone2 = new Phone();
    person = new Person();
    person.getPhoneNumbersList().add(phone1);
    person.getPhoneNumbersList().add(phone2);
    // Make sure that initial status of Observable collection is clear (no elements added or removed)
    assertTrue(person.getPhoneNumbersList() instanceof ObservableList);
    observableList = (ObservableList) person.getPhoneNumbersList();
    assertTrue(observableList.observer() instanceof CollectionChanges);
    collectionChanges = (CollectionChanges) observableList.observer();
    collectionChanges.clear();
    assertTrue(collectionChanges.addedElements().isEmpty());
    assertTrue(collectionChanges.removedElements().isEmpty());
}
Also used : ObservableList(io.requery.util.ObservableList) Phone(io.requery.test.model.Phone) CollectionChanges(io.requery.proxy.CollectionChanges) Person(io.requery.test.model.Person) Before(org.junit.Before)

Aggregations

Person (io.requery.test.model.Person)2 Phone (io.requery.test.model.Phone)2 ObservableList (io.requery.util.ObservableList)2 CollectionChanges (io.requery.proxy.CollectionChanges)1 ObservableSet (io.requery.util.ObservableSet)1 Before (org.junit.Before)1