diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/VaadinClubhelperApplication.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/VaadinClubhelperApplication.java index c7f010e..e28b4c6 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/VaadinClubhelperApplication.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/VaadinClubhelperApplication.java @@ -6,7 +6,7 @@ import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.scheduling.annotation.EnableScheduling; -@SpringBootApplication +@SpringBootApplication(scanBasePackages = { "de.kreth.vaadin.clubhelper", "de.kreth.clubhelperbackend" }) @EnableScheduling public class VaadinClubhelperApplication extends SpringBootServletInitializer { diff --git a/src/test/java/de/kreth/vaadin/clubhelper/HibernateHolder.java b/src/test/java/de/kreth/vaadin/clubhelper/HibernateHolder.java new file mode 100644 index 0000000..87f502c --- /dev/null +++ b/src/test/java/de/kreth/vaadin/clubhelper/HibernateHolder.java @@ -0,0 +1,47 @@ +package de.kreth.vaadin.clubhelper; + +import org.hibernate.cfg.Configuration; + +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Adress; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Attendance; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Contact; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.DeletedEntry; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Persongroup; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Relative; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Startpaesse; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.StartpassStartrechte; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Version; + +public enum HibernateHolder { + + INSTANCE; + final Configuration configuration = createConfig(); + + org.hibernate.cfg.Configuration createConfig() { + Configuration configuration = new Configuration(); + configuration.addAnnotatedClass(Adress.class); + configuration.addAnnotatedClass(Attendance.class); + configuration.addAnnotatedClass(Contact.class); + configuration.addAnnotatedClass(DeletedEntry.class); + configuration.addAnnotatedClass(GroupDef.class); + configuration.addAnnotatedClass(Person.class); + configuration.addAnnotatedClass(Persongroup.class); + configuration.addAnnotatedClass(Relative.class); + configuration.addAnnotatedClass(Startpaesse.class); + configuration.addAnnotatedClass(StartpassStartrechte.class); + configuration.addAnnotatedClass(Version.class); + configuration.addInputStream(getClass().getResourceAsStream("/schema/ClubEvent.hbm.xml")); + + configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect"); + configuration.setProperty("hibernate.connection.driver_class", "org.h2.Driver"); + configuration.setProperty("hibernate.connection.url", "jdbc:h2:mem:test"); + configuration.setProperty("hibernate.hbm2ddl.auto", "create"); + return configuration; + } + + public static Configuration configuration() { + return INSTANCE.configuration; + } +} diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/AbstractDatabaseTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/AbstractDatabaseTest.java index daddfb9..f07be4c 100644 --- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/AbstractDatabaseTest.java +++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/AbstractDatabaseTest.java @@ -1,11 +1,19 @@ package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; import javax.persistence.EntityTransaction; @@ -15,20 +23,16 @@ import org.hibernate.cfg.Configuration; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Adress; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Attendance; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Contact; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.DeletedEntry; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef; +import de.kreth.vaadin.clubhelper.HibernateHolder; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEventBuilder; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubeventHasPerson; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Persongroup; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Relative; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Startpaesse; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.StartpassStartrechte; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Version; public abstract class AbstractDatabaseTest { + private static final AtomicInteger counter = new AtomicInteger(); + protected static SessionFactory sessionFactory; protected static Session session; @@ -36,35 +40,13 @@ public abstract class AbstractDatabaseTest { public static void setUpDatabase() throws Exception { // setup the session factory - Configuration configuration = createConfig(); + Configuration configuration = HibernateHolder.configuration(); sessionFactory = configuration.buildSessionFactory(); session = sessionFactory.openSession(); } - public static Configuration createConfig() { - Configuration configuration = new Configuration(); - configuration.addAnnotatedClass(Adress.class); - configuration.addAnnotatedClass(Attendance.class); - configuration.addAnnotatedClass(Contact.class); - configuration.addAnnotatedClass(DeletedEntry.class); - configuration.addAnnotatedClass(GroupDef.class); - configuration.addAnnotatedClass(Person.class); - configuration.addAnnotatedClass(Persongroup.class); - configuration.addAnnotatedClass(Relative.class); - configuration.addAnnotatedClass(Startpaesse.class); - configuration.addAnnotatedClass(StartpassStartrechte.class); - configuration.addAnnotatedClass(Version.class); - configuration.addInputStream(AbstractDatabaseTest.class.getResourceAsStream("/schema/ClubEvent.hbm.xml")); - - configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect"); - configuration.setProperty("hibernate.connection.driver_class", "org.h2.Driver"); - configuration.setProperty("hibernate.connection.url", "jdbc:h2:mem:test"); - configuration.setProperty("hibernate.hbm2ddl.auto", "create"); - return configuration; - } - public enum DB_TYPE { MYSQL("SET @@foreign_key_checks = 0", "SET @@foreign_key_checks = 1"), H2("SET REFERENTIAL_INTEGRITY FALSE", "SET REFERENTIAL_INTEGRITY TRUE"); @@ -133,4 +115,67 @@ public abstract class AbstractDatabaseTest { throw e; } } + + public Person testInsertPerson() { + Person p = new Person(); + p.setPrename("prename"); + p.setSurname("surname"); + p.setBirth(LocalDate.now()); + + transactional(() -> session.save(p)); + return p; + } + + public List insertPersons(int count) { + + final List inserted = new ArrayList<>(); + + transactional(() -> { + for (int i = 0; i < count; i++) { + + Person p = new Person(); + p.setPrename("prename_" + i); + p.setSurname("surname_" + i); + p.setBirth(LocalDate.now()); + session.save(p); + inserted.add(p); + } + }); + for (Person p : inserted) { + assertTrue(p.getId() > 0, "not saved: " + p); + } + return inserted; + } + + public ClubEvent creteEvent() { + ClubEvent ev = ClubEventBuilder.builder().withId("id_" + counter.getAndIncrement()).withAllDay(true) + .withCaption("caption").withDescription("description") + .withStart(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0, ZoneId.systemDefault())) + .withEnd(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0, ZoneId.systemDefault())).withiCalUID("iCalUID") + .withOrganizerDisplayName("organizerDisplayName").build(); + return ev; + } + + public List loadEventPersons() { + + return session.doReturningWork(conn -> { + + List link = new ArrayList<>(); + + try (Statement stm = conn.createStatement()) { + ResultSet rs = stm.executeQuery("select * from clubevent_has_person"); + while (rs.next()) { + ClubeventHasPerson ep = new ClubeventHasPerson(); + + ep.setClubEventId(rs.getString("clubevent_id")); + ep.setPersonId(rs.getInt("person_id")); + link.add(ep); + } + } + + return link; + }); + + } + } diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDaoTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDaoTest.java deleted file mode 100644 index c2ecba4..0000000 --- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDaoTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.util.List; - -import org.hibernate.query.Query; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.test.context.junit4.SpringRunner; - -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEventBuilder; - -@RunWith(SpringRunner.class) -@DataJpaTest -@EnableAutoConfiguration -@Disabled -public class ClubEventDaoTest extends AbstractDatabaseTest { - - @Autowired - private ClubEventDao dao; - - @Test - public void storeEvent() { - dao.save(creteEvent()); - - Query query = session.createNamedQuery("ClubEvent.findAll", ClubEvent.class); - List result = query.list(); - assertEquals(1, result.size()); - } - - private ClubEvent creteEvent() { - ClubEvent ev = ClubEventBuilder.builder().withId("id").withAllDay(true).withCaption("caption") - .withDescription("description") - .withStart(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0, ZoneId.systemDefault())) - .withEnd(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0, ZoneId.systemDefault())).withiCalUID("iCalUID") - .withOrganizerDisplayName("organizerDisplayName").build(); - return ev; - } - -} diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDataTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDataTest.java index fddf22c..b79ba91 100644 --- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDataTest.java +++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDataTest.java @@ -3,63 +3,22 @@ package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import java.sql.ResultSet; -import java.sql.Statement; import java.time.LocalDate; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; import org.hibernate.IdentifierLoadAccess; import org.hibernate.query.Query; import org.junit.jupiter.api.Test; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEventBuilder; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubeventHasPerson; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; public class ClubEventDataTest extends AbstractDatabaseTest { - private static final AtomicInteger counter = new AtomicInteger(); - - public Person testInsertPerson() { - Person p = new Person(); - p.setPrename("prename"); - p.setSurname("surname"); - p.setBirth(LocalDate.now()); - - transactional(() -> session.save(p)); - return p; - } - - public List insertPersons(int count) { - - final List inserted = new ArrayList<>(); - - transactional(() -> { - for (int i = 0; i < count; i++) { - - Person p = new Person(); - p.setPrename("prename_" + i); - p.setSurname("surname_" + i); - p.setBirth(LocalDate.now()); - session.save(p); - inserted.add(p); - } - }); - for (Person p : inserted) { - assertTrue(p.getId() > 0, "not saved: " + p); - } - return inserted; - } - @Test public void testSaveAndSelectEvent() { ClubEvent ev = creteEvent(); @@ -93,28 +52,6 @@ public class ClubEventDataTest extends AbstractDatabaseTest { } - private List loadEventPersons() { - - return session.doReturningWork(conn -> { - - List link = new ArrayList<>(); - - try (Statement stm = conn.createStatement()) { - ResultSet rs = stm.executeQuery("select * from clubevent_has_person"); - while (rs.next()) { - ClubeventHasPerson ep = new ClubeventHasPerson(); - - ep.setClubEventId(rs.getString("clubevent_id")); - ep.setPersonId(rs.getInt("person_id")); - link.add(ep); - } - } - - return link; - }); - - } - @Test public void changeEventsPersons() { ClubEvent ev = creteEvent(); @@ -138,10 +75,10 @@ public class ClubEventDataTest extends AbstractDatabaseTest { loaded.setPersons(new HashSet<>()); } - loaded.getPersons().add(person); + loaded.add(person); transactional(() -> session.update(ev)); - loaded.getPersons().add(person2); + loaded.add(person2); transactional(() -> session.update(ev)); List entries = loadEventPersons(); @@ -176,12 +113,4 @@ public class ClubEventDataTest extends AbstractDatabaseTest { assertEquals(6, result.size()); } - private ClubEvent creteEvent() { - ClubEvent ev = ClubEventBuilder.builder().withId("id_" + counter.getAndIncrement()).withAllDay(true) - .withCaption("caption").withDescription("description") - .withStart(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0, ZoneId.systemDefault())) - .withEnd(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0, ZoneId.systemDefault())).withiCalUID("iCalUID") - .withOrganizerDisplayName("organizerDisplayName").build(); - return ev; - } } diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/DatabaseTestBean.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/DatabaseTestBean.java index bc472f6..94ffdee 100644 --- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/DatabaseTestBean.java +++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/DatabaseTestBean.java @@ -1,59 +1,26 @@ package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao; -import java.io.IOException; - -import org.hibernate.Session; -import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Bean; -import org.springframework.core.io.Resource; -import org.springframework.core.io.ResourceLoader; -import org.springframework.core.io.support.ResourcePatternUtils; import org.springframework.orm.hibernate5.LocalSessionFactoryBean; +import de.kreth.vaadin.clubhelper.HibernateHolder; + @SpringBootConfiguration @EnableAutoConfiguration public class DatabaseTestBean { - @Autowired - private ResourceLoader rl; - @Bean public LocalSessionFactoryBean sessionFactory() throws Exception { - MyTestDatabase tdb = new MyTestDatabase(); - Configuration config = tdb.createConfig(); - - LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean(); - sessionFactoryBean.setHibernateProperties(config.getProperties()); -// Class[] dataClasses = {Adress.class, Attendance.class, Contact.class, DeletedEntry.class, GroupDef.class, Person.class, Persongroup.class, Relative.class, Startpaesse.class, StartpassStartrechte.class, Version.class}; -// sessionFactoryBean.setMappingLocations(loadResources()); -// sessionFactoryBean.setAnnotatedClasses(dataClasses); - - return sessionFactoryBean; - } - public Resource[] loadResources() { - Resource[] resources = null; - try { - resources = ResourcePatternUtils.getResourcePatternResolver(rl) - .getResources("classpath:/schema/*.hbm.xml"); - } catch (IOException e) { - throw new RuntimeException(e); - } - return resources; - } - - class MyTestDatabase extends AbstractDatabaseTest { - - public SessionFactory getSessionFactory() { - return sessionFactory; - } - - public Session getSession() { - return session; - } + Configuration config = HibernateHolder.configuration(); + + LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean(); + sessionFactoryBean.setHibernateProperties(config.getProperties()); + + return sessionFactoryBean; } + } diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/tests/TestConfiguration.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/tests/TestConfiguration.java index 5a93941..c071883 100644 --- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/tests/TestConfiguration.java +++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/tests/TestConfiguration.java @@ -10,17 +10,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import de.kreth.clubhelperbackend.google.calendar.CalendarAdapter; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Adress; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Attendance; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Contact; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.DeletedEntry; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Persongroup; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Relative; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Startpaesse; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.StartpassStartrechte; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Version; +import de.kreth.vaadin.clubhelper.HibernateHolder; @Configuration public class TestConfiguration { @@ -29,7 +19,7 @@ public class TestConfiguration { public EntityManager getEntityManager() throws Exception { // setup the session factory - org.hibernate.cfg.Configuration configuration = createConfig(); + org.hibernate.cfg.Configuration configuration = HibernateHolder.configuration(); SessionFactory sessionFactory = configuration.buildSessionFactory(); return sessionFactory.openSession(); @@ -41,26 +31,4 @@ public class TestConfiguration { return new CalendarAdapter(); } - public org.hibernate.cfg.Configuration createConfig() { - org.hibernate.cfg.Configuration configuration = new org.hibernate.cfg.Configuration(); - configuration.addAnnotatedClass(Adress.class); - configuration.addAnnotatedClass(Attendance.class); - configuration.addAnnotatedClass(Contact.class); - configuration.addAnnotatedClass(DeletedEntry.class); - configuration.addAnnotatedClass(GroupDef.class); - configuration.addAnnotatedClass(Person.class); - configuration.addAnnotatedClass(Persongroup.class); - configuration.addAnnotatedClass(Relative.class); - configuration.addAnnotatedClass(Startpaesse.class); - configuration.addAnnotatedClass(StartpassStartrechte.class); - configuration.addAnnotatedClass(Version.class); - configuration.addInputStream(getClass().getResourceAsStream("/schema/ClubEvent.hbm.xml")); - - configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect"); - configuration.setProperty("hibernate.connection.driver_class", "org.h2.Driver"); - configuration.setProperty("hibernate.connection.url", "jdbc:h2:mem:test"); - configuration.setProperty("hibernate.hbm2ddl.auto", "create"); - return configuration; - } - } diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/tests/VaadinClubhelperApplicationTests.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/tests/VaadinClubhelperApplicationTests.java index 9bf57de..24198cc 100644 --- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/tests/VaadinClubhelperApplicationTests.java +++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/tests/VaadinClubhelperApplicationTests.java @@ -55,7 +55,7 @@ public class VaadinClubhelperApplicationTests { int port; @Autowired - EntityManager em; + EntityManager entityManager; private WebDriver driver; private ZonedDateTime now; @@ -89,11 +89,11 @@ public class VaadinClubhelperApplicationTests { } public void insertDataIntoDatabase() { - TypedQuery query = em.createQuery("FROM groupDef", GroupDef.class); + TypedQuery query = entityManager.createQuery("FROM groupDef", GroupDef.class); if (!query.getResultList().isEmpty()) { return; } - EntityTransaction tx = em.getTransaction(); + EntityTransaction tx = entityManager.getTransaction(); tx.begin(); GroupDef adminGroup = new GroupDef(); @@ -103,15 +103,15 @@ public class VaadinClubhelperApplicationTests { GroupDef participantGroup = new GroupDef(); participantGroup.setName("ACTIVE"); - em.persist(adminGroup); - em.persist(competitorGroup); - em.persist(participantGroup); + entityManager.persist(adminGroup); + entityManager.persist(competitorGroup); + entityManager.persist(participantGroup); ClubEvent ev = new ClubEventBuilder().withAllDay(true).withId("id" + idCount.incrementAndGet()) .withCaption("caption").withDescription("description").withiCalUID("iCalUID").withLocation("location") .withOrganizerDisplayName("mtv_allgemein").withStart(now).withEnd(now.plusDays(2)).build(); - em.persist(ev); + entityManager.persist(ev); ZonedDateTime holidayStart; ZonedDateTime holidayEnd; @@ -129,7 +129,7 @@ public class VaadinClubhelperApplicationTests { .withCaption("holiday").withDescription("holiday").withiCalUID("iCalUID").withLocation("") .withOrganizerDisplayName("Schulferien").withStart(holidayStart).withEnd(holidayEnd).build(); - em.persist(holiday); + entityManager.persist(holiday); Person p = new Person(); p.setPrename("prename"); @@ -138,7 +138,7 @@ public class VaadinClubhelperApplicationTests { p.setUsername("Allgroups"); p.setPassword("password"); p.setPersongroups(Arrays.asList(adminGroup, competitorGroup, participantGroup)); - em.persist(p); + entityManager.persist(p); p = new Person(); p.setPrename("prename"); @@ -147,7 +147,7 @@ public class VaadinClubhelperApplicationTests { p.setUsername("participant"); p.setPassword("password"); p.setPersongroups(Arrays.asList(participantGroup)); - em.persist(p); + entityManager.persist(p); p = new Person(); p.setPrename("prename"); @@ -156,7 +156,7 @@ public class VaadinClubhelperApplicationTests { p.setUsername("competitor"); p.setPassword("password"); p.setPersongroups(Arrays.asList(competitorGroup, participantGroup)); - em.persist(p); + entityManager.persist(p); tx.commit(); } @@ -166,7 +166,7 @@ public class VaadinClubhelperApplicationTests { if (driver != null) { driver.close(); } - org.hibernate.Session session = (Session) em; + org.hibernate.Session session = (Session) entityManager; session.doWork(connection -> { AbstractDatabaseTest.cleanDatabase(connection, AbstractDatabaseTest.DB_TYPE.H2);