Database test competition type

master
Markus Kreth 7 years ago
parent 7f3e1653c0
commit ddf8f844d9
  1. 14
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/ClubEvent.java
  2. 22
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDataTest.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;
}

@ -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<ClubEvent> 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();

Loading…
Cancel
Save