aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceTest.java
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2018-06-20 22:07:36 +0200
committerTharre <tharre3@gmail.com>2018-06-20 22:07:36 +0200
commit0c995a05985da749d93aa56eba976c7fc621a4fa (patch)
tree5b80394920705aae5e2b6004c3dfbd839c8b8fa3 /src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceTest.java
parentf5bc7925a8fbbe247972a6f0e0571cc7e92fbefa (diff)
parente21feb3ac772a5394dc5381b58142c3c061de716 (diff)
downloadsepm-groupproject-master.tar.gz
sepm-groupproject-master.tar.xz
sepm-groupproject-master.zip
Merge branch 'develop'HEADv3.0master
Diffstat (limited to 'src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceTest.java')
-rw-r--r--src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceTest.java148
1 files changed, 0 insertions, 148 deletions
diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceTest.java
deleted file mode 100644
index 4d3a251..0000000
--- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service;
-
-import static org.mockito.ArgumentMatchers.anyLong;
-import static org.mockito.Mockito.when;
-
-import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.RegistrationDAO;
-import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.VehicleDAO;
-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.einsatzverwaltung.dto.Vehicle;
-import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Builder;
-import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.ConstructionType;
-import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status;
-import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.VehicleType;
-import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException;
-import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidRegistrationException;
-import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException;
-import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException;
-import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException;
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.temporal.ChronoUnit;
-import java.util.HashSet;
-import java.util.Set;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
-
-public class RegistrationServiceTest {
-
- @Mock private RegistrationDAO registrationDAO;
-
- @Mock private VehicleDAO vehicleDAO;
-
- @Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
-
- @Rule public ExpectedException thrown = ExpectedException.none();
-
- @Before
- public void setUp() throws ElementNotFoundException, PersistenceException {
- MockitoAnnotations.initMocks(this);
- Builder b =
- Vehicle.builder()
- .name("RTW-1")
- .constructionType(ConstructionType.HOCHDACH)
- .status(Status.ABGEMELDET)
- .type(VehicleType.RTW)
- .hasNef(true);
- when(vehicleDAO.get(anyLong())).thenAnswer(ans -> b.id(ans.getArgument(0)).build());
- }
-
- @Test
- public void addValidRegistrationsShouldSucceed()
- throws InvalidRegistrationException, ServiceException, InvalidVehicleException {
- RegistrationService registrationService =
- new RegistrationServiceImpl(registrationDAO, vehicleDAO);
- Set<Registration> registrations = new HashSet<>();
- 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();
- Instant start = Instant.now();
- Instant end = start.plus(8, ChronoUnit.HOURS);
- Registration registration1 =
- Registration.builder().start(start).end(end).employee(employee1).build();
- Registration registration2 =
- Registration.builder().start(start).end(end).employee(employee2).build();
- Registration registration3 =
- Registration.builder().start(start).end(end).employee(employee3).build();
- registrations.add(registration1);
- registrations.add(registration2);
- registrations.add(registration3);
- registrationService.add(vehicle.id(), registrations);
- }
-
- @Test
- public void addOnlyOnePersonToRTWShouldFail()
- throws InvalidRegistrationException, ServiceException, InvalidVehicleException {
- thrown.expect(InvalidRegistrationException.class);
- RegistrationService registrationService =
- new RegistrationServiceImpl(registrationDAO, vehicleDAO);
- Set<Registration> registrations = new HashSet<>();
- Vehicle vehicle =
- Vehicle.builder()
- .id(1)
- .name("RTW-1")
- .constructionType(ConstructionType.HOCHDACH)
- .type(VehicleType.RTW)
- .status(Status.ABGEMELDET)
- .hasNef(true)
- .build();
- 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);
- registrationService.add(vehicle.id(), registrations);
- }
-}