use of io.requery.test.autovalue.Person in project requery by requery.
the class AutoValueModelTest method testSelectAll.
@Test
public void testSelectAll() {
List<Integer> added = new ArrayList<>();
for (int i = 0; i < 10; i++) {
added.add(randomPerson());
}
Result<Person> result = data.select(Person.class).get();
for (Person p : result) {
assertTrue(added.contains(p.getId()));
}
}
use of io.requery.test.autovalue.Person in project requery by requery.
the class AutoValueModelTest method testDelete.
@Test
public void testDelete() throws MalformedURLException {
Integer key = randomPerson();
Person p = data.findByKey(Person.class, key);
assertNotNull(p);
data.delete(p);
p = data.findByKey(Person.class, key);
assertNull(p);
}
use of io.requery.test.autovalue.Person in project requery by requery.
the class AutoValueModelTest method testInsert.
@Test
public void testInsert() {
Set<Integer> ids = new HashSet<>();
for (int i = 0; i < 10; i++) {
Person p = Person.builder().setName("person" + i).setAge(30).setEmail("test@example.com").setUUID(UUID.randomUUID()).setBirthday(new Date()).setAbout("About me").build();
Integer key = data.insert(p, Integer.class);
assertTrue(key > 0);
ids.add(key);
}
final Set<Integer> selected = new HashSet<>();
data.select(PersonType.ID).get().each(new Consumer<Tuple>() {
@Override
public void accept(Tuple tuple) {
selected.add(tuple.get(PersonType.ID));
}
});
assertEquals(ids, selected);
}
use of io.requery.test.autovalue.Person in project requery by requery.
the class AutoValueModelTest method testUpdate.
@Test
public void testUpdate() {
Person person = Person.builder().setName("Bob").setAge(30).setEmail("test@example.com").setUUID(UUID.randomUUID()).setBirthday(new Date()).setAbout("About me").build();
Integer key = data.insert(person, Integer.class);
Person renamed = person.toBuilder().setId(key).setName("Bobby").build();
data.update(renamed);
person = data.findByKey(Person.class, key);
assertTrue(person.getName().equals("Bobby"));
}
use of io.requery.test.autovalue.Person in project requery by requery.
the class AutoValueModelTest method testRefresh.
@Test
public void testRefresh() throws MalformedURLException {
Integer key = randomPerson();
Integer count = data.update(Person.class).set(PersonType.NAME, "Unknown").get().value();
assertTrue(count > 0);
Person p = data.findByKey(Person.class, key);
data.refresh(p);
assertEquals(p.getName(), "Unknown");
}