Search in sources :

Example 1 with TemplateEngine

use of edu.stanford.bmir.protege.web.server.templates.TemplateEngine in project webprotege by protegeproject.

the class CommentNotificationEmailGenerator_TestCase method setUp.

@Before
public void setUp() throws Exception {
    when(templateFile.getContents()).thenReturn(TEMPLATE_FILE_CONTENTS);
    when(templateFile.getFile()).thenReturn(file);
    when(file.getName()).thenReturn(THE_FILE_NAME);
    when(comment.getCreatedBy()).thenReturn(creator);
    when(creator.getUserName()).thenReturn(USER_NAME);
    when(applicationNameSupplier.get()).thenReturn("TheAppName");
    when(placeUrl.getProjectUrl(any())).thenReturn("TheProjectUrl");
    when(placeUrl.getEntityUrl(any(), any())).thenReturn("TheEntityUrl");
    when(entityData.getEntity()).thenReturn(entity);
    when(entityData.getBrowserText()).thenReturn("TheBrowserText");
    templateEngine = new TemplateEngine(DefaultMustacheFactory::new);
    generator = new CommentNotificationEmailGenerator(templateFile, templateEngine, applicationNameSupplier, placeUrl);
}
Also used : TemplateEngine(edu.stanford.bmir.protege.web.server.templates.TemplateEngine) Before(org.junit.Before)

Example 2 with TemplateEngine

use of edu.stanford.bmir.protege.web.server.templates.TemplateEngine in project webprotege by protegeproject.

the class PasswordResetMailer_IT method setUp.

@Before
public void setUp() throws Exception {
    when(placeUrl.getApplicationUrl()).thenReturn(applicationUrl);
    when(appNameProvider.get()).thenReturn(theAppName);
    OverridableFile overridableFile = new OverridableFile(TEMPLATE_PATH, new File("/tmp/data"));
    FileContents templateFile = new FileContents(overridableFile);
    TemplateEngine templateEngine = new TemplateEngine(DefaultMustacheFactory::new);
    ResetPasswordMailer mailer = new ResetPasswordMailer(sendMailImpl, templateEngine, templateFile, placeUrl, appNameProvider);
    mailer.sendEmail(userId, emailAddress, theNewPassword, e -> {
    });
    verify(sendMailImpl, times(1)).sendMail(eq(singletonList(emailAddress)), eq("Your password has been reset"), bodyCaptor.capture(), any(MessagingExceptionHandler.class));
}
Also used : TemplateEngine(edu.stanford.bmir.protege.web.server.templates.TemplateEngine) FileContents(edu.stanford.bmir.protege.web.server.filemanager.FileContents) DefaultMustacheFactory(com.github.mustachejava.DefaultMustacheFactory) MessagingExceptionHandler(edu.stanford.bmir.protege.web.server.mail.MessagingExceptionHandler) File(java.io.File) OverridableFile(edu.stanford.bmir.protege.web.server.inject.OverridableFile) OverridableFile(edu.stanford.bmir.protege.web.server.inject.OverridableFile) Before(org.junit.Before)

Aggregations

TemplateEngine (edu.stanford.bmir.protege.web.server.templates.TemplateEngine)2 Before (org.junit.Before)2 DefaultMustacheFactory (com.github.mustachejava.DefaultMustacheFactory)1 FileContents (edu.stanford.bmir.protege.web.server.filemanager.FileContents)1 OverridableFile (edu.stanford.bmir.protege.web.server.inject.OverridableFile)1 MessagingExceptionHandler (edu.stanford.bmir.protege.web.server.mail.MessagingExceptionHandler)1 File (java.io.File)1