Search in sources :

Example 1 with PartialTicketTextGenerator

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

the class TicketReservationManagerTest method dontSendWarningEmailIfNotAcquiredStatus.

// check we don't send the ticket-has-changed-owner email if the originalEmail and name are present and the status is not ACQUIRED
@Test
public void dontSendWarningEmailIfNotAcquiredStatus() {
    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.FREE);
    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());
    verifyZeroInteractions(messageSource);
}
Also used : PartialTicketTextGenerator(alfio.manager.support.PartialTicketTextGenerator) UpdateTicketOwnerForm(alfio.controller.form.UpdateTicketOwnerForm) Test(org.junit.Test)

Example 2 with PartialTicketTextGenerator

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

the class TicketReservationManagerTest method fallbackToCurrentLocale.

@Test
public void fallbackToCurrentLocale() throws IOException {
    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);
    when(modified.getStatus()).thenReturn(TicketStatus.ACQUIRED);
    UpdateTicketOwnerForm form = new UpdateTicketOwnerForm();
    when(event.getShortName()).thenReturn("short-name");
    initUpdateTicketOwner(original, modified, ticketId, originalEmail, originalName, form);
    form.setUserLanguage("");
    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)).sendTicketByEmail(eq(modified), eq(event), eq(Locale.ENGLISH), any(), any(), any());
    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 3 with PartialTicketTextGenerator

use of alfio.manager.support.PartialTicketTextGenerator 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 4 with PartialTicketTextGenerator

use of alfio.manager.support.PartialTicketTextGenerator 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)

Aggregations

UpdateTicketOwnerForm (alfio.controller.form.UpdateTicketOwnerForm)4 PartialTicketTextGenerator (alfio.manager.support.PartialTicketTextGenerator)4 Test (org.junit.Test)4 TextTemplateGenerator (alfio.manager.support.TextTemplateGenerator)3