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) }