From 99cc213ef1fb419bfa482f245eee5c3b0f4a5b80 Mon Sep 17 00:00:00 2001 From: Markus Kreth Date: Wed, 24 Apr 2019 23:12:00 +0200 Subject: [PATCH] Error handling --- .classpath | 5 +++ .settings/org.eclipse.core.resources.prefs | 1 + .settings/org.eclipse.wst.common.component | 33 ++++++++++------ pom.xml | 3 +- .../vaadinclubhelper/ClubhelperException.java | 15 ++++++++ .../business/EventBusiness.java | 18 ++++++--- .../vaadinclubhelper/dao/PersonDaoImpl.java | 7 +++- .../vaadinclubhelper/data/ClubEvent.java | 28 +++++++++++--- .../ui/ClubhelperErrorDialog.java | 38 +++++++++++++++++++ .../ui/components/CalendarComponent.java | 16 ++++++-- .../ui/navigation/HeadView.java | 36 +++++++++++------- .../ui/navigation/LoginUI.java | 6 ++- .../ui/navigation/MainView.java | 25 ++++++++++-- .../business/EventBusinessSpringTest.java | 22 ++++++++++- .../business/ThrowingRunnable.java | 6 +++ 15 files changed, 208 insertions(+), 51 deletions(-) create mode 100644 src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ClubhelperException.java create mode 100644 src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/ClubhelperErrorDialog.java create mode 100644 src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/ThrowingRunnable.java diff --git a/.classpath b/.classpath index 522ef49..3c31b96 100644 --- a/.classpath +++ b/.classpath @@ -35,5 +35,10 @@ + + + + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index f004f42..6d88dab 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -5,4 +5,5 @@ encoding//src/main/resources/jasper/calendar_month.jrxml=UTF-8 encoding//src/main/resources/jasper/calendar_year.jrxml=UTF-8 encoding//src/test/java=UTF-8 encoding//src/test/resources=UTF-8 +encoding//target/generated-resources/gwt=UTF-8 encoding/=UTF-8 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index b7f26ad..d6bcf76 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,6 @@ - + + @@ -7,8 +8,9 @@ - - + + + @@ -17,7 +19,8 @@ - + + @@ -26,7 +29,8 @@ - + + @@ -35,7 +39,8 @@ - + + @@ -44,7 +49,8 @@ - + + @@ -53,7 +59,9 @@ - + + + @@ -62,7 +70,8 @@ - + + @@ -71,7 +80,8 @@ - + + @@ -80,7 +90,8 @@ - + + diff --git a/pom.xml b/pom.xml index 48d2b3d..e5e7c35 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ de.kreth.vaadin.clubhelper vaadin-clubhelper - 1.1.0 + 1.1.1-SNAPSHOT war vaadin-clubhelper @@ -345,6 +345,5 @@ https://github.com/markuskreth/vaadin-clubhelper.git scm:git:git@github.com:markuskreth/vaadin-clubhelper.git scm:git:git@github.com:markuskreth/vaadin-clubhelper.git - vaadin-clubhelper-1.1.0 diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ClubhelperException.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ClubhelperException.java new file mode 100644 index 0000000..81cfb6b --- /dev/null +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ClubhelperException.java @@ -0,0 +1,15 @@ +package de.kreth.vaadin.clubhelper.vaadinclubhelper; + +public class ClubhelperException extends Exception { + + private static final long serialVersionUID = 8677112373849590712L; + + public ClubhelperException(String message, Throwable cause) { + super(message, cause); + } + + public ClubhelperException(String message) { + super(message); + } + +} diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusiness.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusiness.java index d753592..a5fbecb 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusiness.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusiness.java @@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.ClubhelperException; import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.meldung.EventMeldung; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.AltersgruppeDao; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.ClubEventDao; @@ -44,15 +45,19 @@ public class EventBusiness { this.current = ev; } - public void changePersons(Set selected) { + public void changePersons(Set selected) throws ClubhelperException { if (current != null) { try { clubEventDao.addPersons(current, selected); log.info("Updated {}, {} with participants: {}", current.getCaption(), current.getStart(), selected); - } catch (Exception e) { - log.error("Unable to update Event {}, {}, {} with participants: {}", current.getId(), - current.getCaption(), current.getStart(), selected, e); - throw e; + } + catch (Exception e) { + StringBuilder errorMessage = new StringBuilder("Unable to update Event "); + errorMessage.append(current.getId()); + errorMessage.append(", ").append(current.getCaption()); + errorMessage.append(", ").append(current.getStart()); + errorMessage.append(" with participants: ").append(selected); + throw new ClubhelperException(errorMessage.toString(), e); } } } @@ -70,7 +75,8 @@ public class EventBusiness { return el; } } - } else { + } + else { altersgruppen.add(e); e.setClubEvent(current); } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoImpl.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoImpl.java index b2b781c..a689947 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoImpl.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoImpl.java @@ -33,6 +33,7 @@ public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao super.save(obj); } + @Transactional public void checkSubEntities(Person obj) { Startpass startPass = obj.getStartpass(); if (startPass != null) { @@ -58,7 +59,8 @@ public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao c.setChanged(now); if (entityManager.contains(c) || c.hasValidId()) { entityManager.merge(c); - } else { + } + else { c.setCreated(now); entityManager.persist(c); } @@ -95,7 +97,8 @@ public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao if (r[1].equals(ignoring)) { p = entityManager.find(Person.class, r[2]); relation = r[3].toString(); - } else if (r[2].equals(ignoring)) { + } + else if (r[2].equals(ignoring)) { p = entityManager.find(Person.class, r[1]); relation = r[4].toString(); } 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 836dacb..22a4bf5 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 @@ -21,20 +21,30 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType.Type; // Entity must not be used, this class is persisted by ClubEvent.hbm.xml @Entity +/** + * Calendar Event item corresponding to google calendar events. + * @author markus + * + */ public class ClubEvent extends BasicItem implements EntityAccessor { private static final long serialVersionUID = -3600971939167437577L; @Id private String id; + private String location; + private String iCalUID; private String organizerDisplayName; + @ManyToMany private Set persons; + @OneToMany private Set altersgruppen; + @OneToOne @JoinColumn(name = "id", nullable = true) private CompetitionType competitionType; @@ -99,7 +109,8 @@ public class ClubEvent extends BasicItem implements EntityAccessor { public Type getType() { if (competitionType != null) { return competitionType.getType(); - } else { + } + else { return null; } } @@ -196,25 +207,29 @@ public class ClubEvent extends BasicItem implements EntityAccessor { if (iCalUID == null) { if (other.iCalUID != null) return false; - } else if (!iCalUID.equals(other.iCalUID)) { + } + else if (!iCalUID.equals(other.iCalUID)) { return false; } if (id == null) { if (other.id != null) return false; - } else if (!id.equals(other.id)) { + } + else if (!id.equals(other.id)) { return false; } if (location == null) { if (other.location != null) return false; - } else if (!location.equals(other.location)) { + } + else if (!location.equals(other.location)) { return false; } if (organizerDisplayName == null) { if (other.organizerDisplayName != null) return false; - } else if (!organizerDisplayName.equals(other.organizerDisplayName)) { + } + else if (!organizerDisplayName.equals(other.organizerDisplayName)) { return false; } return true; @@ -224,7 +239,8 @@ public class ClubEvent extends BasicItem implements EntityAccessor { if (parse != null) { Instant instant = parse.toInstant(); return ZonedDateTime.ofInstant(instant, ZoneId.systemDefault()); - } else { + } + else { return null; } } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/ClubhelperErrorDialog.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/ClubhelperErrorDialog.java new file mode 100644 index 0000000..40dc19e --- /dev/null +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/ClubhelperErrorDialog.java @@ -0,0 +1,38 @@ +package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import com.vaadin.shared.ui.ContentMode; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; + +public class ClubhelperErrorDialog { + + private final Window errorDlg = new Window("Fehler"); + + public ClubhelperErrorDialog(String errormessage, Exception exception) { + VerticalLayout layout = new VerticalLayout(); + layout.addComponent(new Label(errormessage)); + layout.addComponent(new Label(exception.getMessage())); + StringWriter out = new StringWriter(); + PrintWriter writer = new PrintWriter(out); + exception.printStackTrace(writer); + layout.addComponent(toComponent(out)); + layout.addComponent(new Button("Schließen", event -> errorDlg.close())); + errorDlg.setContent(layout); + } + + public Label toComponent(StringWriter out) { + Label label = new Label(out.toString()); + label.setContentMode(ContentMode.PREFORMATTED); + return label; + } + + public void show(UI ui) { + ui.addWindow(errorDlg); + } +} diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarComponent.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarComponent.java index 85d3311..a73d219 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarComponent.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarComponent.java @@ -24,11 +24,14 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; public class CalendarComponent extends CustomComponent { private static final long serialVersionUID = -9152173211931554059L; - private transient final Logger log = LoggerFactory.getLogger(getClass()); + + private final transient Logger log = LoggerFactory.getLogger(getClass()); + + private final transient List> dateUpdateEvents; private final ClubEventProvider dataProvider; - private Calendar calendar; - private List> dateUpdateEvents; + + private final Calendar calendar; public CalendarComponent(ClubEventProvider dataProvider) { @@ -40,7 +43,7 @@ public class CalendarComponent extends CustomComponent { calendar.setCaption("Events"); calendar.setSizeFull(); - calendar.addListener(ev -> calendarEvent(ev)); + calendar.addListener(this::calendarEvent); setCompositionRoot(calendar); } @@ -75,6 +78,11 @@ public class CalendarComponent extends CustomComponent { calendar.markAsDirty(); } + /** + * {@link ClubEvent} provider for vaadin calendar addon. + * @author markus + * + */ public static class ClubEventProvider extends BasicItemProvider { private static final long serialVersionUID = -5415397258827236704L; diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java index df0bdf0..5c05760 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java @@ -48,6 +48,7 @@ public class HeadView extends HorizontalLayout { private static final long serialVersionUID = -7915475211371903028L; protected transient final Logger log = LoggerFactory.getLogger(getClass()); + protected transient DateTimeFormatter dfMonth = DateTimeFormatter.ofPattern("MMMM uuuu"); private final ClubEventProvider dataProvider; @@ -55,9 +56,11 @@ public class HeadView extends HorizontalLayout { private int monthItemId; private final Button personLabel; + protected final Label monthName; private final Function startTime; + private final Function endTime; private final ClubNavigator navigator; @@ -104,7 +107,8 @@ public class HeadView extends HorizontalLayout { Person loggedinPerson = securityVerifier.getLoggedinPerson(); if (loggedinPerson != null) { personLabel.setCaption(loggedinPerson.getSurname() + ", " + loggedinPerson.getPrename()); - } else { + } + else { personLabel.setCaption(""); } } @@ -133,7 +137,8 @@ public class HeadView extends HorizontalLayout { securityVerifier.setLoggedinPerson(null); navigator.navigateTo(ClubhelperViews.MainView.name()); }); - } else { + } + else { contextMenu.addItem("Anmelden", ev1 -> navigator.navigateTo(ClubhelperViews.LoginUI.name())); } int width = getUI().getPage().getBrowserWindowWidth(); @@ -156,7 +161,8 @@ public class HeadView extends HorizontalLayout { start = startTime.apply(source); end = endTime.apply(source); items = dataProvider.getItems(start, end); - } else { + } + else { start = startTime.apply(source).withDayOfYear(1); end = start.withMonth(12).withDayOfMonth(31); items = dataProvider.getItems(start, end); @@ -180,7 +186,8 @@ public class HeadView extends HorizontalLayout { if (values.containsKey(day)) { content = values.get(day); content.append("\n"); - } else { + } + else { content = new StringBuilder(); values.put(day, content); } @@ -194,7 +201,8 @@ public class HeadView extends HorizontalLayout { String calendarMonth; if (monthOnly) { calendarMonth = dfMonth.format(start); - } else { + } + else { calendarMonth = "Jahr " + start.getYear(); } @@ -202,7 +210,8 @@ public class HeadView extends HorizontalLayout { JasperPrint print; if (monthOnly) { print = CalendarCreator.createCalendar(new Date(start.toInstant().toEpochMilli()), values, holidays); - } else { + } + else { print = CalendarCreator.createYearCalendar(start.getYear(), values, holidays); } log.trace("Created Jasper print for {}", calendarMonth); @@ -215,12 +224,10 @@ public class HeadView extends HorizontalLayout { window.setHeight("90%"); personLabel.getUI().addWindow(window); log.trace("Added pdf window for {}", calendarMonth); - } catch (JRException e) { + } + catch (JRException | IOException | RuntimeException e) { log.error("Error Creating Jasper Report for {}", calendarMonth, e); Notification.show("Fehler bei PDF: " + e); - } catch (IOException e1) { - log.error("Error Creating Jasper Report for {}", calendarMonth, e1); - Notification.show("Fehler bei PDF: " + e1); } } @@ -239,13 +246,16 @@ public class HeadView extends HorizontalLayout { exec.execute(() -> { try { JasperExportManager.exportReportToPdfStream(print, out); - } catch (JRException e) { + } + catch (JRException e) { log.error("Error on Export to Pdf.", e); throw new RuntimeException(e); - } finally { + } + finally { try { out.close(); - } catch (IOException e) { + } + catch (IOException e) { log.warn("Error closing Jasper output stream.", e); } } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/LoginUI.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/LoginUI.java index e446220..26897d7 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/LoginUI.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/LoginUI.java @@ -18,9 +18,11 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier; public class LoginUI extends VerticalLayout implements View { private static final long serialVersionUID = 4339018452507960084L; + private final Logger logger = LoggerFactory.getLogger(getClass()); private Navigator navigator; + private String parameters; public LoginUI(PersonDao personDao, SecurityVerifier securityGroupVerifier) { @@ -35,8 +37,8 @@ public class LoginUI extends VerticalLayout implements View { Person loggedin = personDao.findLoginUser(username, password); securityGroupVerifier.setLoggedinPerson(loggedin); navigator.navigateTo(ClubhelperViews.MainView.name() + '/' + parameters); - } catch (final Exception ex) { - ex.printStackTrace(); + } + catch (final Exception ex) { logger.error("Error on login for User={}", e.getLoginParameter("username"), ex); String message = "Incorrect user or password for " + e.getLoginParameter("username") + "\n" + ex.getMessage(); diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainView.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainView.java index a5a0e39..a6f7680 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainView.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainView.java @@ -11,12 +11,14 @@ import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.ui.Grid.SelectionMode; import com.vaadin.ui.VerticalLayout; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.ClubhelperException; import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.ClubhelperErrorDialog; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonGrid; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.SingleEventView; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperNavigation.ClubNavigator; @@ -24,14 +26,19 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperNavig public abstract class MainView extends VerticalLayout implements View { private static final long serialVersionUID = 4831071242146146399L; + protected final Logger LOGGER = LoggerFactory.getLogger(getClass()); private final PersonDao personDao; + private final GroupDao groupDao; + protected final EventBusiness eventBusiness; + protected final SecurityVerifier securityVerifier; protected PersonGrid personGrid; + protected SingleEventView eventView; protected ClubNavigator navigator; @@ -49,16 +56,19 @@ public abstract class MainView extends VerticalLayout implements View { if (this.navigator == null) { initUI(event); LOGGER.info("Loaded UI and started fetch of Events"); - } else { + } + else { if (securityVerifier.isLoggedin()) { LOGGER.info("{} already initialized - opening Person View.", getClass().getName()); ClubEvent current = eventBusiness.getCurrent(); openDetailForEvent(current); - } else { + } + else { LOGGER.info("{} already initialized - but not loggedin.", getClass().getName()); detailClosed(); } } + } public void initUI(ViewChangeEvent event) { @@ -79,7 +89,16 @@ public abstract class MainView extends VerticalLayout implements View { private void personSelectionChange(SelectionEvent ev) { Set selected = ev.getAllSelectedItems(); LOGGER.debug("Selection changed to: {}", selected); - eventBusiness.changePersons(selected); + try { + eventBusiness.changePersons(selected); + } + catch (ClubhelperException e) { + LOGGER.error("Error storing Persons.", e); + + String text = "Fehler beim Speichern der Personen dieser Veranstaltung"; + new ClubhelperErrorDialog(text, e).show(getUI()); + + } } public void detailClosed() { diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusinessSpringTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusinessSpringTest.java index 1560196..5430449 100644 --- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusinessSpringTest.java +++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusinessSpringTest.java @@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.ClubhelperException; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.TestDatabaseHelper; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubeventHasPerson; @@ -31,6 +32,7 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.tests.TestConfiguration; class EventBusinessSpringTest { private List persons; + private ClubEvent event; @Autowired @@ -94,11 +96,27 @@ class EventBusinessSpringTest { @Disabled void testAddPersonsToEvent() { assertEquals(0, all.getResultList().size()); - testDatabaseHelper.transactional(() -> eventBusiness.changePersons(new HashSet<>(persons.subList(0, 1)))); - testDatabaseHelper.transactional(() -> eventBusiness.changePersons(new HashSet<>(persons.subList(0, 2)))); + try { + transactional(() -> eventBusiness.changePersons(new HashSet<>(persons.subList(0, 1)))); + transactional(() -> eventBusiness.changePersons(new HashSet<>(persons.subList(0, 2)))); + } + catch (Exception e) { + + } List result = all.getResultList(); assertEquals(2, result.size()); } + private void transactional(ThrowingRunnable object) { + testDatabaseHelper.transactional(() -> { + try { + object.run(); + } + catch (ClubhelperException e) { + throw new RuntimeException(e); + } + }); + } + } diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/ThrowingRunnable.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/ThrowingRunnable.java new file mode 100644 index 0000000..e98d104 --- /dev/null +++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/ThrowingRunnable.java @@ -0,0 +1,6 @@ +package de.kreth.vaadin.clubhelper.vaadinclubhelper.business; + +public interface ThrowingRunnable { + + void run() throws E; +}