use of io.requery.test.model.Phone in project requery by requery.
the class CompletableEntityStoreTest method testInsertOneToMany.
@Test
public void testInsertOneToMany() throws Exception {
final Person person = randomPerson();
data.insert(person).thenApply(new Function<Person, Phone>() {
@Override
public Phone apply(Person person) {
Phone phone1 = randomPhone();
phone1.setOwner(person);
return phone1;
}
}).thenCompose(new Function<Phone, CompletionStage<Phone>>() {
@Override
public CompletionStage<Phone> apply(Phone phone) {
return data.insert(phone);
}
}).toCompletableFuture().get();
HashSet<Phone> set = new HashSet<>(person.getPhoneNumbers().toList());
assertEquals(1, set.size());
}
use of io.requery.test.model.Phone in project requery by requery.
the class FunctionalTest method testDeleteOneToManyResult.
@Test
public void testDeleteOneToManyResult() {
Person person = randomPerson();
data.insert(person);
Phone phone1 = randomPhone();
Phone phone2 = randomPhone();
phone1.setOwner(person);
phone2.setOwner(person);
data.insert(phone1);
data.insert(phone2);
data.refresh(person);
assertEquals(2, person.getPhoneNumbers().toList().size());
data.delete(person.getPhoneNumbers());
Phone cached = data.findByKey(Phone.class, phone1.getId());
assertNull(cached);
}
use of io.requery.test.model.Phone in project requery by requery.
the class FunctionalTest method testInsertOneToManyInverseUpdate.
@Test
public void testInsertOneToManyInverseUpdate() {
Person person = randomPerson();
data.insert(person);
Phone phone1 = randomPhone();
Phone phone2 = randomPhone();
person.getPhoneNumbers().add(phone1);
person.getPhoneNumbers().add(phone2);
data.update(person);
HashSet<Phone> set = new HashSet<>(person.getPhoneNumbers().toList());
assertEquals(2, set.size());
assertTrue(set.containsAll(Arrays.asList(phone1, phone2)));
assertEquals(person, phone1.getOwner());
assertEquals(person, phone2.getOwner());
}
use of io.requery.test.model.Phone in project requery by requery.
the class FunctionalTest method testInsertEmptyObject.
@Test
public void testInsertEmptyObject() {
Phone phone = new Phone();
data.insert(phone);
assertTrue(phone.getId() > 0);
}
use of io.requery.test.model.Phone in project requery by requery.
the class FunctionalTest method testRefreshAll.
@Test
public void testRefreshAll() {
Person person = randomPerson();
data.insert(person);
Phone phone = randomPhone();
person.getPhoneNumbers().add(phone);
data.update(person);
data.refreshAll(person);
assertTrue(person.getPhoneNumbersSet().contains(phone));
}
Aggregations