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());
}
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);
}
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));
}
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);
}
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());
}
Aggregations