use of alfio.manager.PaymentManager.PaymentMethodDTO in project alf.io by alfio-event.
the class TicketReservationManagerTest method testValidatePaymentMethodsAllBlacklisted.
@Test
void testValidatePaymentMethodsAllBlacklisted() {
when(totalPrice.requiresPayment()).thenReturn(true);
when(ticketRepository.getCategoriesIdToPayInReservation(RESERVATION_ID)).thenReturn(List.of(1));
when(configurationManager.getBlacklistedMethodsForReservation(eq(event), any())).thenReturn(new ArrayList<>(EnumSet.complementOf(EnumSet.of(PaymentMethod.NONE))));
when(paymentManager.getPaymentMethods(eq(event), any())).thenReturn(Arrays.stream(PaymentProxy.values()).map(pp -> new PaymentMethodDTO(pp, pp.getPaymentMethod(), PaymentMethodStatus.ACTIVE)).collect(Collectors.toList()));
Assertions.assertFalse(trm.canProceedWithPayment(event, totalPrice, RESERVATION_ID));
}
use of alfio.manager.PaymentManager.PaymentMethodDTO in project alf.io by alfio-event.
the class TicketReservationManagerTest method testValidatePaymentMethodsPartiallyAllowed.
@Test
void testValidatePaymentMethodsPartiallyAllowed() {
when(totalPrice.requiresPayment()).thenReturn(true);
when(ticketRepository.getCategoriesIdToPayInReservation(RESERVATION_ID)).thenReturn(List.of(1, 2));
when(configurationManager.getBlacklistedMethodsForReservation(eq(event), any())).thenReturn(List.of(PaymentMethod.CREDIT_CARD));
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.PaymentManager.PaymentMethodDTO 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.PaymentManager.PaymentMethodDTO in project alf.io by alfio-event.
the class TicketReservationManagerTest method testValidatePaymentMethodsPayPalError.
@Test
void testValidatePaymentMethodsPayPalError() {
when(totalPrice.requiresPayment()).thenReturn(true);
when(ticketRepository.getCategoriesIdToPayInReservation(RESERVATION_ID)).thenReturn(List.of(1));
when(configurationManager.getBlacklistedMethodsForReservation(eq(event), any())).thenReturn(new ArrayList<>(EnumSet.complementOf(EnumSet.of(PaymentMethod.PAYPAL, PaymentMethod.NONE))));
when(paymentManager.getPaymentMethods(eq(event), any())).thenReturn(Arrays.stream(PaymentProxy.values()).map(pp -> new PaymentMethodDTO(pp, pp.getPaymentMethod(), pp.getPaymentMethod() == PaymentMethod.PAYPAL ? PaymentMethodStatus.ERROR : PaymentMethodStatus.ACTIVE)).collect(Collectors.toList()));
Assertions.assertFalse(trm.canProceedWithPayment(event, totalPrice, RESERVATION_ID));
}
use of alfio.manager.PaymentManager.PaymentMethodDTO in project alf.io by alfio-event.
the class TicketReservationManagerTest method testValidatePaymentMethodsAllowed.
@Test
void testValidatePaymentMethodsAllowed() {
when(totalPrice.requiresPayment()).thenReturn(true);
when(ticketRepository.getCategoriesIdToPayInReservation(RESERVATION_ID)).thenReturn(List.of(1));
when(configurationManager.getBlacklistedMethodsForReservation(eq(event), any())).thenReturn(List.of());
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));
}
Aggregations