use of io.requery.test.model.Phone in project requery by requery.
the class RxTest method testQuerySelfObservableRelational.
@Test
public void testQuerySelfObservableRelational() throws Exception {
final AtomicInteger count = new AtomicInteger();
Subscription subscription = data.select(Person.class).get().toSelfObservable().subscribe(new Action1<Result<Person>>() {
@Override
public void call(Result<Person> persons) {
count.incrementAndGet();
}
});
Person person = randomPerson();
data.insert(person).toBlocking().value();
Phone phone = randomPhone();
person.getPhoneNumbers().add(phone);
data.update(person).toBlocking().value();
data.delete(phone).toBlocking().value();
assertEquals(4, count.get());
subscription.unsubscribe();
}
use of io.requery.test.model.Phone in project requery by requery.
the class RxTest method testQueryObservableFromEntity.
@Test
public void testQueryObservableFromEntity() throws Exception {
final Person person = randomPerson();
data.insert(person).map(new Func1<Person, Phone>() {
@Override
public Phone call(Person person) {
Phone phone1 = randomPhone();
phone1.setOwner(person);
return phone1;
}
}).flatMap(new Func1<Phone, Single<?>>() {
@Override
public Single<?> call(Phone phone) {
return data.insert(phone);
}
}).toBlocking().value();
int count = person.getPhoneNumbers().toList().size();
assertEquals(1, count);
}
use of io.requery.test.model.Phone in project requery by requery.
the class ReactiveTest method testQuerySelfObservableRelational.
@Test
public void testQuerySelfObservableRelational() throws Exception {
final AtomicInteger count = new AtomicInteger();
Disposable disposable = data.select(Person.class).get().observableResult().subscribe(new Consumer<Result<Person>>() {
@Override
public void accept(Result<Person> persons) {
count.incrementAndGet();
}
});
Person person = randomPerson();
data.insert(person).blockingGet();
Phone phone = randomPhone();
person.getPhoneNumbers().add(phone);
data.update(person).blockingGet();
data.delete(phone).blockingGet();
assertEquals(4, count.get());
disposable.dispose();
}
use of io.requery.test.model.Phone in project requery by requery.
the class ReactiveTest method testQueryObservableFromEntity.
@Test
public void testQueryObservableFromEntity() throws Exception {
final Person person = randomPerson();
data.insert(person).map(new Function<Person, Phone>() {
@Override
public Phone apply(Person person) {
Phone phone1 = randomPhone();
phone1.setOwner(person);
return phone1;
}
}).flatMap(new Function<Phone, Single<?>>() {
@Override
public Single<?> apply(Phone phone) {
return data.insert(phone);
}
}).blockingGet();
int count = person.getPhoneNumbers().toList().size();
assertEquals(1, count);
}
use of io.requery.test.model.Phone in project requery by requery.
the class ReactorTest method testInsertOneToMany.
@Test
public void testInsertOneToMany() throws Exception {
final Person person = randomPerson();
data.insert(person).map(new Function<Person, Phone>() {
@Override
public Phone apply(Person person) {
Phone phone1 = randomPhone();
phone1.setOwner(person);
return phone1;
}
}).flatMap(new Function<Phone, Mono<?>>() {
@Override
public Mono<?> apply(Phone phone) {
return data.insert(phone);
}
}).blockFirst();
assertTrue(person.getPhoneNumbers().toList().size() == 1);
}
Aggregations