use of alfio.model.modification.DateTimeModification in project alf.io by alfio-event.
the class WaitingQueueProcessorIntegrationTest method testPreRegistration.
@Test
public void testPreRegistration() {
List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()), new DateTimeModification(LocalDate.now().plusDays(2), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null));
Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
Event event = pair.getKey();
waitingQueueManager.subscribe(event, new CustomerName("Giuseppe Garibaldi", "Giuseppe", "Garibaldi", event), "peppino@garibaldi.com", null, Locale.ENGLISH);
waitingQueueManager.subscribe(event, new CustomerName("Nino Bixio", "Nino", "Bixio", event), "bixio@mille.org", null, Locale.ITALIAN);
assertTrue(waitingQueueRepository.countWaitingPeople(event.getId()) == 2);
waitingQueueSubscriptionProcessor.distributeAvailableSeats(event);
assertEquals(18, ticketRepository.findFreeByEventId(event.getId()).size());
TicketCategoryModification tcm = new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now().minusDays(1), LocalTime.now()), new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null);
eventManager.insertCategory(event.getId(), tcm, pair.getValue());
waitingQueueSubscriptionProcessor.distributeAvailableSeats(event);
List<WaitingQueueSubscription> subscriptions = waitingQueueRepository.loadAll(event.getId());
assertEquals(2, subscriptions.stream().filter(w -> StringUtils.isNotBlank(w.getReservationId())).count());
assertTrue(subscriptions.stream().allMatch(w -> w.getStatus().equals(WaitingQueueSubscription.Status.PENDING)));
assertTrue(subscriptions.stream().allMatch(w -> w.getSubscriptionType().equals(WaitingQueueSubscription.Type.PRE_SALES)));
}
use of alfio.model.modification.DateTimeModification in project alf.io by alfio-event.
the class Validator method validateAdditionalService.
public static ValidationResult validateAdditionalService(EventModification.AdditionalService additionalService, EventModification eventModification, Errors errors) {
if (additionalService.isFixPrice() && !Optional.ofNullable(additionalService.getPrice()).filter(p -> p.compareTo(BigDecimal.ZERO) >= 0).isPresent()) {
errors.rejectValue("additionalServices", "error.price");
}
List<EventModification.AdditionalServiceText> descriptions = additionalService.getDescription();
List<EventModification.AdditionalServiceText> titles = additionalService.getTitle();
if (descriptions == null || titles == null || titles.size() != descriptions.size()) {
errors.rejectValue("additionalServices", "error.title");
errors.rejectValue("additionalServices", "error.description");
} else {
if (!validateDescriptionList(titles) || !containsAllRequiredTranslations(eventModification, titles)) {
errors.rejectValue("additionalServices", "error.title");
}
if (!validateDescriptionList(descriptions) || !containsAllRequiredTranslations(eventModification, descriptions)) {
errors.rejectValue("additionalServices", "error.description");
}
}
DateTimeModification inception = additionalService.getInception();
DateTimeModification expiration = additionalService.getExpiration();
if (inception == null || expiration == null || expiration.isBefore(inception)) {
errors.rejectValue("additionalServices", "error.inception");
errors.rejectValue("additionalServices", "error.expiration");
} else if (eventModification != null && expiration.isAfter(eventModification.getEnd())) {
errors.rejectValue("additionalServices", "error.expiration");
}
return evaluateValidationResult(errors);
}
use of alfio.model.modification.DateTimeModification in project alf.io by alfio-event.
the class ReservationFlowIntegrationTest method ensureConfiguration.
@Before
public void ensureConfiguration() {
IntegrationTestUtil.ensureMinimalConfiguration(configurationRepository);
List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now().minusDays(1), LocalTime.now()), new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null));
Pair<Event, String> eventAndUser = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
event = eventAndUser.getKey();
user = eventAndUser.getValue() + "_owner";
//
TemplateManager templateManager = Mockito.mock(TemplateManager.class);
reservationApiController = new ReservationApiController(eventRepository, ticketHelper, templateManager, i18nManager, euVatChecker, ticketReservationRepository, ticketReservationManager);
}
Aggregations