use of org.jboss.as.test.integration.jpa.hibernate.entity.Company in project wildfly by wildfly.
the class EntityTestCase method testManyToOne.
@Test
@InSequence(2)
public void testManyToOne() throws Exception {
EntityTest test = lookup("EntityTest", EntityTest.class);
Flight f = test.manyToOneCreate();
Flight f2 = test.findFlightById(f.getId());
assertEquals(f.getId(), new Long(1));
assertEquals(f.getName(), f2.getName());
assertEquals(f.getCompany().getName(), f2.getCompany().getName());
Company c = test.findCompanyById(f.getCompany().getId());
assertNotNull("Company has one flight.", c.getFlights());
assertEquals(f.getCompany().getFlights().size(), c.getFlights().size());
}
use of org.jboss.as.test.integration.jpa.hibernate.entity.Company in project wildfly by wildfly.
the class EntityTest method manyToOneCreate.
public Flight manyToOneCreate() throws Exception {
Flight f = new Flight();
f.setName("Flight number one");
f.setId(new Long(1));
Company comp = new Company();
comp.setName("Airline 1");
f.setCompany(comp);
session.save(f);
return f;
}
use of org.jboss.as.test.integration.jpa.hibernate.entity.Company in project wildfly by wildfly.
the class EntityTest method manyToManyCreate.
public void manyToManyCreate() throws Exception {
Flight f1 = findFlightById(new Long(1));
Flight f2 = new Flight();
f2.setId(new Long(2));
f2.setName("Flight two");
Company us = new Company();
us.setName("Airline 2");
f2.setCompany(us);
Set<Customer> customers1 = new HashSet<Customer>();
Set<Customer> customers2 = new HashSet<Customer>();
Customer c1 = new Customer();
c1.setName("John");
customers1.add(c1);
Customer c2 = new Customer();
c2.setName("Tom");
customers2.add(c2);
Customer c3 = new Customer();
c3.setName("Pete");
customers2.add(c3);
f1.setCustomers(customers1);
f2.setCustomers(customers2);
session.save(c1);
session.save(c2);
session.save(c3);
session.save(f2);
}
Aggregations