Search in sources :

Example 1 with TemplateGenerator

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

the class SpecialPriceManagerTest method trimLanguageTag.

@Test
public void trimLanguageTag() {
    when(configurationManager.getFor(eq(USE_PARTNER_CODE_INSTEAD_OF_PROMOTIONAL), any())).thenReturn(new ConfigurationManager.MaybeConfiguration(USE_PARTNER_CODE_INSTEAD_OF_PROMOTIONAL));
    when(specialPriceRepository.findActiveByCategoryIdForUpdate(eq(0), eq(1))).thenReturn(List.of(specialPrice1));
    Assertions.assertTrue(specialPriceManager.sendCodeToAssignee(singletonList(new SendCodeModification("123", "me", "me@domain.com", " it")), "", 0, ""));
    ArgumentCaptor<TemplateGenerator> templateCaptor = ArgumentCaptor.forClass(TemplateGenerator.class);
    verify(notificationManager).sendSimpleEmail(eq(event), isNull(), eq("me@domain.com"), anyString(), templateCaptor.capture());
    templateCaptor.getValue().generate();
    @SuppressWarnings("rawtypes") ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class);
    verify(templateManager).renderTemplate(any(Event.class), eq(TemplateResource.SEND_RESERVED_CODE), captor.capture(), eq(Locale.ITALIAN));
    Map<String, Object> model = captor.getValue();
    Assertions.assertEquals("123", model.get("code"));
    Assertions.assertEquals(event, model.get("event"));
    Assertions.assertEquals(organization, model.get("organization"));
    Assertions.assertEquals("http://my-event", model.get("eventPage"));
    Assertions.assertEquals("me", model.get("assignee"));
    verify(messageSource).getMessage(eq("email-code.subject"), eq(new Object[] { "Event Name", null }), eq(Locale.ITALIAN));
}
Also used : TemplateGenerator(alfio.manager.support.TemplateGenerator) Event(alfio.model.Event) ConfigurationManager(alfio.manager.system.ConfigurationManager) SendCodeModification(alfio.model.modification.SendCodeModification) Test(org.junit.jupiter.api.Test)

Example 2 with TemplateGenerator

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

the class SpecialPriceManagerTest method sendMessage.

private void sendMessage(String promoCodeDescription) {
    Assertions.assertTrue(specialPriceManager.sendCodeToAssignee(singletonList(new SendCodeModification("123", "me", "me@domain.com", "it")), "", 0, ""));
    ArgumentCaptor<TemplateGenerator> templateCaptor = ArgumentCaptor.forClass(TemplateGenerator.class);
    verify(notificationManager).sendSimpleEmail(eq(event), isNull(), eq("me@domain.com"), anyString(), templateCaptor.capture());
    templateCaptor.getValue().generate();
    @SuppressWarnings("rawtypes") ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class);
    verify(templateManager).renderTemplate(any(Event.class), eq(TemplateResource.SEND_RESERVED_CODE), captor.capture(), eq(Locale.ITALIAN));
    Map<String, Object> model = captor.getValue();
    Assertions.assertEquals("123", model.get("code"));
    Assertions.assertEquals(event, model.get("event"));
    Assertions.assertEquals(organization, model.get("organization"));
    Assertions.assertEquals("http://my-event", model.get("eventPage"));
    Assertions.assertEquals("me", model.get("assignee"));
    verify(messageSource).getMessage(eq("email-code.subject"), eq(new Object[] { "Event Name", promoCodeDescription }), eq(Locale.ITALIAN));
}
Also used : TemplateGenerator(alfio.manager.support.TemplateGenerator) Event(alfio.model.Event) SendCodeModification(alfio.model.modification.SendCodeModification)

Aggregations

TemplateGenerator (alfio.manager.support.TemplateGenerator)2 Event (alfio.model.Event)2 SendCodeModification (alfio.model.modification.SendCodeModification)2 ConfigurationManager (alfio.manager.system.ConfigurationManager)1 Test (org.junit.jupiter.api.Test)1