コード例 #1
0
  @Test
  public void testGetTicketPrice() {
    User testUser = createUser();
    Event testHighRatedEvent = createEvent();
    Event testEvent = createEvent();
    Auditorium testAuditorium = createAuditorium();

    eventService.assignAuditoriumToEvent(testHighRatedEvent, TESTED_DATE_2, testAuditorium);

    Assert.assertEquals(
        bookingService.getTicketPrice(testHighRatedEvent, TESTED_DATE_2, 10, testUser),
        HIGH_RATED_EVENT_PRICE,
        0);
    Assert.assertEquals(
        bookingService.getTicketPrice(testHighRatedEvent, TESTED_DATE_2, 1, testUser),
        HIGH_RATEDEVENT_PRICE_VIP_SEAT,
        0);

    testEvent.setRating(EventRating.MID);
    eventService.assignAuditoriumToEvent(testEvent, TESTED_DATE_2.plus(1), testAuditorium);

    Assert.assertEquals(
        bookingService.getTicketPrice(testEvent, TESTED_DATE_2.plus(1), 10, testUser),
        EVENT_BASE_PRICE,
        0);
    Assert.assertEquals(
        bookingService.getTicketPrice(testEvent, TESTED_DATE_2.plus(1), 1, testUser),
        EVENT_PRICE_VIP_SEAT,
        0);
  }
コード例 #2
0
  @Test(expected = IllegalArgumentException.class)
  public void testBookingTicket() {

    User testUser = createUser();
    User testUser2 = createUser();
    Event testEvent = createEvent();
    Ticket testTicket = createTicket(testEvent, TESTED_DATE, 1);
    Ticket testTicket2 = createTicket(testEvent, TESTED_DATE, 2);

    bookingService.bookTicket(testUser, testTicket);
    bookingService.bookTicket(testUser2, testTicket2);

    Assert.assertEquals(testTicket.getUser(), testUser);
    Assert.assertTrue(testUser.getBookedTickets().contains(testTicket));

    Assert.assertEquals(testTicket2.getUser(), testUser2);
    Assert.assertTrue(testUser2.getBookedTickets().contains(testTicket2));

    Assert.assertNotEquals(
        2, bookingService.getPurchasedTicketsForEvent(testEvent, TESTED_DATE).size());
  }