Search in sources :

Example 46 with Event

use of alfio.model.Event in project alf.io by alfio-event.

the class EventManagerIntegrationTest method testEventGeneration.

@Test
public void testEventGeneration() {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null));
    Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository).getKey();
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertNotNull(tickets);
    assertFalse(tickets.isEmpty());
    assertEquals(AVAILABLE_SEATS, tickets.size());
    assertEquals(10, tickets.stream().filter(t -> t.getCategoryId() == null).count());
}
Also used : Ticket(alfio.model.Ticket) Event(alfio.model.Event) Test(org.junit.Test)

Example 47 with Event

use of alfio.model.Event in project alf.io by alfio-event.

the class EventManagerIntegrationTest method testUnboundedEventGeneration.

@Test
public void testUnboundedEventGeneration() {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null));
    Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository).getKey();
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertNotNull(tickets);
    assertFalse(tickets.isEmpty());
    assertEquals(AVAILABLE_SEATS, tickets.size());
    assertEquals(AVAILABLE_SEATS, tickets.stream().filter(t -> t.getCategoryId() == null).count());
    List<TicketCategory> ticketCategories = ticketCategoryRepository.findByEventId(event.getId());
    assertEquals(1, ticketCategories.size());
    assertEquals(0, ticketCategories.get(0).getMaxTickets());
}
Also used : Ticket(alfio.model.Ticket) Event(alfio.model.Event) TicketCategory(alfio.model.TicketCategory) Test(org.junit.Test)

Example 48 with Event

use of alfio.model.Event in project alf.io by alfio-event.

the class EventManagerIntegrationTest method testValidationBoundedFailedRestrictedFlag.

@Test
public void testValidationBoundedFailedRestrictedFlag() {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, true, "", true, null, null, null, null, null));
    Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
    Event event = pair.getLeft();
    String username = pair.getRight();
    TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0);
    Map<String, String> categoryDescription = ticketCategoryDescriptionRepository.descriptionForTicketCategory(category.getId());
    TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 10, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), true, "", false, null, null, null, null, null);
    Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username);
    assertFalse(result.isSuccess());
}
Also used : Event(alfio.model.Event) TicketCategory(alfio.model.TicketCategory) Test(org.junit.Test)

Example 49 with Event

use of alfio.model.Event in project alf.io by alfio-event.

the class EventManagerIntegrationTest method testDecreaseRestrictedCategory.

@Test
public void testDecreaseRestrictedCategory() {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, true, "", true, null, null, null, null, null));
    Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
    Event event = pair.getLeft();
    String username = pair.getRight();
    TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0);
    Map<String, String> categoryDescription = ticketCategoryDescriptionRepository.descriptionForTicketCategory(category.getId());
    TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 9, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), true, "", true, null, null, null, null, null);
    Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username);
    assertTrue(result.isSuccess());
    assertEquals(9, ticketRepository.countFreeTickets(event.getId(), category.getId()).intValue());
    assertEquals(1, ticketRepository.countReleasedUnboundedTickets(event.getId()).intValue());
}
Also used : Event(alfio.model.Event) TicketCategory(alfio.model.TicketCategory) Test(org.junit.Test)

Example 50 with Event

use of alfio.model.Event in project alf.io by alfio-event.

the class EventManagerIntegrationTest method testIncreaseEventSeatsWithABoundedCategory.

@Test
public void testIncreaseEventSeatsWithABoundedCategory() {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null));
    Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
    Event event = pair.getKey();
    EventModification update = new EventModification(event.getId(), Event.EventType.INTERNAL, null, null, null, null, null, null, null, event.getOrganizationId(), null, "0.0", "0.0", ZoneId.systemDefault().getId(), null, DateTimeModification.fromZonedDateTime(event.getBegin()), DateTimeModification.fromZonedDateTime(event.getEnd()), event.getRegularPrice(), event.getCurrency(), 40, event.getVat(), event.isVatIncluded(), event.getAllowedPaymentProxies(), null, event.isFreeOfCharge(), null, 7, null, null);
    eventManager.updateEventPrices(event, update, pair.getValue());
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertNotNull(tickets);
    assertFalse(tickets.isEmpty());
    assertEquals(20, tickets.size());
    assertEquals(20, ticketRepository.countReleasedUnboundedTickets(event.getId()).intValue());
    assertEquals(10, tickets.stream().filter(t -> t.getCategoryId() != null).count());
}
Also used : Ticket(alfio.model.Ticket) Event(alfio.model.Event) Test(org.junit.Test)

Aggregations

Event (alfio.model.Event)71 Test (org.junit.Test)28 Ticket (alfio.model.Ticket)24 TicketCategory (alfio.model.TicketCategory)21 Organization (alfio.model.user.Organization)13 java.util (java.util)11 ZonedDateTime (java.time.ZonedDateTime)10 Autowired (org.springframework.beans.factory.annotation.Autowired)10 BigDecimal (java.math.BigDecimal)9 TicketReservation (alfio.model.TicketReservation)7 ConfigurationKeys (alfio.model.system.ConfigurationKeys)7 Collectors (java.util.stream.Collectors)7 Log4j2 (lombok.extern.log4j.Log4j2)7 StringUtils (org.apache.commons.lang3.StringUtils)7 ConfigurationManager (alfio.manager.system.ConfigurationManager)6 Configuration (alfio.model.system.Configuration)5 TicketRepository (alfio.repository.TicketRepository)5 Pair (org.apache.commons.lang3.tuple.Pair)5 Triple (org.apache.commons.lang3.tuple.Triple)5 UserManager (alfio.manager.user.UserManager)4