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