@Test
public void testEmailNotificationWithTemplate() throws Exception {

                    
    EmailNotificationPublisher publisher = new EmailNotificationPublisher(connection, userInfo);
    
    
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("Name", "John Doe");
    Set<OrganizationalEntity> recipients = new HashSet<>(Arrays.asList(factory.newUser("john")));
    publisher.publish("admin@jbpm.org", "Test notification", recipients, "basic-email", parameters);
    
    assertEquals( 1, wiser.getMessages().size() );
    String expectedBody = "<html><body>Hello John Doe</body></html>";
    
    MimeMessage msg = (( WiserMessage  ) wiser.getMessages().get( 0 )).getMimeMessage();
    // Side effect of MIME encoding (I think.. ): \r\n..
    String content = ((String) msg.getContent()).replace("\r\n", "");
    assertEquals( expectedBody, content );
    assertEquals( "Test notification", msg.getSubject() );
    assertEquals( "admin@jbpm.org", ((InternetAddress)msg.getFrom()[0]).getAddress() );        
    assertEquals( "john@domain.com", ((InternetAddress)msg.getRecipients( RecipientType.TO )[0]).getAddress() );
    assertNull( msg.getRecipients( RecipientType.CC ) );
    assertNull( msg.getRecipients( RecipientType.BCC ) );
}