提交 4be5e159 编写于 作者: C chengshiwen

Fix unit tests

上级 045980b7
......@@ -96,9 +96,6 @@ public class EmailAlertPlugin implements AlertPlugin {
retMaps = emailManager.send(receviersList, receviersCcList, alert.getTitle(), alert.getContent(),
alert.getShowType());
//send flag
boolean flag = false;
if (retMaps == null) {
retMaps = new HashMap<>();
retMaps.put(Constants.MESSAGE, "alert send error.");
......@@ -107,9 +104,12 @@ public class EmailAlertPlugin implements AlertPlugin {
return retMaps;
}
flag = Boolean.parseBoolean(String.valueOf(retMaps.get(Constants.STATUS)));
if (flag) {
boolean enabled = Boolean.parseBoolean(String.valueOf(retMaps.get(Constants.MAIL_ENABLED)));
boolean status = Boolean.parseBoolean(String.valueOf(retMaps.get(Constants.STATUS)));
if (!enabled) {
logger.warn("mail wasn't sent since the mail config isn't set");
retMaps.put(Constants.MESSAGE, "mail wasn't sent since the mail config isn't set");
} else if (status) {
logger.info("alert send success");
retMaps.put(Constants.MESSAGE, "email send success.");
if (EnterpriseWeChatUtils.isEnable()) {
......@@ -121,7 +121,6 @@ public class EmailAlertPlugin implements AlertPlugin {
logger.error(e.getMessage(), e);
}
}
} else {
retMaps.put(Constants.MESSAGE, "alert send error.");
logger.info("alert send error : {}", retMaps.get(Constants.MESSAGE));
......
......@@ -75,6 +75,7 @@ public class EmailAlertPluginTest {
List<String> list = new ArrayList<String>(){{ add("xx@xx.com"); }};
alertInfo.addProp("receivers", list);
Map<String, Object> ret = plugin.process(alertInfo);
assertFalse(Boolean.parseBoolean(String.valueOf(ret.get(Constants.STATUS))));
assertFalse(Boolean.parseBoolean(String.valueOf(ret.get(Constants.MAIL_ENABLED))));
assertTrue(Boolean.parseBoolean(String.valueOf(ret.get(Constants.STATUS))));
}
}
\ No newline at end of file
......@@ -453,11 +453,11 @@ public class SqlTask extends AbstractTask {
if(EnumUtils.isValidEnum(ShowType.class,showTypeName)){
Map<String, Object> mailResult = MailUtils.sendMails(receiversList,
receiversCcList, title, content, ShowType.valueOf(showTypeName).getDescp());
if(!(boolean) mailResult.get(STATUS)){
throw new RuntimeException("send mail failed!");
}else if(!(boolean) mailResult.get(MAIL_ENABLED)){
if(!(boolean) mailResult.get(MAIL_ENABLED)){
logger.info("mail info : {} {}", title, content);
logger.warn("mail wasn't sent since the mail config isn't set");
}else if(!(boolean) mailResult.get(STATUS)){
throw new RuntimeException("send mail failed!");
}
}else{
logger.error("showType: {} is not valid " ,showTypeName);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册