From ddf8f844d980ca7f30b00b8d9c928bf829609891 Mon Sep 17 00:00:00 2001 From: Markus Kreth Date: Tue, 22 Jan 2019 05:15:19 +0100 Subject: [PATCH] Database test competition type --- .../vaadinclubhelper/data/ClubEvent.java | 14 ++++++++++++ .../dao/ClubEventDataTest.java | 22 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/ClubEvent.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/ClubEvent.java index 546272f..480af6e 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/ClubEvent.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/ClubEvent.java @@ -17,6 +17,8 @@ import javax.persistence.Transient; import org.vaadin.addon.calendar.item.BasicItem; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType.Type; + // Entity must not be used, this class is persisted by ClubEvent.hbm.xml @Entity public class ClubEvent extends BasicItem implements EntityAccessor { @@ -94,6 +96,18 @@ public class ClubEvent extends BasicItem implements EntityAccessor { return iCalUID; } + public Type getCompetitionType() { + if (competitionType != null) { + return competitionType.getType(); + } else { + return null; + } + } + + public void setCompetitionType(CompetitionType competitionType) { + this.competitionType = competitionType; + } + public String getOrganizerDisplayName() { return organizerDisplayName; } 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 a93de6f..971aeb2 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 @@ -19,6 +19,8 @@ import org.springframework.test.context.ContextConfiguration; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubeventHasPerson; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType.Type; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.tests.TestConfiguration; @@ -37,6 +39,26 @@ public class ClubEventDataTest { testDatabaseHelper.cleanDatabase(); } + @Test + public void testEventAddon() { + + ClubEvent ev = testDatabaseHelper.creteEvent(); + CompetitionType competitionType = new CompetitionType(); + competitionType.setType(Type.EINZEL); + ev.setCompetitionType(competitionType); + + testDatabaseHelper.transactional(() -> entityManager.persist(ev)); + List allClubEvent = testDatabaseHelper.allClubEvent(); + assertEquals(1, allClubEvent.size()); + assertEquals(Type.EINZEL, allClubEvent.get(0).getCompetitionType()); + + competitionType.setType(Type.DOPPELMINI); + testDatabaseHelper.transactional(() -> entityManager.merge(ev)); + allClubEvent = testDatabaseHelper.allClubEvent(); + assertEquals(1, allClubEvent.size()); + assertEquals(Type.DOPPELMINI, allClubEvent.get(0).getCompetitionType()); + } + @Test public void testSaveAndSelectEvent() { ClubEvent ev = testDatabaseHelper.creteEvent();