package com.jay.monitor.data.server.store.es;

import com.jay.monitor.data.server.SpringRunCase;
import com.jay.monitor.data.server.enums.AlertMsgEnums;
import com.jay.monitor.data.server.models.store.AlertPlatformConfig;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

public class ElasticAlertPlatformProcessTest extends SpringRunCase {
    @Autowired
    private ElasticAlertPlatformProcess elasticAlertPlatformProcess;

    @Test
    public void testSave() {
        AlertPlatformConfig config = new AlertPlatformConfig();
        config.setAlertName("组1");
        config.setPlatformType(AlertMsgEnums.DingDing);
        config.setUrl(
            "https://oapi.dingtalk.com/robot/send?access_token=f68223b00613967e969a33b5200667bd054a0f5289fa77e8ec062294625892e4");
        config.setStatus(1);
        config.setRemark("这个是用来测试的");
        config.setCreateDate(new Date());
        config.setCreator("liukx");
        boolean save = elasticAlertPlatformProcess.save(config);
        Assert.assertTrue(save);
    }

    @Test
    public void testUpdate() {
        AlertPlatformConfig alertPlatformConfig = elasticAlertPlatformProcess.queryById("KFpExHsBIcT-h3qq6woY");
        alertPlatformConfig.setStatus(1);
        alertPlatformConfig.setCreateDate(new Date());
        boolean update = elasticAlertPlatformProcess.update(alertPlatformConfig);
        Assert.assertTrue(update);
    }

    @Test
    public void testQuery() {
        AlertPlatformConfig alertPlatformConfig = elasticAlertPlatformProcess.queryById("KFpExHsBIcT-h3qq6woY");
        Assert.assertNotNull(alertPlatformConfig);
    }
}