Пример #1
0
  @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;
  }
Пример #2
0
  @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());
  }
Пример #3
0
  @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());
  }
Пример #4
0
  @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());
  }
Пример #5
0
  @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);
  }
Пример #6
0
  @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());
  }
Пример #7
0
  @Test
  @Ignore("mails")
  public void createReservationTest() {

    ReservationModel model = ReservationModelUtils.createReservationModel();

    Integer id = reservationService.createReservation(model);

    assert id != 0;
  }
Пример #8
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());
    }
  }
Пример #9
0
 @Test
 public void createReservationAdminTest() {
   final ReservationModel reservationModel = ReservationModelUtils.createReservationModel();
   final Integer id = reservationService.createReservationAdmin(reservationModel);
   assert id != 0;
 }