diff options
Diffstat (limited to 'src/test/java/at/ac/tuwien/sepm/assignment')
-rw-r--r-- | src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java index e89e99a..1180bfa 100644 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java @@ -17,7 +17,9 @@ import org.h2.tools.RunScript; import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; public class H2RegistrationDAOTest { @@ -67,8 +69,10 @@ public class H2RegistrationDAOTest { false); } + @Rule public ExpectedException thrown = ExpectedException.none(); + @Test - public void addRegistrationShouldSucceed() throws PersistenceException { + public void addRegistrationsShouldSucceed() throws PersistenceException { List<Registration> registrations = new LinkedList<>(); /* Vehicle vehicle = Vehicle.builder() @@ -132,4 +136,27 @@ public class H2RegistrationDAOTest { List<Long> returnvalues = registrationDAO.add(1, registrations); assertFalse(returnvalues.isEmpty()); // can be improved... } + + @Test + public void addRegistrationToInexistentVehicleShouldFail() throws PersistenceException { + thrown.expect(PersistenceException.class); + List<Registration> registrations = new LinkedList<>(); + Employee employee = + Employee.builder() + .id(1) + .name("John Doe") + .birthday(LocalDate.now()) // incorrect, but should be irrelevant + .educationLevel(EducationLevel.RS) + .isDriver(true) + .isPilot(true) + .build(); + Registration registration = + Registration.builder() + .start(Instant.MIN) + .end(Instant.MAX) + .employee(employee) + .build(); + registrations.add(registration); + registrationDAO.add(200, registrations); + } } |