|
@@ -56,20 +56,46 @@ public class EventFormatterTest {
|
56
|
56
|
|
57
|
57
|
when(templateProvider.getFormat(ChannelMessageEvent.class))
|
58
|
58
|
.thenReturn(Optional.of(
|
59
|
|
- EventFormat.create("Template {{channel}} meep", Optional.empty())));
|
|
59
|
+ EventFormat.create(
|
|
60
|
+ "Template {{channel}} meep",
|
|
61
|
+ Optional.empty(),
|
|
62
|
+ Optional.empty(),
|
|
63
|
+ Optional.empty())));
|
60
|
64
|
when(propertyManager.getProperty(messageEvent, ChannelMessageEvent.class, "channel"))
|
61
|
65
|
.thenReturn(Optional.of("MONKEY"));
|
62
|
66
|
|
63
|
67
|
assertEquals("Template MONKEY meep", formatter.format(messageEvent).orElse(null));
|
64
|
68
|
}
|
65
|
69
|
|
|
70
|
+ @Test
|
|
71
|
+ public void testBeforeAndAfterFormat() {
|
|
72
|
+ messageEvent = new ChannelMessageEvent(channel, null, null);
|
|
73
|
+
|
|
74
|
+ when(templateProvider.getFormat(ChannelMessageEvent.class))
|
|
75
|
+ .thenReturn(Optional.of(
|
|
76
|
+ EventFormat.create(
|
|
77
|
+ "Template {{channel}} meep",
|
|
78
|
+ Optional.of("Before!"),
|
|
79
|
+ Optional.of("After!"),
|
|
80
|
+ Optional.empty())));
|
|
81
|
+ when(propertyManager.getProperty(messageEvent, ChannelMessageEvent.class, "channel"))
|
|
82
|
+ .thenReturn(Optional.of("MONKEY"));
|
|
83
|
+
|
|
84
|
+ assertEquals(
|
|
85
|
+ "Before!\nTemplate MONKEY meep\nAfter!",
|
|
86
|
+ formatter.format(messageEvent).orElse(null));
|
|
87
|
+ }
|
|
88
|
+
|
66
|
89
|
@Test
|
67
|
90
|
public void testFormatWithFunction() {
|
68
|
91
|
messageEvent = new ChannelMessageEvent(channel, null, null);
|
69
|
92
|
|
70
|
93
|
when(templateProvider.getFormat(ChannelMessageEvent.class))
|
71
|
94
|
.thenReturn(Optional.of(
|
72
|
|
- EventFormat.create("Template {{channel|lowercase}} meep",
|
|
95
|
+ EventFormat.create(
|
|
96
|
+ "Template {{channel|lowercase}} meep",
|
|
97
|
+ Optional.empty(),
|
|
98
|
+ Optional.empty(),
|
73
|
99
|
Optional.empty())));
|
74
|
100
|
when(propertyManager.getProperty(messageEvent, ChannelMessageEvent.class, "channel"))
|
75
|
101
|
.thenReturn(Optional.of("MONKEY"));
|
|
@@ -84,7 +110,11 @@ public class EventFormatterTest {
|
84
|
110
|
|
85
|
111
|
when(templateProvider.getFormat(ChannelMessageEvent.class))
|
86
|
112
|
.thenReturn(Optional.of(
|
87
|
|
- EventFormat.create("Template {{message}} meep", Optional.empty())));
|
|
113
|
+ EventFormat.create(
|
|
114
|
+ "Template {{message}} meep",
|
|
115
|
+ Optional.empty(),
|
|
116
|
+ Optional.empty(),
|
|
117
|
+ Optional.empty())));
|
88
|
118
|
when(propertyManager.getProperty(messageEvent, ChannelMessageEvent.class, "message"))
|
89
|
119
|
.thenReturn(Optional.of("{{channel}}"));
|
90
|
120
|
|