use of alfio.model.Event in project alf.io by alfio-event.
the class EventManagerIntegrationTest method testAddBoundedCategoryToUnboundedEvent.
@Test
public void testAddBoundedCategoryToUnboundedEvent() {
List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 0, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null));
Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
Event event = pair.getKey();
TicketCategoryModification tcm = new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null);
Result<Integer> result = eventManager.insertCategory(event, tcm, pair.getValue());
assertTrue(result.isSuccess());
List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
assertNotNull(tickets);
assertFalse(tickets.isEmpty());
assertEquals(10, tickets.size());
assertEquals(10, tickets.stream().filter(t -> t.getCategoryId() == null).count());
assertEquals(10, ticketRepository.countReleasedTicketInCategory(event.getId(), result.getData()).intValue());
}
use of alfio.model.Event in project alf.io by alfio-event.
the class EventManagerIntegrationTest method testUpdateBoundedFlagToTrue.
@Test
public void testUpdateBoundedFlagToTrue() {
List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null));
Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
Event event = pair.getLeft();
String username = pair.getRight();
assertEquals(new Integer(AVAILABLE_SEATS), ticketRepository.countFreeTicketsForUnbounded(event.getId()));
TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0);
Map<String, String> categoryDescription = ticketCategoryDescriptionRepository.descriptionForTicketCategory(category.getId());
TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), AVAILABLE_SEATS, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), false, "", true, null, null, null, null, null);
Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username);
assertTrue(result.isSuccess());
assertEquals(new Integer(0), ticketRepository.countFreeTicketsForUnbounded(event.getId()));
}
use of alfio.model.Event in project alf.io by alfio-event.
the class EventManagerIntegrationTest method testEventGenerationWithUnboundedCategory.
@Test
public void testEventGenerationWithUnboundedCategory() {
List<TicketCategoryModification> categories = Arrays.asList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null), new TicketCategoryModification(null, "default", 9, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null), new TicketCategoryModification(null, "default", 0, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null));
Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository).getKey();
List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
assertNotNull(tickets);
assertFalse(tickets.isEmpty());
assertEquals(AVAILABLE_SEATS, tickets.size());
assertEquals(1, tickets.stream().filter(t -> t.getCategoryId() == null).count());
}
use of alfio.model.Event in project alf.io by alfio-event.
the class EventManagerIntegrationTest method generateAndEditEvent.
private Pair<Event, String> generateAndEditEvent(int newEventSize) {
List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null));
Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
Event event = pair.getKey();
if (newEventSize != AVAILABLE_SEATS) {
EventModification update = new EventModification(event.getId(), Event.EventType.INTERNAL, null, null, null, null, null, null, null, event.getOrganizationId(), null, null, null, event.getZoneId().toString(), Collections.emptyMap(), DateTimeModification.fromZonedDateTime(event.getBegin()), DateTimeModification.fromZonedDateTime(event.getEnd()), event.getRegularPrice(), event.getCurrency(), newEventSize, event.getVat(), event.isVatIncluded(), event.getAllowedPaymentProxies(), null, event.isFreeOfCharge(), null, 7, null, null);
eventManager.updateEventPrices(event, update, pair.getValue());
}
List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
assertNotNull(tickets);
assertFalse(tickets.isEmpty());
assertEquals(AVAILABLE_SEATS, tickets.size());
if (newEventSize > AVAILABLE_SEATS) {
assertEquals(newEventSize - AVAILABLE_SEATS, ticketRepository.countReleasedUnboundedTickets(event.getId()).intValue());
}
assertEquals(10, tickets.stream().filter(t -> t.getCategoryId() != null).count());
return Pair.of(eventRepository.findById(event.getId()), pair.getRight());
}
use of alfio.model.Event in project alf.io by alfio-event.
the class EventManagerIntegrationTest method testNewBoundedCategoryWithExistingBoundedAndPendingTicket.
@Test
public void testNewBoundedCategoryWithExistingBoundedAndPendingTicket() {
List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null));
Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
Event event = pair.getLeft();
String username = pair.getRight();
assertEquals(new Integer(AVAILABLE_SEATS), ticketRepository.countFreeTicketsForUnbounded(event.getId()));
TicketReservationModification trm = new TicketReservationModification();
trm.setAmount(1);
trm.setTicketCategoryId(ticketCategoryRepository.findByEventId(event.getId()).get(0).getId());
TicketReservationWithOptionalCodeModification reservation = new TicketReservationWithOptionalCodeModification(trm, Optional.empty());
ticketReservationManager.createTicketReservation(event, Collections.singletonList(reservation), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(), Locale.ENGLISH, false);
TicketCategoryModification tcm = new TicketCategoryModification(null, "new", 1, DateTimeModification.fromZonedDateTime(ZonedDateTime.now()), DateTimeModification.fromZonedDateTime(ZonedDateTime.now().plusDays(1)), Collections.emptyMap(), BigDecimal.TEN, false, "", true, null, null, null, null, null);
Result<Integer> insertResult = eventManager.insertCategory(event, tcm, username);
assertTrue(insertResult.isSuccess());
Integer categoryID = insertResult.getData();
tcm = new TicketCategoryModification(categoryID, tcm.getName(), AVAILABLE_SEATS, tcm.getInception(), tcm.getExpiration(), tcm.getDescription(), tcm.getPrice(), false, "", true, null, null, null, null, null);
Result<TicketCategory> result = eventManager.updateCategory(categoryID, event, tcm, username);
assertFalse(result.isSuccess());
}
Aggregations