Search in sources :

Example 1 with CheckInStatistics

use of alfio.manager.support.CheckInStatistics in project alf.io by alfio-event.

the class CheckInManagerTest method getStatistics.

@Test
void getStatistics() {
    when(configurationManager.getFor(eq(CHECK_IN_STATS), any(ConfigurationLevel.class))).thenReturn(new ConfigurationManager.MaybeConfiguration(CHECK_IN_STATS, new ConfigurationKeyValuePathLevel(null, "true", null)));
    CheckInStatistics statistics = checkInManager.getStatistics(EVENT_NAME, USERNAME);
    assertNotNull(statistics);
    verify(eventRepository).retrieveCheckInStatisticsForEvent(EVENT_ID);
}
Also used : ConfigurationLevel(alfio.manager.system.ConfigurationLevel) CheckInStatistics(alfio.manager.support.CheckInStatistics) ConfigurationManager(alfio.manager.system.ConfigurationManager) ConfigurationKeyValuePathLevel(alfio.model.system.ConfigurationKeyValuePathLevel) Test(org.junit.jupiter.api.Test)

Example 2 with CheckInStatistics

use of alfio.manager.support.CheckInStatistics in project alf.io by alfio-event.

the class CheckInManagerTest method setUp.

@BeforeEach
public void setUp() {
    eventRepository = mock(EventRepository.class);
    configurationManager = mock(ConfigurationManager.class);
    OrganizationRepository organizationRepository = mock(OrganizationRepository.class);
    Event event = mock(Event.class);
    Organization organization = mock(Organization.class);
    ConfigurationLevel cl = ConfigurationLevel.event(event);
    when(event.getConfigurationLevel()).thenReturn(cl);
    when(eventRepository.findOptionalByShortName(EVENT_NAME)).thenReturn(Optional.of(event));
    when(event.getId()).thenReturn(EVENT_ID);
    when(event.getOrganizationId()).thenReturn(ORG_ID);
    when(organizationRepository.findOrganizationForUser(USERNAME, ORG_ID)).thenReturn(Optional.of(organization));
    when(organization.getId()).thenReturn(ORG_ID);
    when(eventRepository.retrieveCheckInStatisticsForEvent(EVENT_ID)).thenReturn(new CheckInStatistics(0, 0, new Date()));
    checkInManager = new CheckInManager(null, eventRepository, null, null, null, null, null, configurationManager, organizationRepository, null, null, null, null, null, TestUtil.clockProvider());
}
Also used : ConfigurationLevel(alfio.manager.system.ConfigurationLevel) Organization(alfio.model.user.Organization) Event(alfio.model.Event) EventRepository(alfio.repository.EventRepository) OrganizationRepository(alfio.repository.user.OrganizationRepository) CheckInStatistics(alfio.manager.support.CheckInStatistics) ConfigurationManager(alfio.manager.system.ConfigurationManager) Date(java.util.Date) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with CheckInStatistics

use of alfio.manager.support.CheckInStatistics in project alf.io by alfio-event.

the class EventRepositoryIntegrationTest method testCheckInStatistics.

@Test
public void testCheckInStatistics() {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", TicketCategory.TicketAccessType.INHERIT, 0, new DateTimeModification(LocalDate.now(ClockProvider.clock()), LocalTime.now(ClockProvider.clock())), new DateTimeModification(LocalDate.now(ClockProvider.clock()), LocalTime.now(ClockProvider.clock())), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null, 0, null, null, AlfioMetadata.empty()));
    Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
    Event event = pair.getKey();
    TicketCategoryModification tcm = new TicketCategoryModification(null, "default", TicketCategory.TicketAccessType.INHERIT, 10, new DateTimeModification(LocalDate.now(ClockProvider.clock()), LocalTime.now(ClockProvider.clock())), new DateTimeModification(LocalDate.now(ClockProvider.clock()), LocalTime.now(ClockProvider.clock())), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null, 0, null, null, AlfioMetadata.empty());
    Result<Integer> result = eventManager.insertCategory(event, tcm, pair.getValue());
    assertTrue(result.isSuccess());
    // initial state
    CheckInStatistics checkInStatistics = eventRepository.retrieveCheckInStatisticsForEvent(event.getId());
    assertEquals(0, checkInStatistics.getCheckedIn());
    assertEquals(0, checkInStatistics.getTotalAttendees());
    EventWithAdditionalInfo eventWithAdditionalInfo = eventStatisticsManager.getEventWithAdditionalInfo(event.getShortName(), pair.getRight());
    TicketCategoryWithAdditionalInfo firstCategory = eventWithAdditionalInfo.getTicketCategories().get(0);
    List<Integer> ids = ticketRepository.selectNotAllocatedTicketsForUpdate(event.getId(), 5, Collections.singletonList(TicketRepository.FREE));
    String reservationId = "12345678";
    ticketReservationRepository.createNewReservation(reservationId, ZonedDateTime.now(ClockProvider.clock()), DateUtils.addDays(new Date(), 1), null, "en", event.getId(), event.getVat(), event.isVatIncluded(), event.getCurrency(), event.getOrganizationId(), null);
    int reserved = ticketRepository.reserveTickets(reservationId, ids, firstCategory.getTicketCategory(), "it", event.getVatStatus(), i -> null);
    assertEquals(5, reserved);
    ticketRepository.updateTicketsStatusWithReservationId(reservationId, Ticket.TicketStatus.ACQUIRED.name());
    checkInStatistics = eventRepository.retrieveCheckInStatisticsForEvent(event.getId());
    // after buying 5 tickets we expect to have them in the total attendees
    assertEquals(0, checkInStatistics.getCheckedIn());
    assertEquals(5, checkInStatistics.getTotalAttendees());
    List<Ticket> ticketsInReservation = ticketRepository.findTicketsInReservation(reservationId);
    ticketRepository.updateTicketStatusWithUUID(ticketsInReservation.get(0).getUuid(), Ticket.TicketStatus.CHECKED_IN.name());
    checkInStatistics = eventRepository.retrieveCheckInStatisticsForEvent(event.getId());
    // checked in ticket must be taken into account
    assertEquals(1, checkInStatistics.getCheckedIn());
    assertEquals(5, checkInStatistics.getTotalAttendees());
}
Also used : Date(java.util.Date) LocalDate(java.time.LocalDate) DateTimeModification(alfio.model.modification.DateTimeModification) TicketCategoryModification(alfio.model.modification.TicketCategoryModification) IntegrationTestUtil.initEvent(alfio.test.util.IntegrationTestUtil.initEvent) CheckInStatistics(alfio.manager.support.CheckInStatistics) BaseIntegrationTest(alfio.util.BaseIntegrationTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with CheckInStatistics

use of alfio.manager.support.CheckInStatistics in project alf.io by alfio-event.

the class CheckInManagerTest method getStatisticsDisabled.

@Test
void getStatisticsDisabled() {
    when(configurationManager.getFor(eq(CHECK_IN_STATS), any(ConfigurationLevel.class))).thenReturn(new ConfigurationManager.MaybeConfiguration(CHECK_IN_STATS, new ConfigurationKeyValuePathLevel(null, "false", null)));
    CheckInStatistics statistics = checkInManager.getStatistics(EVENT_NAME, USERNAME);
    assertNull(statistics);
    verify(eventRepository, never()).retrieveCheckInStatisticsForEvent(EVENT_ID);
}
Also used : ConfigurationLevel(alfio.manager.system.ConfigurationLevel) CheckInStatistics(alfio.manager.support.CheckInStatistics) ConfigurationManager(alfio.manager.system.ConfigurationManager) ConfigurationKeyValuePathLevel(alfio.model.system.ConfigurationKeyValuePathLevel) Test(org.junit.jupiter.api.Test)

Aggregations

CheckInStatistics (alfio.manager.support.CheckInStatistics)4 ConfigurationLevel (alfio.manager.system.ConfigurationLevel)3 ConfigurationManager (alfio.manager.system.ConfigurationManager)3 Test (org.junit.jupiter.api.Test)3 ConfigurationKeyValuePathLevel (alfio.model.system.ConfigurationKeyValuePathLevel)2 Date (java.util.Date)2 Event (alfio.model.Event)1 DateTimeModification (alfio.model.modification.DateTimeModification)1 TicketCategoryModification (alfio.model.modification.TicketCategoryModification)1 Organization (alfio.model.user.Organization)1 EventRepository (alfio.repository.EventRepository)1 OrganizationRepository (alfio.repository.user.OrganizationRepository)1 IntegrationTestUtil.initEvent (alfio.test.util.IntegrationTestUtil.initEvent)1 BaseIntegrationTest (alfio.util.BaseIntegrationTest)1 LocalDate (java.time.LocalDate)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1