package com.jay.monitor.data.server.utils;

import com.alibaba.fastjson.JSON;
import com.jay.monitor.data.server.models.request.dingding.MdModel;
import org.junit.Test;

import static org.junit.Assert.*;

/**
 * @Module TODO
 * @Description TODO
 * @Author liukaixiong
 * @Date 2020/12/14 16:09
 */
public class DingDingUtilsTest {
    String dingDingUrl = "https://oapi.dingtalk.com/robot/send?access_token=c2d694e28fd5de8c0b4f42be2e253bb3e4ef1fbb7d589ac377015e738713b995";

    @Test
    public void send() {

        // String md = "{\"markdown\":{\"text\":\"|/elab-marketing-user/miniecrm/standing/book/payProofPdf|1|5668|5668|\\n|/elab-marketing-user/visit/add|1|5192|5192|\\n|/elab-marketing-user/miniecrm/standing/book/payProof|1|5168|5168|\\n|/elab-marketing-user/visit/scanVisitQueue|12|5206|5385|\\n|/elab-marketing-user/organize/v2.0/verification/autoAuthentication|48|5365|8997|\\n|/elab-marketing-user/bindAdviser/reportAdviserListNew|6|5120|5137|\\n|/elab-marketing-user/report/upgrade/reportCount|16|5341|6088|\\n|/elab-marketing-user/miniecrm/standing/book/reportList|12|5341|5905|\\n|/elab-marketing-user/c_report/manualRecord|12|5355|6037|\\n\",\"title\":\"URL请求慢排行 - TOP 10 \"},\"msgtype\":\"markdown\"}";
        String md = "{\n" +
                "     \"msgtype\": \"markdown\",\n" +
                "     \"markdown\": {\n" +
                "         \"title\":\"杭州天气\",\n" +
                "         \"text\": \"| /elab-marketing-user/miniecrm/standing/book/payProof | 1    | 5168 | 5168 |\n" +
                "| ---------------------------------------------------- | ---- | ---- | ---- |\n" +
                "|     阿萨德发送大方                                                 |     1 |     2 |   3   |\"\n" +
                "     },\n" +
                "      \"at\": {\n" +
                "          \"atMobiles\": [\n" +
                "              \"150XXXXXXXX\"\n" +
                "          ],\n" +
                "          \"isAtAll\": false\n" +
                "      }\n" +
                " }";
        MdModel model = JSON.parseObject(md, MdModel.class);
        boolean send = DingDingUtils.send(dingDingUrl, model);
        System.out.println("发送结果:" + send);
    }
}