use of alfio.model.system.ConfigurationKeyValuePathLevel in project alf.io by alfio-event.
the class WaitingQueueSubscriptionProcessorTest method processPendingTickets.
@Test
void processPendingTickets() {
when(configurationManager.getFor(eq(Set.of(ENABLE_WAITING_QUEUE, ENABLE_PRE_REGISTRATION)), any())).thenReturn(Map.of(ENABLE_WAITING_QUEUE, new ConfigurationManager.MaybeConfiguration(ENABLE_WAITING_QUEUE, new ConfigurationKeyValuePathLevel("", "true", null)), ENABLE_PRE_REGISTRATION, new ConfigurationManager.MaybeConfiguration(ENABLE_PRE_REGISTRATION)));
when(messageSource.getMessage(anyString(), any(), eq(Locale.ENGLISH))).thenReturn("subject");
when(subscription.getLocale()).thenReturn(Locale.ENGLISH);
when(subscription.getEmailAddress()).thenReturn("me");
ZonedDateTime expiration = ZonedDateTime.now(clockProvider().getClock()).plusDays(1);
when(waitingQueueManager.distributeSeats(eq(event))).thenReturn(Stream.of(Triple.of(subscription, reservation, expiration)));
String reservationId = "reservation-id";
when(ticketReservationManager.createTicketReservation(eq(event), anyList(), anyList(), any(Date.class), eq(Optional.empty()), any(Locale.class), eq(true), isNull())).thenReturn(reservationId);
processor.handleWaitingTickets();
verify(ticketReservationManager).createTicketReservation(eq(event), eq(Collections.singletonList(reservation)), anyList(), eq(Date.from(expiration.toInstant())), eq(Optional.empty()), eq(Locale.ENGLISH), eq(true), isNull());
verify(notificationManager).sendSimpleEmail(eq(event), eq(reservationId), eq("me"), eq("subject"), any(TemplateGenerator.class));
}
use of alfio.model.system.ConfigurationKeyValuePathLevel in project alf.io by alfio-event.
the class CheckInManagerTest method getStatisticsDisabled.
@Test
void getStatisticsDisabled() {
when(configurationManager.getFor(eq(CHECK_IN_STATS), any(ConfigurationLevel.class))).thenReturn(new ConfigurationManager.MaybeConfiguration(CHECK_IN_STATS, new ConfigurationKeyValuePathLevel(null, "false", null)));
CheckInStatistics statistics = checkInManager.getStatistics(EVENT_NAME, USERNAME);
assertNull(statistics);
verify(eventRepository, never()).retrieveCheckInStatisticsForEvent(EVENT_ID);
}
use of alfio.model.system.ConfigurationKeyValuePathLevel in project alf.io by alfio-event.
the class WaitingQueueManagerTest method processPreReservations.
@Test
void processPreReservations() {
Ticket ticket = mock(Ticket.class);
WaitingQueueSubscription subscription = mock(WaitingQueueSubscription.class);
when(subscription.isPreSales()).thenReturn(true);
when(eventRepository.countExistingTickets(eq(eventId))).thenReturn(10);
when(event.getZoneId()).thenReturn(ZoneId.systemDefault());
when(waitingQueueRepository.countWaitingPeople(eq(eventId))).thenReturn(1);
when(ticketRepository.countWaiting(eq(eventId))).thenReturn(0);
when(configurationManager.getFor(eq(ENABLE_PRE_REGISTRATION), any())).thenReturn(new ConfigurationManager.MaybeConfiguration(ENABLE_PRE_REGISTRATION, new ConfigurationKeyValuePathLevel(null, "true", null)));
when(configurationManager.getFor(eq(WAITING_QUEUE_RESERVATION_TIMEOUT), any())).thenReturn(new ConfigurationManager.MaybeConfiguration(WAITING_QUEUE_RESERVATION_TIMEOUT));
when(ticketRepository.selectWaitingTicketsForUpdate(eventId, Ticket.TicketStatus.PRE_RESERVED.name(), 1)).thenReturn(Collections.singletonList(ticket));
when(waitingQueueRepository.loadAllWaitingForUpdate(eventId)).thenReturn(Collections.singletonList(subscription));
when(waitingQueueRepository.loadWaiting(eventId, 1)).thenReturn(Collections.singletonList(subscription));
Stream<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> stream = manager.distributeSeats(event);
assertEquals(1L, stream.count());
verify(waitingQueueRepository).loadAllWaitingForUpdate(eq(eventId));
verify(waitingQueueRepository).loadWaiting(eq(eventId), eq(1));
verify(ticketRepository).countWaiting(eq(eventId));
verify(ticketRepository, never()).revertToFree(eq(eventId));
verify(ticketRepository).countPreReservedTickets(eq(eventId));
verify(ticketRepository).preReserveTicket(anyList());
verify(ticketRepository).selectWaitingTicketsForUpdate(eq(eventId), anyString(), anyInt());
}
use of alfio.model.system.ConfigurationKeyValuePathLevel in project alf.io by alfio-event.
the class DeferredBankTransferManagerTest method acceptPaymentRequest.
@Test
void acceptPaymentRequest() {
var paymentContext = new PaymentContext(event);
when(bankTransferManager.options(paymentContext)).thenReturn(Map.of(DEFERRED_BANK_TRANSFER_ENABLED, new MaybeConfiguration(DEFERRED_BANK_TRANSFER_ENABLED, new ConfigurationKeyValuePathLevel(DEFERRED_BANK_TRANSFER_ENABLED.name(), "true", null))));
when(bankTransferManager.bankTransferEnabledForMethod(any(), eq(paymentContext), anyMap())).thenReturn(true);
when(bankTransferManager.isPaymentDeferredEnabled(anyMap())).thenCallRealMethod();
assertTrue(deferredBankTransferManager.accept(PaymentMethod.BANK_TRANSFER, paymentContext, TransactionRequest.empty()));
assertFalse(deferredBankTransferManager.accept(PaymentMethod.BANK_TRANSFER, new PaymentContext(), TransactionRequest.empty()));
}
Aggregations