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.MQDataDTO;
import com.jay.monitor.data.core.model.serializable.SQLMonitorDTO;
import com.jay.monitor.data.server.MonitorServerApplication;
import com.jay.monitor.data.server.store.StoreDataManager;
import junit.framework.TestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.IOException;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = MonitorServerApplication.class)
public class SQLUserProcessTest extends TestCase {
    @Autowired
    private StoreDataManager storeDataManager;

    @Test
    public void testHandleRequest0() 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\"}";
        SQLMonitorDTO sqlMonitorDTO = JSON.parseObject(json, SQLMonitorDTO.class);
//        mqDataDTO.setStatus(-1);
        storeDataManager.store(MsgTypeEnums.SQL, sqlMonitorDTO);
        System.in.read();
    }
}