use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.
the class TicketReservationManagerTest method sendAssignmentReminderBeforeEventEnd.
@Test
void sendAssignmentReminderBeforeEventEnd() {
TicketReservation reservation = mock(TicketReservation.class);
when(configurationManager.getFor(eq(ASSIGNMENT_REMINDER_START), any())).thenReturn(new MaybeConfiguration(ASSIGNMENT_REMINDER_START));
when(configurationManager.getFor(eq(ASSIGNMENT_REMINDER_INTERVAL), any())).thenReturn(new MaybeConfiguration(ASSIGNMENT_REMINDER_INTERVAL));
// when(configurationManager.getForSystem(any())).thenReturn(Optional.empty());
when(configurationManager.getFor(eq(BANKING_KEY), any())).thenReturn(BANKING_INFO);
when(reservation.latestNotificationTimestamp(any())).thenReturn(Optional.empty());
when(reservation.getId()).thenReturn("abcd");
when(reservation.getUserLanguage()).thenReturn("en");
when(reservation.getEmail()).thenReturn("ciccio");
when(reservation.getValidity()).thenReturn(new Date(Instant.now(ClockProvider.clock()).getEpochSecond()));
when(ticketReservationRepository.findReservationById(eq("abcd"))).thenReturn(reservation);
when(ticketReservationRepository.findOptionalReservationById(eq("abcd"))).thenReturn(Optional.of(reservation));
when(eventRepository.findByReservationId("abcd")).thenReturn(event);
when(eventRepository.findAll()).thenReturn(singletonList(event));
when(ticketRepository.findAllReservationsConfirmedButNotAssignedForUpdate(anyInt())).thenReturn(singleton("abcd"));
trm.sendReminderForTicketAssignment();
verify(notificationManager, times(1)).sendSimpleEmail(eq(event), eq("abcd"), eq("ciccio"), anyString(), any(TemplateGenerator.class));
}
use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.
the class StripeWebhookPaymentManagerTest method stripeConfigurationIncompletePlatformModeOff.
@Test
void stripeConfigurationIncompletePlatformModeOff() {
var configuration = new HashMap<>(completeStripeConfiguration(true));
// missing config
configuration.put(STRIPE_CONNECTED_ID, new MaybeConfiguration(STRIPE_CONNECTED_ID));
configuration.put(PLATFORM_MODE_ENABLED, new MaybeConfiguration(PLATFORM_MODE_ENABLED));
configuration.put(STRIPE_WEBHOOK_PAYMENT_KEY, new MaybeConfiguration(STRIPE_WEBHOOK_PAYMENT_KEY));
var configurationLevel = ConfigurationLevel.organization(1);
when(configurationManager.getFor(EnumSet.of(STRIPE_ENABLE_SCA, BASE_URL, STRIPE_WEBHOOK_PAYMENT_KEY, STRIPE_CC_ENABLED, PLATFORM_MODE_ENABLED, STRIPE_CONNECTED_ID), configurationLevel)).thenReturn(configuration);
assertFalse(stripeWebhookPaymentManager.accept(PaymentMethod.CREDIT_CARD, new PaymentContext(null, configurationLevel), TransactionRequest.empty()));
}
use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.
the class StripeWebhookPaymentManagerTest method doNotConsiderConnectedIdIfConfigurationLevelIsSystem.
@Test
void doNotConsiderConnectedIdIfConfigurationLevelIsSystem() {
var configuration = new HashMap<>(completeStripeConfiguration(true));
// missing config
configuration.put(STRIPE_CONNECTED_ID, new MaybeConfiguration(STRIPE_CONNECTED_ID));
var configurationLevel = ConfigurationLevel.system();
when(configurationManager.getFor(EnumSet.of(STRIPE_ENABLE_SCA, BASE_URL, STRIPE_WEBHOOK_PAYMENT_KEY, STRIPE_CC_ENABLED, PLATFORM_MODE_ENABLED, STRIPE_CONNECTED_ID), configurationLevel)).thenReturn(configuration);
assertTrue(stripeWebhookPaymentManager.accept(PaymentMethod.CREDIT_CARD, new PaymentContext(null, configurationLevel), TransactionRequest.empty()));
}
use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.
the class TicketReservationManagerTest method considerZoneIdWhileCheckingExpired.
@Test
void considerZoneIdWhileCheckingExpired() {
TicketReservation reservation = mock(TicketReservation.class);
when(configurationManager.getFor(eq(ASSIGNMENT_REMINDER_START), any())).thenReturn(new MaybeConfiguration(ASSIGNMENT_REMINDER_START));
// when(configurationManager.getStringConfigValue(any())).thenReturn(Optional.empty());
when(reservation.latestNotificationTimestamp(any())).thenReturn(Optional.empty());
when(reservation.getId()).thenReturn("abcd");
when(ticketReservationRepository.findReservationById(eq("abcd"))).thenReturn(reservation);
when(eventRepository.findByReservationId("abcd")).thenReturn(event);
when(event.getZoneId()).thenReturn(ZoneId.of("UTC-8"));
// same day
when(event.getBegin()).thenReturn(ZonedDateTime.now(ZoneId.of("UTC-8")));
when(eventRepository.findAll()).thenReturn(singletonList(event));
when(ticketRepository.findAllReservationsConfirmedButNotAssignedForUpdate(anyInt())).thenReturn(singleton("abcd"));
trm.sendReminderForTicketAssignment();
verify(notificationManager, never()).sendSimpleEmail(eq(event), anyString(), anyString(), anyString(), any(TemplateGenerator.class));
}
use of alfio.manager.system.ConfigurationManager.MaybeConfiguration 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