diff --git a/.classpath b/.classpath
index 3c31b96..1cbc804 100644
--- a/.classpath
+++ b/.classpath
@@ -32,6 +32,7 @@
+
diff --git a/pom.xml b/pom.xml
index e5e7c35..4a188c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -140,6 +140,11 @@
junit-jupiter-engine
test
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
@@ -238,6 +243,11 @@
org.apache.logging.log4j
log4j-core
+
+ org.junit.platform
+ junit-platform-runner
+ test
+
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/ZonedDateTimeAttributeConverter.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/ZonedDateTimeAttributeConverter.java
index a3d98d7..ae96718 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/ZonedDateTimeAttributeConverter.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/ZonedDateTimeAttributeConverter.java
@@ -10,7 +10,7 @@ import javax.persistence.Converter;
@Converter(autoApply = true)
public class ZonedDateTimeAttributeConverter
implements
- AttributeConverter {
+ AttributeConverter {
@Override
public Date convertToDatabaseColumn(ZonedDateTime attribute) {
@@ -20,7 +20,7 @@ public class ZonedDateTimeAttributeConverter
@Override
public ZonedDateTime convertToEntityAttribute(Date dbData) {
return ZonedDateTime.ofInstant(dbData.toInstant(),
- ZoneId.from(dbData.toInstant()));
+ ZoneId.systemDefault());
}
}
diff --git a/src/test/java/de/kreth/vaadin/clubhelper/AllTests.java b/src/test/java/de/kreth/vaadin/clubhelper/AllTests.java
new file mode 100644
index 0000000..5aa8d66
--- /dev/null
+++ b/src/test/java/de/kreth/vaadin/clubhelper/AllTests.java
@@ -0,0 +1,11 @@
+package de.kreth.vaadin.clubhelper;
+
+import org.junit.platform.runner.JUnitPlatform;
+import org.junit.platform.suite.api.SelectPackages;
+import org.junit.runner.RunWith;
+
+@RunWith(JUnitPlatform.class)
+@SelectPackages("de.kreth.vaadin.clubhelper")
+public class AllTests {
+
+}
diff --git a/src/test/java/de/kreth/vaadin/clubhelper/FastTestsOnly.java b/src/test/java/de/kreth/vaadin/clubhelper/FastTestsOnly.java
new file mode 100644
index 0000000..7f02487
--- /dev/null
+++ b/src/test/java/de/kreth/vaadin/clubhelper/FastTestsOnly.java
@@ -0,0 +1,12 @@
+package de.kreth.vaadin.clubhelper;
+
+import org.junit.platform.runner.JUnitPlatform;
+import org.junit.platform.suite.api.ExcludeTags;
+import org.junit.platform.suite.api.SelectPackages;
+import org.junit.runner.RunWith;
+
+@RunWith(JUnitPlatform.class)
+@SelectPackages("de.kreth.vaadin.clubhelper")
+@ExcludeTags("spring")
+public class FastTestsOnly {
+}
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 5430449..d024cea 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
@@ -14,6 +14,7 @@ import javax.persistence.TypedQuery;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +30,7 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.tests.TestConfiguration;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestConfiguration.class)
+@Tag("spring")
class EventBusinessSpringTest {
private List persons;
diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/ZonedDateTimeAttributeConverterTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/ZonedDateTimeAttributeConverterTest.java
new file mode 100644
index 0000000..1b1c4b7
--- /dev/null
+++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/ZonedDateTimeAttributeConverterTest.java
@@ -0,0 +1,48 @@
+package de.kreth.vaadin.clubhelper.vaadinclubhelper.business;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.temporal.ChronoField;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class ZonedDateTimeAttributeConverterTest {
+
+ private ZonedDateTimeAttributeConverter converter;
+
+ @BeforeEach
+ void setUp() throws Exception {
+ this.converter = new ZonedDateTimeAttributeConverter();
+ }
+
+ @Test
+ void testZonedToDate() {
+ ZonedDateTime zonedDatetime = ZonedDateTime.of(2019, 4, 25, 21, 43, 13, 0, ZoneId.systemDefault());
+ Date actualDate = converter.convertToDatabaseColumn(zonedDatetime);
+ GregorianCalendar calendar = new GregorianCalendar();
+ calendar.setTime(actualDate);
+ assertEquals(21, calendar.get(Calendar.HOUR_OF_DAY));
+ assertEquals(43, calendar.get(Calendar.MINUTE));
+ assertEquals(13, calendar.get(Calendar.SECOND));
+ assertEquals(0, calendar.get(Calendar.MILLISECOND));
+ }
+
+ @Test
+ void testDateToZoned() {
+ GregorianCalendar calendar = new GregorianCalendar();
+ ZonedDateTime zonedDateTime = converter.convertToEntityAttribute(calendar.getTime());
+ assertNotNull(zonedDateTime);
+ assertEquals(calendar.get(Calendar.HOUR_OF_DAY), zonedDateTime.get(ChronoField.HOUR_OF_DAY));
+ assertEquals(calendar.get(Calendar.MINUTE), zonedDateTime.get(ChronoField.MINUTE_OF_HOUR));
+ assertEquals(calendar.get(Calendar.SECOND), zonedDateTime.get(ChronoField.SECOND_OF_MINUTE));
+ assertEquals(calendar.get(Calendar.MILLISECOND), zonedDateTime.get(ChronoField.MILLI_OF_SECOND));
+ }
+
+}
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 dfd001a..e5d9ab6 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
@@ -12,6 +12,7 @@ import java.util.Set;
import javax.persistence.EntityManager;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -25,6 +26,7 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.tests.TestConfiguration;
@SpringBootTest
@ContextConfiguration(classes = TestConfiguration.class)
+@Tag("spring")
public class ClubEventDataTest {
@Autowired
diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoRelativeTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoRelativeTest.java
index 834c663..e645559 100644
--- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoRelativeTest.java
+++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoRelativeTest.java
@@ -16,6 +16,7 @@ import org.hibernate.SessionFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -26,6 +27,7 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.tests.TestConfiguration;
@SpringBootTest
@ContextConfiguration(classes = TestConfiguration.class)
+@Tag("spring")
@Disabled
public class PersonDaoRelativeTest {
@@ -42,6 +44,7 @@ public class PersonDaoRelativeTest {
private SessionFactory sessionFactory;
private Person person1;
+
private Person person2;
@BeforeEach
diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoTest.java
index a5fa71c..c2ad74b 100644
--- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoTest.java
+++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoTest.java
@@ -12,6 +12,7 @@ import javax.persistence.EntityManager;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -23,6 +24,7 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.tests.TestConfiguration;
@SpringBootTest
@ContextConfiguration(classes = TestConfiguration.class)
+@Tag("spring")
public class PersonDaoTest {
@Autowired
diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonFilterTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonFilterTest.java
index fe1a2f5..ea09dd8 100644
--- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonFilterTest.java
+++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonFilterTest.java
@@ -14,6 +14,7 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -29,10 +30,13 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.tests.TestConfiguration;
@SpringBootTest
@ContextConfiguration(classes = TestConfiguration.class)
+@Tag("spring")
class PersonFilterTest {
private PersonFilter filter;
+
private List persons;
+
private final List groups = setupData();
@Autowired
diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonGroupValidatorTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonGroupValidatorTest.java
new file mode 100644
index 0000000..9790c49
--- /dev/null
+++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonGroupValidatorTest.java
@@ -0,0 +1,43 @@
+package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+import java.util.ArrayList;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.vaadin.data.ValidationResult;
+
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef;
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
+
+class PersonGroupValidatorTest {
+
+ private PersonGroupValidator validator;
+
+ private Person person;
+
+ @BeforeEach
+ void setUp() throws Exception {
+ validator = new PersonGroupValidator();
+ person = new Person();
+ }
+
+ @Test
+ void testError() {
+ ValidationResult result = validator.apply(person, null);
+ assertTrue(result.isError());
+ }
+
+ @Test
+ void testOk() {
+ GroupDef group = new GroupDef();
+ group.setPersongroups(new ArrayList<>());
+ person.add(group);
+ ValidationResult result = validator.apply(person, null);
+ assertFalse(result.isError());
+ }
+
+}
diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/ZonedDateTimeConverterTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/ZonedDateTimeConverterTest.java
new file mode 100644
index 0000000..505a123
--- /dev/null
+++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/ZonedDateTimeConverterTest.java
@@ -0,0 +1,53 @@
+package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+import java.time.LocalDate;
+import java.time.ZonedDateTime;
+import java.time.temporal.ChronoField;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.vaadin.data.Result;
+
+class ZonedDateTimeConverterTest {
+
+ private ZonedDateTimeConverter converter;
+
+ @BeforeEach
+ void setUp() throws Exception {
+ converter = new ZonedDateTimeConverter();
+ }
+
+ @Test
+ void testConvertToModelNull() {
+ Result result = converter.convertToModel(null, null);
+ assertNotNull(result);
+ assertFalse(result.isError());
+ assertNull(result.getOrThrow(msg -> new RuntimeException(msg)));
+ }
+
+ @Test
+ void testConvertToModel() {
+ LocalDate now = LocalDate.now();
+ Result result = converter.convertToModel(now, null);
+ assertNotNull(result);
+ assertFalse(result.isError());
+ ZonedDateTime actual = result.getOrThrow(msg -> new RuntimeException(msg));
+ assertEquals(0, actual.get(ChronoField.HOUR_OF_DAY));
+ assertEquals(0, actual.get(ChronoField.MINUTE_OF_DAY));
+ assertEquals(0, actual.get(ChronoField.SECOND_OF_MINUTE));
+ assertEquals(0, actual.get(ChronoField.MILLI_OF_SECOND));
+ }
+
+ @Test
+ void testConvertToPresentation() {
+ ZonedDateTime now = ZonedDateTime.now();
+ assertEquals(now.toLocalDate(), converter.convertToPresentation(now, null));
+ }
+
+}