Ejemplo n.º 1
0
  @Test
  public void test_cancell_flight()
      throws FlightCapacityExceededException, UnknownAirTicketException {
    // given
    Timestamp date = Timestamp.valueOf("2012-12-20 16:00:00");
    Flight flight1 = new Flight(date, 200, "praha", "london", 300);
    genericDao.save(flight1);
    int fullCapacity = flight1.getCapacity();
    AirTicket airTicket1 = bookingService.bookFlight(flight1.getId());
    int afterCapacity1 = flight1.getCapacity();
    assertEquals(fullCapacity, afterCapacity1 + 1);

    // when
    bookingService.cancelFlight(airTicket1.getId());
    int afterCapacity2 = flight1.getCapacity();

    // then
    assertEquals(fullCapacity, afterCapacity2);
    assertTrue(
        "Flight's airtickets should be empty after deleting the airticket",
        flight1.getAirTickets().isEmpty());
  }
Ejemplo n.º 2
0
 @Test(expected = UnknownAirTicketException.class)
 public void test_unknown_flight_exception_with_cancel() throws UnknownAirTicketException {
   // when
   bookingService.cancelFlight(898989898L);
 }