Search in sources :

Example 6 with Customer

use of org.jboss.as.test.integration.jpa.hibernate.entity.Customer in project wildfly by wildfly.

the class EntityTest method createCustomer.

public Customer createCustomer(String name) {
    Customer c = new Customer();
    c.setName(name);
    session.save(c);
    return c;
}
Also used : Customer(org.jboss.as.test.integration.jpa.hibernate.entity.Customer)

Example 7 with Customer

use of org.jboss.as.test.integration.jpa.hibernate.entity.Customer 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);
}
Also used : Company(org.jboss.as.test.integration.jpa.hibernate.entity.Company) Customer(org.jboss.as.test.integration.jpa.hibernate.entity.Customer) Flight(org.jboss.as.test.integration.jpa.hibernate.entity.Flight) HashSet(java.util.HashSet)

Example 8 with Customer

use of org.jboss.as.test.integration.jpa.hibernate.entity.Customer in project wildfly by wildfly.

the class EntityTestCase method testOneToMany.

@Test
@InSequence(1)
public void testOneToMany() throws Exception {
    EntityTest test = lookup("EntityTest", EntityTest.class);
    Customer c = test.oneToManyCreate();
    assertNotNull(c);
    assertNotNull(c.getTickets());
    Set<Ticket> tickets = c.getTickets();
    assertTrue(tickets.size() > 0);
    assertNotNull(c);
    assertNotNull(c.getTickets());
    tickets = c.getTickets();
    assertTrue(tickets.size() > 0);
}
Also used : Ticket(org.jboss.as.test.integration.jpa.hibernate.entity.Ticket) Customer(org.jboss.as.test.integration.jpa.hibernate.entity.Customer) EntityTest(org.jboss.as.test.integration.jpa.hibernate.EntityTest) EntityTest(org.jboss.as.test.integration.jpa.hibernate.EntityTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

Customer (org.jboss.as.test.integration.jpa.hibernate.entity.Customer)8 InSequence (org.jboss.arquillian.junit.InSequence)3 EntityTest (org.jboss.as.test.integration.jpa.hibernate.EntityTest)3 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 Ticket (org.jboss.as.test.integration.jpa.hibernate.entity.Ticket)2 Company (org.jboss.as.test.integration.jpa.hibernate.entity.Company)1 Flight (org.jboss.as.test.integration.jpa.hibernate.entity.Flight)1