diff options
| author | Felix Kehrer <felix.kehrer@gmail.com> | 2018-05-06 17:04:51 +0200 | 
|---|---|---|
| committer | Felix Kehrer <felix.kehrer@gmail.com> | 2018-05-07 14:42:09 +0200 | 
| commit | 8c73a66236c9a3c416fdb7d337725ec9d4ab6583 (patch) | |
| tree | 02ee1c405b6d5f8a6723cb05aa2e2b5b366dca49 /src/test/java/at/ac/tuwien | |
| parent | abbf3afda52ef48d1efd7912453d9d71e55fb2d9 (diff) | |
| download | sepm-groupproject-8c73a66236c9a3c416fdb7d337725ec9d4ab6583.tar.gz sepm-groupproject-8c73a66236c9a3c416fdb7d337725ec9d4ab6583.tar.xz sepm-groupproject-8c73a66236c9a3c416fdb7d337725ec9d4ab6583.zip  | |
Implemented incorrect insert test (specified vehicle does not exist in test database)
Diffstat (limited to 'src/test/java/at/ac/tuwien')
| -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); +    }  }  | 
