Search in sources :

Example 1 with Address

use of io.requery.test.model.Address in project requery by requery.

the class FunctionalTest method testGetNullAssociationInverse.

@Test
public void testGetNullAssociationInverse() {
    Address address = randomAddress();
    data.insert(address);
    assertNull(address.getPerson());
}
Also used : Address(io.requery.test.model.Address) Test(org.junit.Test)

Example 2 with Address

use of io.requery.test.model.Address in project requery by requery.

the class FunctionalTest method testCopy.

@Test
public void testCopy() {
    Address address = new Address();
    address.setCity("San Francisco");
    address.setState("CA");
    address.setCountry("US");
    Address copy = address.copy();
    assertEquals(address.getCity(), copy.getCity());
    assertEquals(address.getState(), copy.getState());
    assertEquals(address.getCountry(), copy.getCountry());
}
Also used : Address(io.requery.test.model.Address) Test(org.junit.Test)

Example 3 with Address

use of io.requery.test.model.Address in project requery by requery.

the class FunctionalTest method testInsertOneToOne.

@Test
public void testInsertOneToOne() {
    Address address = randomAddress();
    data.insert(address);
    assertTrue(address.getId() > 0);
    Person person = randomPerson();
    data.insert(person);
    person.setAddress(address);
    data.update(person);
    // fetch inverse
    assertSame(address.getPerson(), person);
    // unset
    person.setAddress(null);
}
Also used : Address(io.requery.test.model.Address) Person(io.requery.test.model.Person) Group_Person(io.requery.test.model.Group_Person) Test(org.junit.Test)

Example 4 with Address

use of io.requery.test.model.Address in project requery by requery.

the class FunctionalTest method testDeleteCascadeOneToOne.

@Test
public void testDeleteCascadeOneToOne() {
    Address address = randomAddress();
    data.insert(address);
    int id = address.getId();
    assertTrue(id > 0);
    Person person = randomPerson();
    person.setAddress(address);
    data.insert(person);
    data.delete(person);
    assertNull(address.getPerson());
    assertNull(data.findByKey(Address.class, id));
}
Also used : Address(io.requery.test.model.Address) Person(io.requery.test.model.Person) Group_Person(io.requery.test.model.Group_Person) Test(org.junit.Test)

Example 5 with Address

use of io.requery.test.model.Address in project requery by requery.

the class FunctionalTest method testInsertOneToOneCascade.

@Test
public void testInsertOneToOneCascade() {
    Address address = randomAddress();
    Person person = randomPerson();
    person.setAddress(address);
    data.insert(person);
    // fetch inverse
    assertSame(address.getPerson(), person);
}
Also used : Address(io.requery.test.model.Address) Person(io.requery.test.model.Person) Group_Person(io.requery.test.model.Group_Person) Test(org.junit.Test)

Aggregations

Address (io.requery.test.model.Address)11 Test (org.junit.Test)10 Person (io.requery.test.model.Person)8 Group_Person (io.requery.test.model.Group_Person)7 EntityCache (io.requery.EntityCache)1 EntityCacheBuilder (io.requery.cache.EntityCacheBuilder)1 Random (java.util.Random)1 CacheManager (javax.cache.CacheManager)1 CachingProvider (javax.cache.spi.CachingProvider)1