use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.
the class TicketReservationManagerTest method confirmPaidReservationButDoNotSendEmail.
@Test
void confirmPaidReservationButDoNotSendEmail() {
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, new ConfigurationKeyValuePathLevel(null, "false", null)));
when(configurationManager.getFor(eq(BANKING_KEY), any())).thenReturn(BANKING_INFO);
mockBillingDocument();
testPaidReservation(true, true);
verify(notificationManager, never()).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 considerZoneIdWhileChecking.
@Test
void considerZoneIdWhileChecking() {
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.getStringConfigValue(any())).thenReturn(Optional.empty());
when(reservation.latestNotificationTimestamp(any())).thenReturn(Optional.empty());
when(reservation.getId()).thenReturn("abcd");
when(reservation.getUserLanguage()).thenReturn("en");
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(configurationManager.getFor(eq(BANKING_KEY), any())).thenReturn(BANKING_INFO);
when(eventRepository.findByReservationId("abcd")).thenReturn(event);
var zoneClock = Clock.offset(ClockProvider.clock(), Duration.ofHours(4).negated());
when(event.getZoneId()).thenReturn(zoneClock.getZone());
when(event.getBegin()).thenReturn(ZonedDateTime.now(zoneClock.getZone()).plusDays(1));
when(eventRepository.findAll()).thenReturn(singletonList(event));
when(ticketRepository.findAllReservationsConfirmedButNotAssignedForUpdate(anyInt())).thenReturn(singleton("abcd"));
when(reservation.getEmail()).thenReturn("ciccio");
trm.sendReminderForTicketAssignment();
verify(notificationManager, times(1)).sendSimpleEmail(eq(event), eq("abcd"), anyString(), anyString(), any(TemplateGenerator.class));
}
use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.
the class TicketReservationManagerTest method handleOnSitePaymentMethod.
@Test
void handleOnSitePaymentMethod() {
when(ticketReservationRepository.findOptionalStatusAndValidationById(eq(RESERVATION_ID))).thenReturn(Optional.of(new TicketReservationStatusAndValidation(PENDING, true)));
initConfirmReservation();
when(ticketRepository.updateTicketsStatusWithReservationId(eq(RESERVATION_ID), eq(TicketStatus.TO_BE_PAID.toString()))).thenReturn(1);
when(ticketReservationRepository.updateTicketReservation(eq(RESERVATION_ID), eq(COMPLETE.toString()), anyString(), anyString(), isNull(), isNull(), anyString(), anyString(), any(ZonedDateTime.class), eq(PaymentProxy.ON_SITE.toString()), isNull())).thenReturn(1);
when(ticketReservationRepository.findOptionalReservationById(eq(RESERVATION_ID))).thenReturn(Optional.of(ticketReservation));
when(configurationManager.getFor(eq(ENABLE_TICKET_TRANSFER), any())).thenReturn(new MaybeConfiguration(ENABLE_TICKET_TRANSFER));
when(configurationManager.getFor(eq(BANKING_KEY), any())).thenReturn(BANKING_INFO);
OnSiteManager onSiteManager = mock(OnSiteManager.class);
when(onSiteManager.accept(eq(PaymentMethod.ON_SITE), any(), any())).thenReturn(true);
when(paymentManager.streamActiveProvidersByProxy(eq(PaymentProxy.ON_SITE), any())).thenReturn(Stream.of(onSiteManager));
when(ticketReservation.getPromoCodeDiscountId()).thenReturn(null);
when(onSiteManager.getTokenAndPay(any())).thenReturn(PaymentResult.successful(TicketReservationManager.NOT_YET_PAID_TRANSACTION_ID));
PaymentSpecification spec = new PaymentSpecification(RESERVATION_ID, new StripeCreditCardToken(GATEWAY_TOKEN), 100, event, "test@email", new CustomerName("Full Name", null, null, event.mustUseFirstAndLastName()), "", null, Locale.ENGLISH, true, false, null, "IT", "123456", PriceContainer.VatStatus.INCLUDED, true, false);
when(ticketReservationRepository.updateTicketReservation(eq(RESERVATION_ID), anyString(), anyString(), anyString(), isNull(), isNull(), eq(Locale.ENGLISH.getLanguage()), isNull(), any(), any(), isNull())).thenReturn(1);
PaymentResult result = trm.performPayment(spec, new TotalPrice(100, 0, 0, 0, "CHF"), PaymentProxy.ON_SITE, PaymentMethod.ON_SITE, null);
Assertions.assertTrue(result.isSuccessful());
Assertions.assertEquals(Optional.of(TicketReservationManager.NOT_YET_PAID_TRANSACTION_ID), result.getGatewayId());
verify(ticketReservationRepository).updateTicketReservation(eq(RESERVATION_ID), eq(TicketReservationStatus.COMPLETE.toString()), anyString(), anyString(), isNull(), isNull(), anyString(), anyString(), any(), eq(PaymentProxy.ON_SITE.toString()), isNull());
verify(ticketReservationRepository).findReservationByIdForUpdate(eq(RESERVATION_ID));
verify(ticketRepository).updateTicketsStatusWithReservationId(eq(RESERVATION_ID), eq(TicketStatus.TO_BE_PAID.toString()));
verify(specialPriceRepository).updateStatusForReservation(eq(singletonList(RESERVATION_ID)), eq(SpecialPrice.Status.TAKEN.toString()));
verify(waitingQueueManager).fireReservationConfirmed(eq(RESERVATION_ID));
verify(ticketReservationRepository, atLeastOnce()).findReservationById(RESERVATION_ID);
verify(billingDocumentManager).generateInvoiceNumber(eq(spec), any());
verify(ticketReservationRepository).updateBillingData(eq(PriceContainer.VatStatus.INCLUDED), eq(100), eq(100), eq(0), eq(0), eq(EVENT_CURRENCY), eq("123456"), eq("IT"), eq(true), eq(RESERVATION_ID));
verify(ticketRepository, atLeastOnce()).findTicketsInReservation(anyString());
}
use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.
the class TicketReservationManagerTest method testValidatePaymentMethodsReservationFreeOfCharge.
@Test
void testValidatePaymentMethodsReservationFreeOfCharge() {
when(totalPrice.requiresPayment()).thenReturn(false);
when(configurationManager.getFor(eq(RESERVATION_TIMEOUT), any())).thenReturn(new MaybeConfiguration(RESERVATION_TIMEOUT));
when(ticketRepository.getCategoriesIdToPayInReservation(RESERVATION_ID)).thenReturn(List.of(1));
when(configurationManager.getBlacklistedMethodsForReservation(eq(event), any())).thenReturn(Arrays.asList(PaymentMethod.values()));
when(paymentManager.getPaymentMethods(eq(event), any())).thenReturn(Arrays.stream(PaymentProxy.values()).map(pp -> new PaymentMethodDTO(pp, pp.getPaymentMethod(), PaymentMethodStatus.ACTIVE)).collect(Collectors.toList()));
Assertions.assertTrue(trm.canProceedWithPayment(event, totalPrice, RESERVATION_ID));
}
use of alfio.manager.system.ConfigurationManager.MaybeConfiguration in project alf.io by alfio-event.
the class TicketReservationManagerTest method doNotSendAssignmentReminderAfterEventEnd.
@Test
void doNotSendAssignmentReminderAfterEventEnd() {
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(ClockProvider.clock().getZone());
when(event.getBegin()).thenReturn(ZonedDateTime.now(ClockProvider.clock()).minusDays(1));
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));
}
Aggregations