@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); }
private Event createEvent() { Event event = new Event(); Set<DateTime> sessionSet = new TreeSet<DateTime>(); sessionSet.add(TESTED_DATE); event.setName("Panda 4DX"); event.setRating(EventRating.HIGH); event.setSessionsSet(sessionSet); event.setBasePrice(EVENT_BASE_PRICE); return event; }
@Test public void testAssignAuditoriumToEvent() { Event testEvent = createEvent(); Auditorium testAuditorium = createAuditorium(); eventService.assignAuditoriumToEvent(testEvent, TESTED_DATE_2, testAuditorium); Assert.assertTrue(testAuditorium.getEventSchedule().contains(TESTED_DATE_2)); Assert.assertEquals(testEvent.getAuditoriums().get(TESTED_DATE_2), testAuditorium); eventService.removeAuditoriumAssignment(testEvent, TESTED_DATE_2, testAuditorium); Assert.assertFalse(testAuditorium.getEventSchedule().contains(TESTED_DATE_2)); }
@Test public void testEventSessionTime() { Event testEvent = createEvent(); Assert.assertEquals(testEvent.getSessionsSet().size(), 1); eventService.addSessionTime(testEvent, DateTime.now().plusDays(5)); eventService.addSessionTime(testEvent, DateTime.now().plusDays(6)); eventService.addSessionTime(testEvent, DateTime.now().plusDays(7)); Assert.assertEquals(testEvent.getSessionsSet().size(), 4); Assert.assertTrue(testEvent.getSessionsSet().contains(TESTED_DATE)); eventService.removeSessionTime(testEvent, TESTED_DATE); Assert.assertFalse(testEvent.getSessionsSet().contains(TESTED_DATE)); }