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

import com.alibaba.fastjson.JSON;
import com.jay.monitor.data.core.enums.MsgTypeEnums;
import com.jay.monitor.data.core.model.serializable.URLDataDTO;
import com.jay.monitor.data.server.SpringRunCase;
import com.jay.monitor.data.server.store.StoreDataManager;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

public class URLUserProcessTest extends SpringRunCase {
    @Autowired
    private StoreDataManager storeDataManager;

    @Test
    public void testUrl() throws Exception {
        String json =
            "{\"affectedRows\":1,\"applicationName\":\"elab-marketing-brand\",\"commandType\":\"UPDATE\",\"createDate\":1614597429039,\"dataId\":\"1\",\"extMap\":{},\"ip\":\"192.168.2.63\",\"logId\":\"elab-marketing-brand-c0a8023f-448499-1005\",\"requestTime\":7,\"result\":1,\"sql\":\"update brand_app_house_history set house_id  =:houseId , creator  =:creator , brand_customer_id  =:brandCustomerId , created  =:created , updator  =:updator , updated  =:updated , brand_id  =:brandId , status  =:status where id =:id\",\"sqlId\":\"houseHistory.updateById\",\"status\":1,\"table\":\"brand_app_house_history\",\"time\":7,\"type\":\"SQL\"}";
        URLDataDTO urlDataDTO = JSON.parseObject(json, URLDataDTO.class);
        urlDataDTO.setClientIp("127.0.0.1");
        urlDataDTO.setUrl("/elab-marketing-user/aaa/bbb");
        urlDataDTO.setUserId("123");
        urlDataDTO.setApplicationName("elab-marketing-user");
        urlDataDTO.setCreateDate(new Date());
        urlDataDTO.setDataId("123123");
        urlDataDTO.setGroupKeyName("1111");
        urlDataDTO.setGroupName("2222");
        urlDataDTO.setIp("127.0.0.1");
        urlDataDTO.setLogId("adfasdfasdfa");
        urlDataDTO.setRequestTime(1111l);
        urlDataDTO.setJsonContent(json);
        urlDataDTO.setStatus(1);

        storeDataManager.store(MsgTypeEnums.URL, urlDataDTO);
        System.in.read();
    }

}