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);
}
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());
}
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());
}
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);
}
Aggregations