package org.matrix.actuators.http;

import com.alibaba.fastjson.JSON;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.matrix.actuators.httpclient.HttpClientActuator;
import org.matrix.actuators.httpclient.HttpRequestDetail;
import org.matrix.actuators.httpclient.HttpResponseDetail;
import org.matrix.config.HttpRequestConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
class HttpClientActuatorTest {

    @Autowired
    HttpClientActuator httpClientActuator;

    @Test
    void test(){

        String json = "{\n" +
                "    \"url\": \"http://127.0.0.1:8080/test/tableName\",\n" +
                "    \"method\": \"GET\",\n" +
                "    \"requestType\": \"QUERY\",\n" +
                "    \"requestBodies\": [\n" +
                "        {\n" +
                "            \"key\": \"tableName\",\n" +
                "            \"type\": \"TEXT\",\n" +
                "            \"value\": \"example\"\n" +
                "        }\n" +
                "    ]\n" +
                "}";
         HttpRequestDetail httpRequestDetail1 = JSON.parseObject(json, HttpRequestDetail.class);
        HttpRequestDetail httpRequestDetail = JSON.parseObject(json, HttpRequestDetail.class);
        HttpResponseDetail httpResponseDetail = httpClientActuator.sendHttpRequest(httpRequestDetail,1l,1l);
        System.out.println(httpResponseDetail);
    }

}
