use of alfio.controller.form.UpdateTicketOwnerForm in project alf.io by alfio-event.
the class TicketReservationManagerTest method sendWarningEmailToOrganizer.
@Test
public void sendWarningEmailToOrganizer() {
final String ticketId = "abcde";
final String originalEmail = "me@myaddress.com";
final String originalName = "First Last";
Ticket original = mock(Ticket.class);
when(original.getStatus()).thenReturn(TicketStatus.ACQUIRED);
Ticket modified = mock(Ticket.class);
UpdateTicketOwnerForm form = new UpdateTicketOwnerForm();
when(event.getShortName()).thenReturn("short-name");
initUpdateTicketOwner(original, modified, ticketId, originalEmail, originalName, form);
PartialTicketTextGenerator ownerChangeTextBuilder = mock(PartialTicketTextGenerator.class);
when(ownerChangeTextBuilder.generate(eq(modified))).thenReturn("Hello, world");
when(original.getUserLanguage()).thenReturn(USER_LANGUAGE);
when(event.getBegin()).thenReturn(ZonedDateTime.now().minusSeconds(1));
trm.updateTicketOwner(original, Locale.ENGLISH, event, form, (a) -> null, ownerChangeTextBuilder, Optional.empty());
verify(messageSource, times(1)).getMessage(eq("ticket-has-changed-owner-subject"), any(), eq(Locale.ITALIAN));
verify(notificationManager, times(1)).sendSimpleEmail(eq(event), eq(originalEmail), anyString(), any(TextTemplateGenerator.class));
verify(notificationManager, times(1)).sendSimpleEmail(eq(event), eq(ORG_EMAIL), anyString(), any(TextTemplateGenerator.class));
}
use of alfio.controller.form.UpdateTicketOwnerForm in project alf.io by alfio-event.
the class TicketReservationManagerTest method sendWarningEmailIfNotAdmin.
@Test
public void sendWarningEmailIfNotAdmin() {
final String ticketId = "abcde";
final String originalEmail = "me@myaddress.com";
final String originalName = "First Last";
Ticket original = mock(Ticket.class);
when(original.getStatus()).thenReturn(TicketStatus.ACQUIRED);
Ticket modified = mock(Ticket.class);
UpdateTicketOwnerForm form = new UpdateTicketOwnerForm();
when(event.getShortName()).thenReturn("short-name");
initUpdateTicketOwner(original, modified, ticketId, originalEmail, originalName, form);
PartialTicketTextGenerator ownerChangeTextBuilder = mock(PartialTicketTextGenerator.class);
when(ownerChangeTextBuilder.generate(eq(modified))).thenReturn("Hello, world");
when(original.getUserLanguage()).thenReturn(USER_LANGUAGE);
trm.updateTicketOwner(original, Locale.ENGLISH, event, form, (a) -> null, ownerChangeTextBuilder, Optional.empty());
verify(messageSource, times(1)).getMessage(eq("ticket-has-changed-owner-subject"), any(), eq(Locale.ITALIAN));
verify(notificationManager, times(1)).sendSimpleEmail(eq(event), eq(originalEmail), anyString(), any(TextTemplateGenerator.class));
}
use of alfio.controller.form.UpdateTicketOwnerForm in project alf.io by alfio-event.
the class DataMigratorIntegrationTest method testUpdateGender.
@Test
public void testUpdateGender() {
List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null));
Pair<Event, String> eventUsername = initEvent(categories);
Event event = eventUsername.getKey();
try {
TicketReservationModification trm = new TicketReservationModification();
trm.setAmount(2);
trm.setTicketCategoryId(eventManager.loadTicketCategories(event).get(0).getId());
TicketReservationWithOptionalCodeModification r = new TicketReservationWithOptionalCodeModification(trm, Optional.empty());
Date expiration = DateUtils.addDays(new Date(), 1);
String reservationId = ticketReservationManager.createTicketReservation(event, Collections.singletonList(r), Collections.emptyList(), expiration, Optional.empty(), Optional.empty(), Locale.ENGLISH, false);
ticketReservationManager.confirm("TOKEN", null, event, reservationId, "email@email.ch", new CustomerName("Full Name", "Full", "Name", event), Locale.ENGLISH, null, new TotalPrice(1000, 10, 0, 0), Optional.empty(), Optional.of(PaymentProxy.ON_SITE), false, null, null, null);
List<Ticket> tickets = ticketRepository.findTicketsInReservation(reservationId);
UpdateTicketOwnerForm first = new UpdateTicketOwnerForm();
first.setEmail("email@email.ch");
// first.setTShirtSize("SMALL");
// first.setGender("F");
first.setFirstName("Full");
first.setLastName("Name");
UpdateTicketOwnerForm second = new UpdateTicketOwnerForm();
// second.setTShirtSize("SMALL-F");
second.setEmail("email@email.ch");
second.setFirstName("Full");
second.setLastName("Name");
PartialTicketPDFGenerator generator = TemplateProcessor.buildPartialPDFTicket(Locale.ITALIAN, event, ticketReservationManager.findById(reservationId).get(), ticketCategoryRepository.getByIdAndActive(tickets.get(0).getCategoryId(), event.getId()), organizationRepository.getById(event.getOrganizationId()), templateManager, fileUploadManager, "");
ticketReservationManager.updateTicketOwner(tickets.get(0), Locale.ITALIAN, event, first, (t) -> "", (t) -> "", Optional.empty());
ticketReservationManager.updateTicketOwner(tickets.get(1), Locale.ITALIAN, event, second, (t) -> "", (t) -> "", Optional.empty());
// FIXME
// dataMigrator.fillTicketsGender();
// ticketRepository.findTicketsInReservation(reservationId).forEach(t -> assertEquals("F", t.getGender()));
} finally {
eventManager.deleteEvent(event.getId(), eventUsername.getValue());
}
}
use of alfio.controller.form.UpdateTicketOwnerForm in project alf.io by alfio-event.
the class TicketHelper method directTicketAssignment.
public Optional<Triple<ValidationResult, Event, Ticket>> directTicketAssignment(String eventName, String reservationId, String email, String fullName, String firstName, String lastName, String userLanguage, Optional<Errors> bindingResult, HttpServletRequest request, Model model) {
List<Ticket> tickets = ticketReservationManager.findTicketsInReservation(reservationId);
if (tickets.size() > 1) {
return Optional.empty();
}
String ticketUuid = tickets.get(0).getUuid();
UpdateTicketOwnerForm form = new UpdateTicketOwnerForm();
form.setAdditional(Collections.emptyMap());
form.setEmail(email);
form.setFullName(fullName);
form.setFirstName(firstName);
form.setLastName(lastName);
form.setUserLanguage(userLanguage);
return assignTicket(eventName, reservationId, ticketUuid, form, bindingResult, request, model);
}
Aggregations