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

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.jay.monitor.data.server.models.dto.alert.RealTimeAlert;
import org.junit.Test;

/**
 * @Module TODO
 * @Description TODO
 * @Author liukaixiong
 * @Date 2021/1/14 18:34
 */
public class DataUtilsTest {

    @Test
    public void test() throws Exception {
    }

    @Test
    public void testJson() {
//        TestJsonModel testJsonModel = new TestJsonModel();
//        testJsonModel.setDate(new Date());
//        testJsonModel.setUsername("某某某");

        String dataJson = "{\"logId\":\"elab-marketing-notify-c0a804f4-447393-24\",\"主题类型\":\"test-mysql-dts\",\"创建时间\":\"2021-01-14 17:03:30.985\",\"数据编号\":\"2766\",\"服务名称\":\"elab-marketing-notify\",\"服务器ip\":\"192.168.4.244\",\"消息编号\":\"135771\",\"消息队列类型\":\"kafka\",\"状态\":-1,\"监控类型\":\"MQ\",\"组key名称\":\"UPDATE\",\"组名称\":\"c_shangtang_visit\",\"触发原因\":\"STATUS\",\"请求时长\":10}";
        RealTimeAlert realTimeAlert = JSON.parseObject(dataJson, RealTimeAlert.class);
        System.out.println(JSON.toJSONString(realTimeAlert, SerializerFeature.PrettyFormat));

    }

    @Test
    public void testJson2() {
        String json = "{\"request\":\"{\\\"userAgent\\\":\\\"\\\",\\\"browserName\\\":\\\"\\\",\\\"browserVersion\\\":\\\"2.14.4\\\",\\\"platform\\\":\\\"miniapp\\\",\\\"fromPlatform\\\":\\\"\\\",\\\"reserve1\\\":\\\"1\\\",\\\"reserve2\\\":\\\"常州市\\\",\\\"fromParam\\\":\\\"{\\\\\\\"scene\\\\\\\":1037}\\\",\\\"deviceType\\\":\\\"Redmi Note 8 Pro\\\",\\\"ip\\\":\\\"61.173.21.69, 100.117.46.16\\\",\\\"cookieId\\\":\\\"\\\",\\\"openId\\\":\\\"oCBsp4824NWP6NjaNxoIHJGYNwgs\\\",\\\"customerId\\\":1542488,\\\"brandUserId\\\":1542488,\\\"createTime\\\":\\\"2021-01-15 15:20:51\\\",\\\"uploadTime\\\":\\\"2021-01-15 15:20:51\\\",\\\"product\\\":\\\"金茂粉\\\",\\\"project\\\":\\\"10022\\\",\\\"eventId\\\":\\\"\\\",\\\"eventName\\\":\\\"\\\",\\\"expand\\\":\\\";brandId=1\\\",\\\"imTalkId\\\":\\\"\\\",\\\"imTalkType\\\":\\\"\\\",\\\"eventModuleDes\\\":\\\"\\\",\\\"eventInnerModuleId\\\":\\\"\\\",\\\"adviserId\\\":\\\"\\\",\\\"clkDesPage\\\":\\\"\\\",\\\"clkId\\\":\\\"clk_2cmina_2\\\",\\\"clkName\\\":\\\"close\\\",\\\"pvId\\\":\\\"\\\",\\\"pvPageStayTime\\\":\\\"\\\",\\\"pvCurPageName\\\":\\\"housepage-index\\\",\\\"pvCurPageParams\\\":\\\"{\\\\\\\"path\\\\\\\":\\\\\\\"pages/index/index\\\\\\\",\\\\\\\"brandId\\\\\\\":1}\\\",\\\"pvLastPageName\\\":\\\"\\\",\\\"pvLastPageParams\\\":\\\"\\\",\\\"pvPageLoadTime\\\":\\\"\\\",\\\"type\\\":\\\"CLK\\\",\\\"longitude\\\":\\\"\\\",\\\"latitude\\\":\\\"\\\",\\\"brandId\\\":1,\\\"session\\\":\\\"1542488_1610695193555\\\",\\\"terminal\\\":\\\"1\\\"}\",\"response\":\"{\\\"success\\\":true,\\\"errorCode\\\":null,\\\"message\\\":null,\\\"id\\\":null,\\\"logId\\\":\\\"default-ac13bd8c-447415-1147\\\"}\",\"header\":\"{\\\"content-length\\\":\\\"933\\\",\\\"charset\\\":\\\"utf-8\\\",\\\"referer\\\":\\\"https://servicewechat.com/wx7c35219113730904/26/page-frame.html\\\",\\\"remoteip\\\":\\\"61.173.21.69\\\",\\\"_catparentmessageid\\\":\\\"uat-elab-marketing-gateway-ac13bd8c-447415-1372\\\",\\\"x-forwarded-port\\\":\\\"80\\\",\\\"userid\\\":\\\"1542488\\\",\\\"elabprojectname\\\":\\\"jinmao\\\",\\\"x-forwarded-host\\\":\\\"api-uat.elaber.cn\\\",\\\"x-forwarded-prefix\\\":\\\"/elab-marketing-system\\\",\\\"brandid\\\":\\\"1\\\",\\\"elabbrandid\\\":\\\"1\\\",\\\"host\\\":\\\"api-uat.elaber.cn\\\",\\\"_catrootmessageid\\\":\\\"uat-elab-marketing-gateway-ac13bd8c-447415-1372\\\",\\\"connection\\\":\\\"close\\\",\\\"content-type\\\":\\\"application/json;charset=UTF-8\\\",\\\"elabsystem\\\":\\\"2\\\",\\\"xcx_token\\\":\\\"f7f474c9c473ee15f2a2eaef7f65cf81\\\",\\\"tonken\\\":\\\"\\\",\\\"elabenvironment\\\":\\\"3\\\",\\\"x-forwarded-proto\\\":\\\"http\\\",\\\"_catchildmessageid\\\":\\\"default-ac13bd8c-447415-1147\\\",\\\"openid\\\":\\\"oCBsp4824NWP6NjaNxoIHJGYNwgs\\\",\\\"x-forwarded-for\\\":\\\"61.173.21.69\\\",\\\"headername\\\":\\\"xcx_token\\\",\\\"fromchannel\\\":\\\"1\\\",\\\"customerid\\\":\\\"1542488\\\",\\\"tokenname\\\":\\\"xcx_token\\\",\\\"accept-encoding\\\":\\\"gzip,compress,br,deflate\\\",\\\"application.name\\\":\\\"uat-elab-marketing-gateway\\\",\\\"user-agent\\\":\\\"Mozilla/5.0 (Linux; Android 10; Redmi Note 8 Pro Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.62 XWEB/2693 MMWEBSDK/201201 Mobile Safari/537.36 MMWEBID/4293 MicroMessenger/7.0.22.1820(0x2700163B) Process/appbrand0 WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android\\\"}\"}";
        JSONObject jsonObject = JSON.parseObject(json);
        System.out.println(jsonObject.toJSONString());
    }

}