Commit 2bb88304 by Johannes Edmeier

SlackNotifier#setMessage should accept strings

fixes #202
parent 7ee97cff
......@@ -77,11 +77,11 @@ public class SlackNotifier extends AbstractStatusChangeNotifier {
this.username = username;
}
public void setMessage(Expression message) {
this.message = message;
public void setMessage(String message) {
this.message = parser.parseExpression(message, ParserContext.TEMPLATE_EXPRESSION);
}
private Object createMessage(ClientApplicationStatusChangedEvent event) {
protected Object createMessage(ClientApplicationStatusChangedEvent event) {
Map<String, Object> messageJson = new HashMap<>();
messageJson.put("username", username);
if (icon != null) {
......
......@@ -14,9 +14,6 @@ import javax.annotation.Nullable;
import org.junit.Before;
import org.junit.Test;
import org.springframework.expression.Expression;
import org.springframework.expression.ParserContext;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.web.client.RestTemplate;
import de.codecentric.boot.admin.event.ClientApplicationStatusChangedEvent;
......@@ -93,9 +90,7 @@ public class SlackNotifierTest {
StatusInfo infoDown = StatusInfo.ofDown();
StatusInfo infoUp = StatusInfo.ofUp();
Expression expression = new SpelExpressionParser().parseExpression(message,
ParserContext.TEMPLATE_EXPRESSION);
notifier.setMessage(expression);
notifier.setMessage(message);
notifier.setChannel(channel);
notifier.setIcon(icon);
notifier.notify(getEvent(infoDown, infoUp));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment