Search in sources :

Example 16 with MaybeConfiguration

use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.

the class TicketReservationManagerTest method confirmPaidReservation.

@Test
void confirmPaidReservation() {
    when(ticketReservationRepository.findOptionalStatusAndValidationById(eq(RESERVATION_ID))).thenReturn(Optional.of(new TicketReservationStatusAndValidation(PENDING, true)));
    when(configurationManager.getFor(eq(ENABLE_TICKET_TRANSFER), any())).thenReturn(new MaybeConfiguration(ENABLE_TICKET_TRANSFER));
    when(configurationManager.getFor(eq(SEND_TICKETS_AUTOMATICALLY), any())).thenReturn(new MaybeConfiguration(SEND_TICKETS_AUTOMATICALLY));
    when(configurationManager.getFor(eq(BANKING_KEY), any())).thenReturn(BANKING_INFO);
    mockBillingDocument();
    testPaidReservation(true, true);
    verify(notificationManager).sendTicketByEmail(any(), any(), any(), any(), any(), any(), any());
}
Also used : MaybeConfiguration(alfio.manager.system.ConfigurationManager.MaybeConfiguration) Test(org.junit.jupiter.api.Test)

Example 17 with MaybeConfiguration

use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.

the class TicketReservationManagerTest method doNotCompleteReservationIfAlreadyCompleted.

@Test
void doNotCompleteReservationIfAlreadyCompleted() {
    when(auditingRepository.countAuditsOfTypeForReservation(eq(RESERVATION_ID), eq(PAYMENT_CONFIRMED))).thenReturn(1);
    when(ticketReservationRepository.findOptionalStatusAndValidationById(eq(RESERVATION_ID))).thenReturn(Optional.of(new TicketReservationStatusAndValidation(COMPLETE, true)));
    when(configurationManager.getFor(eq(SEND_TICKETS_AUTOMATICALLY), any())).thenReturn(new MaybeConfiguration(SEND_TICKETS_AUTOMATICALLY));
    when(configurationManager.getFor(eq(BANKING_KEY), any())).thenReturn(BANKING_INFO);
    when(ticketRepository.forbidReassignment(any())).thenReturn(1);
    mockBillingDocument();
    testPaidReservation(true, true, false);
}
Also used : MaybeConfiguration(alfio.manager.system.ConfigurationManager.MaybeConfiguration) Test(org.junit.jupiter.api.Test)

Example 18 with MaybeConfiguration

use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.

the class TicketReservationManagerTest method sendReminderOnlyIfNoPreviousNotifications.

@Test
void sendReminderOnlyIfNoPreviousNotifications() {
    initReminder();
    when(event.getId()).thenReturn(EVENT_ID);
    when(configurationManager.getFor(eq(ASSIGNMENT_REMINDER_START), any())).thenReturn(new MaybeConfiguration(ASSIGNMENT_REMINDER_START));
    when(ticketReservation.latestNotificationTimestamp(any())).thenReturn(Optional.empty());
    when(ticketReservation.getId()).thenReturn(RESERVATION_ID);
    when(ticket.getTicketsReservationId()).thenReturn(RESERVATION_ID);
    int ticketId = 2;
    when(ticket.getId()).thenReturn(ticketId);
    when(ticket.getUuid()).thenReturn("uuid");
    when(ticket.getEmail()).thenReturn("ciccio");
    when(ticketRepository.findAllAssignedButNotYetNotifiedForUpdate(EVENT_ID)).thenReturn(singletonList(ticket));
    when(ticketReservationRepository.findOptionalReservationById(eq(RESERVATION_ID))).thenReturn(Optional.of(ticketReservation));
    when(eventRepository.findByReservationId(RESERVATION_ID)).thenReturn(event);
    when(event.getZoneId()).thenReturn(ClockProvider.clock().getZone());
    when(event.getBegin()).thenReturn(ZonedDateTime.now(ClockProvider.clock()).plusDays(1));
    when(eventRepository.findAll()).thenReturn(singletonList(event));
    when(ticketRepository.findAllReservationsConfirmedButNotAssignedForUpdate(anyInt())).thenReturn(singleton(RESERVATION_ID));
    when(ticketRepository.flagTicketAsReminderSent(ticketId)).thenReturn(1);
    when(ticketRepository.findByUUID(anyString())).thenReturn(ticket);
    when(messageSource.getMessage(eq("reminder.ticket-additional-info.subject"), any(), any())).thenReturn("subject");
    when(configurationManager.getFor(eq(OPTIONAL_DATA_REMINDER_ENABLED), any())).thenReturn(MaybeConfigurationBuilder.existing(OPTIONAL_DATA_REMINDER_ENABLED, "true"));
    trm.sendReminderForOptionalData();
    verify(notificationManager, times(1)).sendSimpleEmail(eq(event), eq(RESERVATION_ID), eq("ciccio"), eq("subject"), any(TemplateGenerator.class));
}
Also used : TemplateGenerator(alfio.manager.support.TemplateGenerator) MaybeConfiguration(alfio.manager.system.ConfigurationManager.MaybeConfiguration) Test(org.junit.jupiter.api.Test)

Example 19 with MaybeConfiguration

use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.

the class TicketReservationManagerTest method confirmAndLockTickets.

@Test
void confirmAndLockTickets() {
    when(ticketReservationRepository.findOptionalStatusAndValidationById(eq(RESERVATION_ID))).thenReturn(Optional.of(new TicketReservationStatusAndValidation(PENDING, true)));
    when(configurationManager.getFor(eq(SEND_TICKETS_AUTOMATICALLY), any())).thenReturn(new MaybeConfiguration(SEND_TICKETS_AUTOMATICALLY));
    when(configurationManager.getFor(eq(BANKING_KEY), any())).thenReturn(BANKING_INFO);
    when(ticketRepository.forbidReassignment(any())).thenReturn(1);
    mockBillingDocument();
    testPaidReservation(true, true);
}
Also used : MaybeConfiguration(alfio.manager.system.ConfigurationManager.MaybeConfiguration) Test(org.junit.jupiter.api.Test)

Example 20 with MaybeConfiguration

use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.

the class TicketReservationManagerTest method initOfflinePaymentTest.

private void initOfflinePaymentTest() {
    when(configurationManager.getFor(eq(OFFLINE_PAYMENT_DAYS), any())).thenReturn(new MaybeConfiguration(OFFLINE_PAYMENT_DAYS, new ConfigurationKeyValuePathLevel(OFFLINE_PAYMENT_DAYS.getValue(), "2", null)));
    when(event.getZoneId()).thenReturn(ClockProvider.clock().getZone());
}
Also used : ConfigurationKeyValuePathLevel(alfio.model.system.ConfigurationKeyValuePathLevel) MaybeConfiguration(alfio.manager.system.ConfigurationManager.MaybeConfiguration)

Aggregations

MaybeConfiguration (alfio.manager.system.ConfigurationManager.MaybeConfiguration)25 Test (org.junit.jupiter.api.Test)21 TemplateGenerator (alfio.manager.support.TemplateGenerator)8 ConfigurationKeyValuePathLevel (alfio.model.system.ConfigurationKeyValuePathLevel)7 PaymentResult (alfio.manager.support.PaymentResult)2 ConfigurationManager (alfio.manager.system.ConfigurationManager)2 StripeCreditCardToken (alfio.model.transaction.token.StripeCreditCardToken)2 Organization (alfio.model.user.Organization)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 PaymentMethodDTO (alfio.manager.PaymentManager.PaymentMethodDTO)1 MessageSourceManager (alfio.manager.i18n.MessageSourceManager)1 EventAndOrganizationId (alfio.model.EventAndOrganizationId)1 TicketReservationWithOptionalCodeModification (alfio.model.modification.TicketReservationWithOptionalCodeModification)1 OrganizationRepository (alfio.repository.user.OrganizationRepository)1 UserRepository (alfio.repository.user.UserRepository)1 MessageSource (org.springframework.context.MessageSource)1 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)1 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)1