aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung
diff options
context:
space:
mode:
authorFelix Kehrer <felix.kehrer@gmail.com>2018-05-06 16:17:34 +0200
committerFelix Kehrer <felix.kehrer@gmail.com>2018-05-07 14:42:09 +0200
commitabbf3afda52ef48d1efd7912453d9d71e55fb2d9 (patch)
tree31fbe6d0798599acab7184b241a58d525b4fb9f4 /src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung
parent5a6c00ebc1583e0505fb795b3483f8937e7b8eb4 (diff)
downloadsepm-groupproject-abbf3afda52ef48d1efd7912453d9d71e55fb2d9.tar.gz
sepm-groupproject-abbf3afda52ef48d1efd7912453d9d71e55fb2d9.tar.xz
sepm-groupproject-abbf3afda52ef48d1efd7912453d9d71e55fb2d9.zip
Implemented correct insert test
Diffstat (limited to 'src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung')
-rw-r--r--src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java72
1 files changed, 71 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 03b70b1..e89e99a 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
@@ -2,10 +2,17 @@ package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao;
import static org.junit.Assert.*;
+import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee;
+import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee.EducationLevel;
+import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration;
import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException;
import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager;
import java.nio.charset.Charset;
import java.sql.SQLException;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.util.LinkedList;
+import java.util.List;
import org.h2.tools.RunScript;
import org.junit.After;
import org.junit.Before;
@@ -61,5 +68,68 @@ public class H2RegistrationDAOTest {
}
@Test
- public void add() {}
+ public void addRegistrationShouldSucceed() throws PersistenceException {
+ List<Registration> registrations = new LinkedList<>();
+ /*
+ Vehicle vehicle = Vehicle.builder()
+ .id(1)
+ .name("RTW-1")
+ .constructionType(ConstructionType.HOCHDACH)
+ .type(VehicleType.RTW)
+ .status(Status.ABGEMELDET)
+ .hasNef(true)
+ .build();
+ */
+ Employee employee1 =
+ Employee.builder()
+ .id(1)
+ .name("John Doe")
+ .birthday(LocalDate.now()) // incorrect, but should be irrelevant
+ .educationLevel(EducationLevel.RS)
+ .isDriver(true)
+ .isPilot(true)
+ .build();
+ Employee employee2 =
+ Employee.builder()
+ .id(2)
+ .name("Nick \"Kage\" Verily")
+ .birthday(LocalDate.now()) // incorrect, but should be irrelevant
+ .educationLevel(EducationLevel.NKV)
+ .isDriver(true)
+ .isPilot(false)
+ .build();
+ Employee employee3 =
+ Employee.builder()
+ .id(3)
+ .name("Nicht Arzt")
+ .birthday(LocalDate.now()) // incorrect, but should be irrelevant
+ .educationLevel(EducationLevel.NA)
+ .isDriver(false)
+ .isPilot(false)
+ .build();
+ Registration registration1 =
+ Registration.builder()
+ .start(Instant.now()) // incorrect, but should be irrelevant to outcome
+ .end(Instant.now()) // same
+ .employee(employee1)
+ .build();
+ Registration registration2 =
+ Registration.builder()
+ .start(Instant.now()) // incorrect, but should be irrelevant to outcome
+ .end(Instant.now()) // same
+ .employee(employee2)
+ .build();
+ Registration registration3 =
+ Registration.builder()
+ .start(Instant.now()) // incorrect, but should be irrelevant to outcome
+ .end(Instant.now()) // same
+ .employee(employee3)
+ .build();
+ registrations.add(registration1);
+ registrations.add(registration2);
+ registrations.add(registration3);
+
+ List<Long> returnvalues = registrationDAO.add(1, registrations);
+ assertFalse(returnvalues.isEmpty()); // can be improved...
+ }
}