package com.jay.monitor.data.server.report.alert.notify;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.jay.monitor.data.server.enums.AlertRuleEnums;
import org.junit.Test;

import java.util.LinkedHashMap;

/**
 * @Module TODO
 * @Description TODO
 * @Author liukaixiong
 * @Date 2021/1/14 14:00
 */
public class DingDingRealTimeAlertProcessTest {

    @Test
    public void send() {
        String json = "{\n" +
                "\"id\": 14964,\n" +
                "\"applicationName\": \"elab-marketing-notify\",\n" +
                "\"applicationIp\": \"172.19.189.160\",\n" +
                "\"mqType\": \"kafka\",\n" +
                "\"invokeType\": \"consumer\",\n" +
                "\"topic\": \"test-mysql-dts\",\n" +
                "\"partitionName\": \"5\",\n" +
                "\"msgId\": \"136016\",\n" +
                "\"dataGroupName\": \"dm_dictionary\",\n" +
                "\"dataGroupKey\": \"UPDATE\",\n" +
                "\"dataId\": \"7065\",\n" +
                "\"rootLogId\": \"test-dts-server-ac13bd95-447389-1870\",\n" +
                "\"parentLogId\": \"test-dts-server-ac13bd95-447389-1870\",\n" +
                "\"logId\": \"elab-marketing-notify-ac13bda0-447389-576\",\n" +
                "\"status\": 1,\n" +
                "\"requestTime\": 1,\n" +
                "\"sourceTime\": 1610603107000,\n" +
                "\"createdTime\": 1610603108000\n" +
                "}\n";


        JSONObject jsonObject = JSON.parseObject(json);
        LinkedHashMap dataMap = new LinkedHashMap();
        dataMap.put("触发原因", AlertRuleEnums.REQUEST_TIME);
        dataMap.put("触发数据", jsonObject);

        String object = JSON.toJSONString(dataMap, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue,
                SerializerFeature.WriteDateUseDateFormat);

        System.out.println(object);
    }
}