|
@@ -16,19 +16,42 @@
|
|
|
*/
|
|
|
package org.apache.dolphinscheduler.dao;
|
|
|
|
|
|
+import org.apache.dolphinscheduler.common.enums.AlertStatus;
|
|
|
+import org.apache.dolphinscheduler.common.enums.AlertType;
|
|
|
+import org.apache.dolphinscheduler.common.enums.ShowType;
|
|
|
+import org.apache.dolphinscheduler.dao.entity.Alert;
|
|
|
import org.junit.Assert;
|
|
|
import org.junit.Test;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-public class AlertDaoTest {
|
|
|
- private static final Logger logger = LoggerFactory.getLogger(AlertDaoTest.class);
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
|
|
|
+public class AlertDaoTest {
|
|
|
@Test
|
|
|
- public void testGetAlertDao() {
|
|
|
- logger.info("testGetAlertDao start");
|
|
|
+ public void testAlertDao(){
|
|
|
AlertDao alertDao = DaoFactory.getDaoInstance(AlertDao.class);
|
|
|
- Assert.assertNotNull(alertDao);
|
|
|
- logger.info("testGetAlertDao end");
|
|
|
+ Alert alert = new Alert();
|
|
|
+ alert.setTitle("Mysql Exception");
|
|
|
+ alert.setShowType(ShowType.TEXT);
|
|
|
+ alert.setContent("[\"alarm time:2018-02-05\", \"service name:MYSQL_ALTER\", \"alarm name:MYSQL_ALTER_DUMP\", " +
|
|
|
+ "\"get the alarm exception.!,interface error,exception information:timed out\", \"request address:http://blog.csdn.net/dreamInTheWorld/article/details/78539286\"]");
|
|
|
+ alert.setAlertType(AlertType.EMAIL);
|
|
|
+ alert.setAlertGroupId(1);
|
|
|
+ alert.setAlertStatus(AlertStatus.WAIT_EXECUTION);
|
|
|
+ alertDao.addAlert(alert);
|
|
|
+
|
|
|
+
|
|
|
+ List<Alert> alerts = alertDao.listWaitExecutionAlert();
|
|
|
+ Assert.assertNotNull(alerts);
|
|
|
+ Assert.assertNotEquals(0, alerts.size());
|
|
|
+ int id = alerts.get(0).getId();
|
|
|
+ AlertStatus alertStatus = alerts.get(0).getAlertStatus();
|
|
|
+ alertDao.updateAlert(AlertStatus.EXECUTION_SUCCESS, "", id);
|
|
|
+
|
|
|
+ alerts = alertDao.listWaitExecutionAlert();
|
|
|
+ Assert.assertEquals(0, alerts.size());
|
|
|
+ alertDao.getAlertMapper().deleteById(id);
|
|
|
}
|
|
|
}
|