Search in sources :

Example 1 with EntityTest

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

the class EntityTestCase method testNamedQueries.

@Test
@InSequence(4)
public void testNamedQueries() throws Exception {
    EntityTest test = lookup("EntityTest", EntityTest.class);
    int count = test.testAllCustomersQuery();
    assertEquals("Number returned for allCustomers query", 4, count);
    Customer c = test.testCustomerByIdQuery();
    assertNotNull("One object should be returned by customerById query", c);
}
Also used : 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)

Example 2 with EntityTest

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

Example 3 with EntityTest

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

the class EntityTestCase method testFlush.

@Test
@InSequence(5)
public void testFlush() throws Exception {
    EntityTest test = lookup("EntityTest", EntityTest.class);
    Customer c = test.createCustomer("Thomas");
    test.changeCustomer(c.getId(), "George");
    Customer c2 = test.findCustomerById(c.getId());
    assertEquals("George", c2.getName());
}
Also used : 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)

Example 4 with EntityTest

use of org.jboss.as.test.integration.jpa.hibernate.EntityTest 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)

Example 5 with EntityTest

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

the class EntityTestCase method testManyToMany.

@Test
@InSequence(3)
public void testManyToMany() throws Exception {
    EntityTest test = lookup("EntityTest", EntityTest.class);
    test.manyToManyCreate();
    Flight f1 = test.findFlightById(new Long(1));
    assertTrue("Name read from Hibernate is Airline 1", f1.getCompany().getName().equals("Airline 1"));
    Flight f2 = test.findFlightById(new Long(2));
    assertTrue("Name read from Hibernate is Airline 1", f2.getCompany().getName().equals("Airline 2"));
    assertEquals(1, f1.getCustomers().size());
    assertEquals(2, f2.getCustomers().size());
}
Also used : Flight(org.jboss.as.test.integration.jpa.hibernate.entity.Flight) 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

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