Search in sources :

Example 6 with UpdateTicketOwnerForm

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));
}
Also used : TextTemplateGenerator(alfio.manager.support.TextTemplateGenerator) PartialTicketTextGenerator(alfio.manager.support.PartialTicketTextGenerator) UpdateTicketOwnerForm(alfio.controller.form.UpdateTicketOwnerForm) Test(org.junit.Test)

Example 7 with UpdateTicketOwnerForm

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));
}
Also used : TextTemplateGenerator(alfio.manager.support.TextTemplateGenerator) PartialTicketTextGenerator(alfio.manager.support.PartialTicketTextGenerator) UpdateTicketOwnerForm(alfio.controller.form.UpdateTicketOwnerForm) Test(org.junit.Test)

Example 8 with UpdateTicketOwnerForm

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());
    }
}
Also used : UpdateTicketOwnerForm(alfio.controller.form.UpdateTicketOwnerForm) LocalDate(java.time.LocalDate) PartialTicketPDFGenerator(alfio.manager.support.PartialTicketPDFGenerator) Test(org.junit.Test)

Example 9 with UpdateTicketOwnerForm

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);
}
Also used : UpdateTicketOwnerForm(alfio.controller.form.UpdateTicketOwnerForm)

Aggregations

UpdateTicketOwnerForm (alfio.controller.form.UpdateTicketOwnerForm)9 Test (org.junit.Test)7 PartialTicketTextGenerator (alfio.manager.support.PartialTicketTextGenerator)4 TextTemplateGenerator (alfio.manager.support.TextTemplateGenerator)3 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)2 BindingResult (org.springframework.validation.BindingResult)2 BindingAwareModelMap (org.springframework.validation.support.BindingAwareModelMap)2 TestConfiguration (alfio.TestConfiguration)1 DataSourceConfiguration (alfio.config.DataSourceConfiguration)1 Initializer (alfio.config.Initializer)1 RepositoryConfiguration (alfio.config.RepositoryConfiguration)1 AttendeeApiController (alfio.controller.api.AttendeeApiController)1 ReservationApiController (alfio.controller.api.ReservationApiController)1 CheckInApiController (alfio.controller.api.admin.CheckInApiController)1 EventApiController (alfio.controller.api.admin.EventApiController)1 SerializablePair (alfio.controller.api.admin.SerializablePair)1 UsersApiController (alfio.controller.api.admin.UsersApiController)1 TicketHelper (alfio.controller.api.support.TicketHelper)1 PaymentForm (alfio.controller.form.PaymentForm)1