|
|
|
@ -1,7 +1,7 @@ |
|
|
|
package de.kreth.vaadin.clubhelper.vaadinclubhelper.business; |
|
|
|
package de.kreth.vaadin.clubhelper.vaadinclubhelper.business; |
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertNull; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertNull; |
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
@ -46,6 +46,7 @@ class EventBusinessSpringTest { |
|
|
|
|
|
|
|
|
|
|
|
@BeforeEach |
|
|
|
@BeforeEach |
|
|
|
void setUp() throws Exception { |
|
|
|
void setUp() throws Exception { |
|
|
|
|
|
|
|
testDatabaseHelper.cleanDatabase(); |
|
|
|
insertTestData(); |
|
|
|
insertTestData(); |
|
|
|
eventBusiness.setSelected(event); |
|
|
|
eventBusiness.setSelected(event); |
|
|
|
|
|
|
|
|
|
|
|
@ -60,8 +61,7 @@ class EventBusinessSpringTest { |
|
|
|
|
|
|
|
|
|
|
|
private void insertTestData() { |
|
|
|
private void insertTestData() { |
|
|
|
persons = new ArrayList<>(); |
|
|
|
persons = new ArrayList<>(); |
|
|
|
|
|
|
|
testDatabaseHelper.transactional(() -> { |
|
|
|
entityManager.getTransaction().begin(); |
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
|
|
|
|
|
|
|
|
Person p = new Person(); |
|
|
|
Person p = new Person(); |
|
|
|
@ -74,7 +74,7 @@ class EventBusinessSpringTest { |
|
|
|
event = testDatabaseHelper.creteEvent(); |
|
|
|
event = testDatabaseHelper.creteEvent(); |
|
|
|
assertNull(event.getPersons()); |
|
|
|
assertNull(event.getPersons()); |
|
|
|
entityManager.persist(event); |
|
|
|
entityManager.persist(event); |
|
|
|
entityManager.getTransaction().commit(); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@ -94,14 +94,8 @@ class EventBusinessSpringTest { |
|
|
|
@Disabled |
|
|
|
@Disabled |
|
|
|
void testAddPersonsToEvent() { |
|
|
|
void testAddPersonsToEvent() { |
|
|
|
assertEquals(0, all.getResultList().size()); |
|
|
|
assertEquals(0, all.getResultList().size()); |
|
|
|
|
|
|
|
testDatabaseHelper.transactional(() -> eventBusiness.changePersons(new HashSet<>(persons.subList(0, 1)))); |
|
|
|
entityManager.getTransaction().begin(); |
|
|
|
testDatabaseHelper.transactional(() -> eventBusiness.changePersons(new HashSet<>(persons.subList(0, 2)))); |
|
|
|
eventBusiness.changePersons(new HashSet<>(persons.subList(0, 1))); |
|
|
|
|
|
|
|
entityManager.getTransaction().commit(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entityManager.getTransaction().begin(); |
|
|
|
|
|
|
|
eventBusiness.changePersons(new HashSet<>(persons.subList(0, 2))); |
|
|
|
|
|
|
|
entityManager.getTransaction().commit(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ClubeventHasPerson> result = all.getResultList(); |
|
|
|
List<ClubeventHasPerson> result = all.getResultList(); |
|
|
|
assertEquals(2, result.size()); |
|
|
|
assertEquals(2, result.size()); |
|
|
|
|