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 f42d638..ef0238d 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 @@ -40,9 +40,6 @@ public class EventBusiness { public void changePersons(Set selected) { if (current != null) { -// for (Person p : selected) { -// current.add(p); -// } try { dao.addPersons(current, selected); log.info("Updated {}, {} with participants: {}", current.getCaption(), current.getStart(), selected); 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 f48817d..4a04406 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 @@ -157,29 +157,35 @@ public class ClubEvent extends BasicItem { public boolean equals(Object obj) { if (this == obj) return true; + if (obj == null) + return false; if (getClass() != obj.getClass()) return false; ClubEvent other = (ClubEvent) obj; 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; } diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusinessTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusinessTest.java index 39e547e..7203ef7 100644 --- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusinessTest.java +++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusinessTest.java @@ -24,6 +24,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import de.kreth.clubhelperbackend.google.calendar.CalendarAdapter; import de.kreth.vaadin.clubhelper.HibernateHolder; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.AbstractDatabaseTest; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.ClubEventDao; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.ClubEventDaoImpl; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; @@ -38,17 +39,17 @@ class EventBusinessTest { private DatabaseHelper helper; @Autowired - protected EntityManager entityManager; - private EventBusiness business; + @Autowired + private EntityManager entityManager; + @Configuration - public static class MyConfig { + public static class InnerConfig { @Bean public EntityManager getEntityManager() throws Exception { - // setup the session factory org.hibernate.cfg.Configuration configuration = HibernateHolder.configuration(); SessionFactory sessionFactory = configuration.buildSessionFactory(); @@ -56,11 +57,21 @@ class EventBusinessTest { } + @Bean + public ClubEventDao getClubEventDao() { + return new ClubEventDaoImpl(); + } + @Bean public CalendarAdapter getCalendarAdapter() throws GeneralSecurityException, IOException { return new CalendarAdapter(); } + @Bean + public EventBusiness getEventBusiness() { + return new EventBusiness(); + } + } @BeforeEach @@ -68,11 +79,6 @@ class EventBusinessTest { helper = new DatabaseHelper(entityManager); helper.cleanH2Database(); - ClubEventDaoImpl dao = new ClubEventDaoImpl(); - dao.setEntityManager(entityManager); - - business = new EventBusiness(); - business.dao = dao; insertTestData(); business.setSelected(event); }