@Test public void getReservation() { List<HutOccupationModel> reservation = reservationService.getOccupation( new DateTime(2015, 10, 1, 0, 0, 0), new DateTime(2015, 10, 10, 0, 0, 0)); assert reservation.size() == 10; for (HutOccupationModel reservationModel : reservation) { assert reservationModel.getHuts().isEmpty(); } ReservationModel model = ReservationModelUtils.createReservationModel( new DateTime(2015, 10, 2, 0, 0, 0), new DateTime(2015, 10, 4, 0, 0, 0)); reservationService.createReservationAdmin(model); reservation = reservationService.getOccupation( new DateTime(2015, 10, 1, 0, 0, 0), new DateTime(2015, 10, 10, 0, 0, 0)); assert reservation.size() == 10; int reservedDays = 0; for (HutOccupationModel reservationModel : reservation) { if (!reservationModel.getHuts().isEmpty()) reservedDays++; } assert reservedDays == 3; }
@Test(expected = RuntimeException.class) // @Ignore("mails") public void testMoreHutsPaid() { final int id1 = reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); reservationService.updateReservationState(ReservationState.PAID.name(), id1); entityManager.clear(); final int id2 = reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); reservationService.updateReservationState(ReservationState.PAID.name(), id2); entityManager.clear(); final int id3 = reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); reservationService.updateReservationState(ReservationState.PAID.name(), id3); entityManager.clear(); final int id4 = reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); reservationService.updateReservationState(ReservationState.PAID.name(), id4); entityManager.clear(); reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); }
@Test @Ignore public void testMoreHutsPaidAndNew() { final int id1 = reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); reservationService.updateReservationState(ReservationState.PAID.name(), id1); entityManager.clear(); final int id2 = reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); reservationService.updateReservationState(ReservationState.PAID.name(), id2); entityManager.clear(); final int id3 = reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); reservationService.updateReservationState(ReservationState.PAID.name(), id3); entityManager.clear(); final int id4 = reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); // final List<Reservation> reservations = reservationRepository.findAll(); assertNotNull(reservations); assertFalse(reservations.isEmpty()); assertEquals(5, reservations.size()); }
@Test @Ignore public void testMoreHutsNew() { reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); reservationService.createReservationAdmin(ReservationModelUtils.createReservationModel()); final List<Reservation> reservations = reservationRepository.findAll(); assertNotNull(reservations); assertFalse(reservations.isEmpty()); assertEquals(5, reservations.size()); }
@Test @Ignore("mails") public void getReservationStateTest() { final ReservationState state = ReservationState.CONFIRM; ReservationModel model = ReservationModelUtils.createReservationModel(); final int reservationId = reservationService.createReservation(model); reservationService.updateReservationState(state.name(), reservationId); entityManager.clear(); List<cz.cizek.mytinka.domain.Reservation> reservations = reservationService.getReservations(state); assert reservations.size() == 1; assert (reservations.get(0).getState() == state); }
@Test @Ignore("mails") public void updateStateTest() { ReservationModel model = ReservationModelUtils.createReservationModel(); Integer id = reservationService.createReservationAdmin(model); reservationService.updateReservationState(ReservationState.CONFIRM.name(), id); entityManager.clear(); Reservation reservation = reservationRepository.findOne(id); assert Objects.equals(reservation.getId(), id); assert reservation.getState().equals(ReservationState.CONFIRM.name()); }
@Test @Ignore("mails") public void createReservationTest() { ReservationModel model = ReservationModelUtils.createReservationModel(); Integer id = reservationService.createReservation(model); assert id != 0; }
@Test public void getOccupationTest_noReservation() { final List<HutOccupationModel> occupations = reservationService.getOccupation(ReservationModelUtils.FROM, ReservationModelUtils.TO); assertNotNull(occupations); assertFalse(occupations.isEmpty()); for (final HutOccupationModel hutOccupationModel : occupations) { assertTrue(hutOccupationModel.getHuts().isEmpty()); } }
@Test public void createReservationAdminTest() { final ReservationModel reservationModel = ReservationModelUtils.createReservationModel(); final Integer id = reservationService.createReservationAdmin(reservationModel); assert id != 0; }