Search in sources :

Example 6 with DateTimeModification

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)));
}
Also used : java.util(java.util) BeforeClass(org.junit.BeforeClass) WaitingQueueRepository(alfio.repository.WaitingQueueRepository) TicketReservationRepository(alfio.repository.TicketReservationRepository) RunWith(org.junit.runner.RunWith) Autowired(org.springframework.beans.factory.annotation.Autowired) ActiveProfiles(org.springframework.test.context.ActiveProfiles) ConfigurationManager(alfio.manager.system.ConfigurationManager) EventModification(alfio.model.modification.EventModification) StringUtils(org.apache.commons.lang3.StringUtils) DateTimeModification(alfio.model.modification.DateTimeModification) RepositoryConfiguration(alfio.config.RepositoryConfiguration) BigDecimal(java.math.BigDecimal) SpringJUnit4ClassRunner(org.springframework.test.context.junit4.SpringJUnit4ClassRunner) Pair(org.apache.commons.lang3.tuple.Pair) LocalTime(java.time.LocalTime) AuthorityRepository(alfio.repository.user.AuthorityRepository) Before(org.junit.Before) DateTimeModification.fromZonedDateTime(alfio.model.modification.DateTimeModification.fromZonedDateTime) Collections.emptyMap(java.util.Collections.emptyMap) OrganizationRepository(alfio.repository.user.OrganizationRepository) TicketCategoryModification(alfio.model.modification.TicketCategoryModification) TicketRepository(alfio.repository.TicketRepository) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) EventRepository(alfio.repository.EventRepository) IntegrationTestUtil(alfio.test.util.IntegrationTestUtil) ConfigurationRepository(alfio.repository.system.ConfigurationRepository) DateUtils(org.apache.commons.lang3.time.DateUtils) Initializer(alfio.config.Initializer) alfio.model(alfio.model) UserRepository(alfio.repository.user.UserRepository) UserManager(alfio.manager.user.UserManager) ContextConfiguration(org.springframework.test.context.ContextConfiguration) LocalDate(java.time.LocalDate) DataSourceConfiguration(alfio.config.DataSourceConfiguration) TestConfiguration(alfio.TestConfiguration) ConfigurationKeys(alfio.model.system.ConfigurationKeys) Assert.assertEquals(org.junit.Assert.assertEquals) Transactional(org.springframework.transaction.annotation.Transactional) DateTimeModification(alfio.model.modification.DateTimeModification) TicketCategoryModification(alfio.model.modification.TicketCategoryModification) Test(org.junit.Test)

Example 7 with DateTimeModification

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);
}
Also used : ValidationResult(alfio.model.result.ValidationResult) Errors(org.springframework.validation.Errors) TicketCategoryModification(alfio.model.modification.TicketCategoryModification) WaitingQueueSubscriptionForm(alfio.controller.form.WaitingQueueSubscriptionForm) Collection(java.util.Collection) UpdateTicketOwnerForm(alfio.controller.form.UpdateTicketOwnerForm) ContentLanguage(alfio.model.ContentLanguage) EventModification(alfio.model.modification.EventModification) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) DateTimeModification(alfio.model.modification.DateTimeModification) BigDecimal(java.math.BigDecimal) List(java.util.List) ErrorCode(alfio.model.result.ErrorCode) ValidationUtils(org.springframework.validation.ValidationUtils) CollectionUtils(org.apache.commons.collections.CollectionUtils) TicketFieldConfiguration(alfio.model.TicketFieldConfiguration) Optional(java.util.Optional) Event(alfio.model.Event) Pattern(java.util.regex.Pattern) DateTimeModification(alfio.model.modification.DateTimeModification)

Example 8 with DateTimeModification

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);
}
Also used : DateTimeModification(alfio.model.modification.DateTimeModification) TicketCategoryModification(alfio.model.modification.TicketCategoryModification) TemplateManager(alfio.util.TemplateManager) ReservationApiController(alfio.controller.api.ReservationApiController) Before(org.junit.Before)

Aggregations

DateTimeModification (alfio.model.modification.DateTimeModification)8 TicketCategoryModification (alfio.model.modification.TicketCategoryModification)7 EventModification (alfio.model.modification.EventModification)5 Before (org.junit.Before)5 Event (alfio.model.Event)3 BigDecimal (java.math.BigDecimal)3 StringUtils (org.apache.commons.lang3.StringUtils)3 TestConfiguration (alfio.TestConfiguration)2 DataSourceConfiguration (alfio.config.DataSourceConfiguration)2 Initializer (alfio.config.Initializer)2 RepositoryConfiguration (alfio.config.RepositoryConfiguration)2 ConfigurationManager (alfio.manager.system.ConfigurationManager)2 UserManager (alfio.manager.user.UserManager)2 alfio.model (alfio.model)2 DateTimeModification.fromZonedDateTime (alfio.model.modification.DateTimeModification.fromZonedDateTime)2 LocationDescriptor (alfio.model.modification.support.LocationDescriptor)2 ConfigurationKeys (alfio.model.system.ConfigurationKeys)2 Organization (alfio.model.user.Organization)2 EventRepository (alfio.repository.EventRepository)2 TicketRepository (alfio.repository.TicketRepository)2