Search in sources :

Example 11 with MaybeConfiguration

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

Example 12 with MaybeConfiguration

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

Example 13 with MaybeConfiguration

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

Example 14 with MaybeConfiguration

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

Example 15 with MaybeConfiguration

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

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