Search in sources :

Example 11 with ConfigurationKeyValuePathLevel

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));
}
Also used : TemplateGenerator(alfio.manager.support.TemplateGenerator) ZonedDateTime(java.time.ZonedDateTime) ConfigurationKeyValuePathLevel(alfio.model.system.ConfigurationKeyValuePathLevel) Test(org.junit.jupiter.api.Test)

Example 12 with ConfigurationKeyValuePathLevel

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);
}
Also used : ConfigurationLevel(alfio.manager.system.ConfigurationLevel) CheckInStatistics(alfio.manager.support.CheckInStatistics) ConfigurationManager(alfio.manager.system.ConfigurationManager) ConfigurationKeyValuePathLevel(alfio.model.system.ConfigurationKeyValuePathLevel) Test(org.junit.jupiter.api.Test)

Example 13 with ConfigurationKeyValuePathLevel

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());
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) Ticket(alfio.model.Ticket) ConfigurationManager(alfio.manager.system.ConfigurationManager) WaitingQueueSubscription(alfio.model.WaitingQueueSubscription) ConfigurationKeyValuePathLevel(alfio.model.system.ConfigurationKeyValuePathLevel) Test(org.junit.jupiter.api.Test)

Example 14 with ConfigurationKeyValuePathLevel

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()));
}
Also used : ConfigurationKeyValuePathLevel(alfio.model.system.ConfigurationKeyValuePathLevel) MaybeConfiguration(alfio.manager.system.ConfigurationManager.MaybeConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationKeyValuePathLevel (alfio.model.system.ConfigurationKeyValuePathLevel)14 Test (org.junit.jupiter.api.Test)9 MaybeConfiguration (alfio.manager.system.ConfigurationManager.MaybeConfiguration)7 ConfigurationManager (alfio.manager.system.ConfigurationManager)6 BeforeEach (org.junit.jupiter.api.BeforeEach)3 CheckInStatistics (alfio.manager.support.CheckInStatistics)2 ConfigurationLevel (alfio.manager.system.ConfigurationLevel)2 EventAndOrganizationId (alfio.model.EventAndOrganizationId)2 Organization (alfio.model.user.Organization)2 MessageSourceManager (alfio.manager.i18n.MessageSourceManager)1 AdminOpenIdAuthenticationManager (alfio.manager.openid.AdminOpenIdAuthenticationManager)1 PaymentResult (alfio.manager.support.PaymentResult)1 TemplateGenerator (alfio.manager.support.TemplateGenerator)1 Ticket (alfio.model.Ticket)1 WaitingQueueSubscription (alfio.model.WaitingQueueSubscription)1 TicketReservationWithOptionalCodeModification (alfio.model.modification.TicketReservationWithOptionalCodeModification)1 StripeCreditCardToken (alfio.model.transaction.token.StripeCreditCardToken)1 OrganizationRepository (alfio.repository.user.OrganizationRepository)1 UserRepository (alfio.repository.user.UserRepository)1 Json (alfio.util.Json)1