use of alfio.repository.user.OrganizationRepository in project alf.io by alfio-event.
the class EventManagerIntegrationTest method testEventGenerationWithOverflow.
@Test(expected = IllegalArgumentException.class)
public void testEventGenerationWithOverflow() {
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", 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", 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());
assertTrue(tickets.stream().noneMatch(t -> t.getCategoryId() == null));
}
use of alfio.repository.user.OrganizationRepository in project alf.io by alfio-event.
the class WaitingQueueProcessorIntegrationTest method testPreRegistration.
@Test
public void testPreRegistration() {
List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()), new DateTimeModification(LocalDate.now().plusDays(2), 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();
waitingQueueManager.subscribe(event, new CustomerName("Giuseppe Garibaldi", "Giuseppe", "Garibaldi", event), "peppino@garibaldi.com", null, Locale.ENGLISH);
waitingQueueManager.subscribe(event, new CustomerName("Nino Bixio", "Nino", "Bixio", event), "bixio@mille.org", null, Locale.ITALIAN);
assertTrue(waitingQueueRepository.countWaitingPeople(event.getId()) == 2);
waitingQueueSubscriptionProcessor.distributeAvailableSeats(event);
assertEquals(18, ticketRepository.findFreeByEventId(event.getId()).size());
TicketCategoryModification tcm = new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now().minusDays(1), LocalTime.now()), new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null);
eventManager.insertCategory(event.getId(), tcm, pair.getValue());
waitingQueueSubscriptionProcessor.distributeAvailableSeats(event);
List<WaitingQueueSubscription> subscriptions = waitingQueueRepository.loadAll(event.getId());
assertEquals(2, subscriptions.stream().filter(w -> StringUtils.isNotBlank(w.getReservationId())).count());
assertTrue(subscriptions.stream().allMatch(w -> w.getStatus().equals(WaitingQueueSubscription.Status.PENDING)));
assertTrue(subscriptions.stream().allMatch(w -> w.getSubscriptionType().equals(WaitingQueueSubscription.Type.PRE_SALES)));
}
use of alfio.repository.user.OrganizationRepository in project alf.io by alfio-event.
the class AdminReservationManagerIntegrationTest method performExistingCategoryTest.
private Triple<Event, String, TicketReservation> performExistingCategoryTest(List<TicketCategoryModification> categories, boolean bounded, List<Integer> attendeesNr, boolean addSeatsIfNotAvailable, boolean expectSuccess, int reservedTickets, int expectedEventSeats) {
assertEquals("Test error: categories' size must be equal to attendees' size", categories.size(), attendeesNr.size());
Pair<Event, String> eventWithUsername = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
Event event = eventWithUsername.getKey();
String username = eventWithUsername.getValue();
DateTimeModification expiration = DateTimeModification.fromZonedDateTime(ZonedDateTime.now().plusDays(1));
CustomerData customerData = new CustomerData("Integration", "Test", "integration-test@test.ch", "Billing Address", "en");
Iterator<Integer> attendeesIterator = attendeesNr.iterator();
List<TicketCategory> existingCategories = ticketCategoryRepository.findByEventId(event.getId());
List<Attendee> allAttendees = new ArrayList<>();
List<TicketsInfo> ticketsInfoList = existingCategories.stream().map(existingCategory -> {
Category category = new Category(existingCategory.getId(), existingCategory.getName(), existingCategory.getPrice());
List<Attendee> attendees = generateAttendees(attendeesIterator.next());
allAttendees.addAll(attendees);
return new TicketsInfo(category, attendees, addSeatsIfNotAvailable, false);
}).collect(toList());
AdminReservationModification modification = new AdminReservationModification(expiration, customerData, ticketsInfoList, "en", false, null);
if (reservedTickets > 0) {
TicketReservationModification trm = new TicketReservationModification();
trm.setAmount(reservedTickets);
trm.setTicketCategoryId(existingCategories.get(0).getId());
TicketReservationWithOptionalCodeModification r = new TicketReservationWithOptionalCodeModification(trm, Optional.empty());
ticketReservationManager.createTicketReservation(event, Collections.singletonList(r), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(), Locale.ENGLISH, false);
}
Result<Pair<TicketReservation, List<Ticket>>> result = adminReservationManager.createReservation(modification, event.getShortName(), username);
if (expectSuccess) {
validateSuccess(bounded, attendeesNr, event, username, existingCategories, result, allAttendees, expectedEventSeats, reservedTickets);
} else {
assertFalse(result.isSuccess());
return null;
}
return Triple.of(eventWithUsername.getLeft(), eventWithUsername.getRight(), result.getData().getKey());
}
Aggregations