use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.
the class TicketReservationManagerTest method lockFailed.
@Test
void lockFailed() {
when(ticketRepository.forbidReassignment(any())).thenReturn(0);
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(userRepository.nullSafeFindIdByUserName(anyString())).thenReturn(Optional.empty());
when(json.asJsonString(any())).thenReturn("{}");
when(billingDocumentRepository.insert(eq(event.getId()), anyString(), anyString(), any(BillingDocument.Type.class), anyString(), any(ZonedDateTime.class), anyInt())).thenReturn(new AffectedRowCountAndKey<>(1, 1L));
testPaidReservation(false, false);
}
use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.
the class StripeWebhookPaymentManagerTest method stripeConfigurationIncompletePlatformModeOn.
@Test
void stripeConfigurationIncompletePlatformModeOn() {
var configuration = new HashMap<>(completeStripeConfiguration(true));
// missing config
configuration.put(STRIPE_CONNECTED_ID, new MaybeConfiguration(STRIPE_CONNECTED_ID));
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 stripeConfigurationCompletePlatformModeOff.
@Test
void stripeConfigurationCompletePlatformModeOff() {
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));
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);
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 FeeCalculatorTest method setUp.
@BeforeEach
void setUp() {
event = mock(EventAndOrganizationId.class);
configurationManager = mock(ConfigurationManager.class);
when(configurationManager.getFor(eq(PLATFORM_MODE_ENABLED), any())).thenReturn(new MaybeConfiguration(PLATFORM_MODE_ENABLED, new ConfigurationKeyValuePathLevel(PLATFORM_MODE_ENABLED.name(), "true", null)));
}
use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.
the class TicketReservationManagerTest method doNotSendReminderIfTicketHasAlreadyBeenModified.
@Test
void doNotSendReminderIfTicketHasAlreadyBeenModified() {
initReminder();
when(event.getId()).thenReturn(EVENT_ID);
when(configurationManager.getFor(eq(ASSIGNMENT_REMINDER_START), any())).thenReturn(new MaybeConfiguration(ASSIGNMENT_REMINDER_START));
// when(configurationManager.getStringConfigValue(any())).thenReturn(Optional.empty());
when(configurationManager.getFor(eq(OPTIONAL_DATA_REMINDER_ENABLED), any())).thenReturn(MaybeConfigurationBuilder.existing(OPTIONAL_DATA_REMINDER_ENABLED, "true"));
when(ticketReservation.latestNotificationTimestamp(any())).thenReturn(Optional.empty());
String RESERVATION_ID = "abcd";
when(ticketReservation.getId()).thenReturn(RESERVATION_ID);
when(ticket.getTicketsReservationId()).thenReturn(RESERVATION_ID);
int ticketId = 2;
when(ticket.getId()).thenReturn(ticketId);
when(ticketRepository.findAllAssignedButNotYetNotifiedForUpdate(EVENT_ID)).thenReturn(singletonList(ticket));
when(ticketReservationRepository.findReservationByIdForUpdate(eq(RESERVATION_ID))).thenReturn(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.flagTicketAsReminderSent(ticketId)).thenReturn(0);
trm.sendReminderForOptionalData();
verify(notificationManager, never()).sendSimpleEmail(eq(event), anyString(), anyString(), anyString(), any(TemplateGenerator.class));
}
Aggregations