use of org.apache.deltaspike.data.test.ee7.domain.House in project deltaspike by apache.
the class HouseRepositoryTest method should_run_modifying_in_transaction.
@Test
@InSequence(1)
public void should_run_modifying_in_transaction() throws Exception {
House house = repository.findByName("Bellevue");
assertNotNull(house);
assertNotNull(house.getId());
assertEquals("Bellevue", house.getName());
assertTrue(puu.isLoaded(house, "flats"));
assertFalse(puu.isLoaded(house, "garages"));
}
use of org.apache.deltaspike.data.test.ee7.domain.House in project deltaspike by apache.
the class HouseRepositoryTest method shouldNotLoadLazyAssociationsWithoutGraph.
@Test
@InSequence(2)
public void shouldNotLoadLazyAssociationsWithoutGraph() throws Exception {
House house = repository.findOptionalByName("Bellevue");
assertNotNull(house);
PersistenceUnitUtil puu = entityManager.getEntityManagerFactory().getPersistenceUnitUtil();
assertFalse(puu.isLoaded(house, "flats"));
assertFalse(puu.isLoaded(house, "garages"));
}
use of org.apache.deltaspike.data.test.ee7.domain.House in project deltaspike by apache.
the class HouseRepositoryTest method should_build_dynamic_graph_from_paths.
@Test
@InSequence(5)
public void should_build_dynamic_graph_from_paths() throws Exception {
House house = repository.fetchByNameWithDynamicGraph("Bellevue");
assertNotNull(house);
assertTrue(puu.isLoaded(house, "flats"));
assertTrue(puu.isLoaded(house, "garages"));
assertEquals(2, house.getFlats().size());
assertEquals(2, house.getGarages().size());
Flat flat = house.getFlats().get(0);
assertFalse(puu.isLoaded(flat, "tenants"));
}
use of org.apache.deltaspike.data.test.ee7.domain.House in project deltaspike by apache.
the class HouseRepositoryTest method init.
@Before
public void init() throws Exception {
puu = entityManager.getEntityManagerFactory().getPersistenceUnitUtil();
// TODO this causes a tx rollback on GlassFish 4 when run in a UserTransaction
if (repository.count() == 0) {
tx.begin();
House house = new House();
Flat flat1 = new Flat();
flat1.setName("Flat 1");
flat1.setHouse(house);
Tenant alice = new Tenant();
alice.setName("Alice");
alice.setFlat(flat1);
Tenant bob = new Tenant();
bob.setName("Bob");
bob.setFlat(flat1);
Tenant charlie = new Tenant();
charlie.setName("Charlie");
charlie.setFlat(flat1);
flat1.setTenants(Arrays.asList(alice, bob, charlie));
Flat flat2 = new Flat();
flat2.setName("Flat 2");
flat2.setHouse(house);
Garage garageA = new Garage();
garageA.setName("Garage A");
garageA.setHouse(house);
Garage garageB = new Garage();
garageB.setName("Garage B");
garageB.setHouse(house);
house.setName("Bellevue");
house.setFlats(Arrays.asList(flat1, flat2));
house.setGarages(Arrays.asList(garageA, garageB));
entityManager.persist(house);
tx.commit();
}
}
use of org.apache.deltaspike.data.test.ee7.domain.House in project deltaspike by apache.
the class HouseRepositoryTest method should_build_dynamic_graph_from_composite_paths.
@Test
@InSequence(6)
public void should_build_dynamic_graph_from_composite_paths() throws Exception {
House house = repository.fetchByNameWithFlatTenants("Bellevue");
assertNotNull(house);
assertTrue(puu.isLoaded(house, "flats"));
assertTrue(puu.isLoaded(house, "garages"));
assertEquals(2, house.getFlats().size());
assertEquals(2, house.getGarages().size());
Flat flat = house.getFlats().get(0);
assertTrue(puu.isLoaded(flat, "tenants"));
assertEquals(3, flat.getTenants().size());
}
Aggregations