aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceIntegrationTest.java
blob: ac5c3fb9eb7866fe05577c9c1fd048099199e36a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service;

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 at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.EmployeeDAO;
import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.EmployeeDatabaseDAO;
import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.RegistrationDAO;
import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.RegistrationDatabaseDAO;
import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.VehicleDAO;
import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.VehicleDatabaseDAO;
import at.ac.tuwien.sepm.assignment.groupphase.util.JdbcTestCase;
import org.dbunit.dataset.IDataSet;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class RegistrationServiceIntegrationTest extends JdbcTestCase {

    private RegistrationDAO registrationDAO;
    private VehicleDAO vehicleDAO;

    @Rule public ExpectedException thrown = ExpectedException.none();

    @Override
    protected IDataSet getDataSet() throws Exception {
        return getDataSet("registrationTestBaseData.xml");
    }

    @Before
    public void prepare() throws PersistenceException {

        EmployeeDAO employeeDAO = new EmployeeDatabaseDAO(getJdbcConnectionManager());
        registrationDAO = new RegistrationDatabaseDAO(getJdbcConnectionManager(), employeeDAO);
        vehicleDAO =
                new VehicleDatabaseDAO(
                        getJdbcConnectionManager(), (RegistrationDatabaseDAO) registrationDAO);
    }

    @Test
    public void addValidRegistrationsShouldSucceed()
            throws InvalidRegistrationException, ServiceException, InvalidVehicleException {
        RegistrationServiceTest.addValidRegistrations(registrationDAO, vehicleDAO);
    }

    @Test
    public void addOnlyOnePersonToRTWShouldFail()
            throws InvalidRegistrationException, ServiceException, InvalidVehicleException {
        RegistrationServiceTest.addOnlyOnePersonToRTW(thrown, registrationDAO, vehicleDAO);
    }

    // TODO: also test real integration, e.g. add registration and delete afterwards (feedback)
}