1
|
package eu.dnetlib.msro.notification;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
import java.util.Map;
|
5
|
|
6
|
import org.antlr.stringtemplate.StringTemplate;
|
7
|
import org.apache.commons.io.IOUtils;
|
8
|
import org.junit.Before;
|
9
|
import org.junit.Test;
|
10
|
|
11
|
import com.google.common.collect.Maps;
|
12
|
|
13
|
public class EmailDispatcherTest {
|
14
|
|
15
|
private String successTemplatePath = "/eu/dnetlib/msro/mail/wf_success.mail.st";
|
16
|
private String failureTemplatePath = "/eu/dnetlib/msro/mail/wf_failed.mail.st";
|
17
|
private EmailDispatcher dispatcher;
|
18
|
|
19
|
@Before
|
20
|
public void setUp() throws Exception {
|
21
|
dispatcher = new EmailDispatcher();
|
22
|
dispatcher.setBaseUrl("http://the.base.url");
|
23
|
dispatcher.setInfrastructure("container.hostname");
|
24
|
}
|
25
|
|
26
|
@Test
|
27
|
public void testPrepareMessageSuccess() throws IOException {
|
28
|
|
29
|
final String template = IOUtils.toString(getClass().getResourceAsStream(successTemplatePath));
|
30
|
final Map<String, Object> map = Maps.newHashMap();
|
31
|
map.put("wfId", "WF_ID");
|
32
|
map.put("wfName", "WF_NAME");
|
33
|
map.put("procId", "PROC_ID");
|
34
|
|
35
|
StringTemplate st = dispatcher.prepareMessage(template, map);
|
36
|
System.out.println(st.toString());
|
37
|
}
|
38
|
|
39
|
@Test
|
40
|
public void testPrepareMessageFailure() throws IOException {
|
41
|
|
42
|
final String template = IOUtils.toString(getClass().getResourceAsStream(failureTemplatePath));
|
43
|
final Map<String, Object> map = Maps.newHashMap();
|
44
|
map.put("wfId", "WF_ID");
|
45
|
map.put("wfName", "WF_NAME");
|
46
|
map.put("procId", "PROC_ID");
|
47
|
|
48
|
StringTemplate st = dispatcher.prepareMessage(template, map);
|
49
|
System.out.println(st.toString());
|
50
|
}
|
51
|
}
|