use of io.requery.test.model.Address in project requery by requery.
the class EntityCacheTest method testSerializeGetPut.
@Test
public void testSerializeGetPut() {
CachingProvider provider = Caching.getCachingProvider();
CacheManager cacheManager = provider.getCacheManager();
EntityCache cache = new EntityCacheBuilder(Models.DEFAULT).useReferenceCache(false).useSerializableCache(true).useCacheManager(cacheManager).build();
Person p = new Person();
p.setName("Alice");
p.setUUID(UUID.randomUUID());
p.setAddress(new Address());
p.getAddress().setType(AddressType.HOME);
int id = 100;
cache.put(Person.class, id, p);
Person d = cache.get(Person.class, id);
Assert.assertNotNull(d);
Assert.assertNotSame(p, d);
Assert.assertEquals(p.getName(), d.getName());
Assert.assertEquals(p.getUUID(), d.getUUID());
}
use of io.requery.test.model.Address in project requery by requery.
the class FunctionalTest method testQueryJoinOrderBy.
@Test
public void testQueryJoinOrderBy() {
Person person = randomPerson();
person.setAddress(randomAddress());
data.insert(person);
// not a useful query just tests the sql output
Result<Address> result = data.select(Address.class).join(Person.class).on(Person.ADDRESS_ID.eq(Person.ID)).where(Person.ID.eq(person.getId())).orderBy(Address.CITY.desc()).get();
List<Address> addresses = result.toList();
assertTrue(addresses.size() > 0);
}
use of io.requery.test.model.Address in project requery by requery.
the class FunctionalTest method testFindByKeyDelete.
@Test
public void testFindByKeyDelete() {
Person person = randomPerson();
Address address = randomAddress();
person.setAddress(address);
data.insert(person);
assertTrue(address.getId() > 0);
Person other = data.findByKey(Person.class, person.getId());
assertSame(person, other);
data.delete(other);
other = data.findByKey(Person.class, person.getId());
assertNull(other);
Address cached = data.findByKey(Address.class, address.getId());
assertNull(cached);
}
use of io.requery.test.model.Address in project requery by requery.
the class FunctionalTest method testUpdateOneToOneCascade.
@Test
public void testUpdateOneToOneCascade() {
Address address = randomAddress();
Person person = randomPerson();
data.insert(person);
person.setAddress(address);
data.update(person);
assertSame(address.getPerson(), person);
}
use of io.requery.test.model.Address in project requery by requery.
the class FunctionalTest method testFindByKeyDeleteInverse.
@Test
public void testFindByKeyDeleteInverse() {
Person person = randomPerson();
Address address = randomAddress();
person.setAddress(address);
data.insert(person);
data.delete(address);
person = data.findByKey(Person.class, person.getId());
assertNull(person);
Address cached = data.findByKey(Address.class, address.getId());
assertNull(cached);
}
Aggregations