Exemple #1
0
  @Test
  public void testReservarOfertaAndFindReserva()
      throws InstanceNotFoundException, InputValidationException, OfertaEstadoException,
          OfertaMaxPersonasException, OfertaEmailException, OfertaReservaDateException,
          OfertaReclamaDateException {

    Oferta oferta = createOferta(getValidOferta());

    try {

      /* Reservar oferta. */
      Reserva reserva =
          ofertaService.findReserva(
              ofertaService.reservarOferta(
                  oferta.getOfertaId(), USER_EMAIL, VALID_CREDIT_CARD_NUMBER));

      /* Find reserva. */
      Reserva foundReserva = ofertaService.findReserva(reserva.getReservaId());

      /* Check reserva. */
      assertEquals(reserva, foundReserva);
      assertEquals(VALID_CREDIT_CARD_NUMBER, foundReserva.getNumeroTarjeta());
      assertEquals(USER_EMAIL, foundReserva.getEmailUsuario());
      assertEquals(oferta.getOfertaId(), foundReserva.getOfertaId());
      assertTrue(Calendar.getInstance().after(foundReserva.getFechaReserva()));

      /* Clear database */
      // Reclamamos la oferta para cambiar su estado y poder eliminarla (Solo se pueden borrar
      // ofertas 'Creadas' o 'Liberadas'
      ofertaService.reclamarOferta(reserva.getReservaId());
      removeReserva(reserva.getReservaId());
    } finally {
      removeOferta(oferta.getOfertaId());
    }
  }