package test.com.pjilisense.flxai.controller;

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiModelProperty;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import test.com.pjilisense.flxai.TestUtils;

import java.util.HashMap;
import java.util.Map;

public class MyDigitalHumanControllerTest {

    @BeforeEach
    public void setUpTestDataWithinTransaction() {
        // set up test data within the transaction
    }
    @AfterEach
    public void tearDownWithinTransaction() {
        // execute "tear down" logic within the transaction
    }

    @Test
    public void testGetAllAiTools() {
        String url = TestUtils.WebconnectURL+"/api/robot/mydigitalhuman/queryAll?language=ch";
        String charset = TestUtils.UTF8;
        try {
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("language","zh");
            String body = TestUtils.doPost(url, JSON.toJSONString(params), charset);
            System.out.println(body);
        } catch (Exception e) {
            e.printStackTrace();
        }
        //param ={"language":"zh"}
        //{"code":0,"msg":"success","data":[{"id":"1896763411581108225","name":"音色Modify","voicePath":"uploads/202503/5c799cffa5864619b817063f77fe734e.MP3","imgPath":"1896761492913520641","language":"zh"}]}
    }
    @Test
    public void testSave() {
        String url = TestUtils.WebconnectURL+"/api/robot/mydigitalhuman";
        String charset = TestUtils.UTF8;
        try {
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("userid","fd8ae359-64dc-4a57-ab41-5438e2fda975");
            params.put("imageid","1896761492913520641");
            params.put("sceneimgid","1896761492913520641");
            params.put("bkimgid","1896761492913520641");
            params.put("voiceid","1896763411581108225");
            params.put("videoimg","1896763411581108225");
            params.put("videodir","genvideo/202503/5c799cffa5864619b817063f77fe734d.mp4");
            params.put("voicedir","genvoice/202503/A1");
            String body = TestUtils.doPost(url, JSON.toJSONString(params), charset);
            System.out.println(body);
            //param ={"voiceid":"1896763411581108225","videodir":"genvideo/202503/5c799cffa5864619b817063f77fe734d.mp4","imageid":"1896761492913520641","bkimgid":"1896761492913520641","voicedir":"genvoice/202503/A1","videoimg":"1896763411581108225","userid":"fd8ae359-64dc-4a57-ab41-5438e2fda975","sceneimgid":"1896761492913520641"}
            //{"code":0,"msg":"success","data":null}
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    @Test
    public void testupdate() {
        String url = TestUtils.WebconnectURL+"/api/robot/mydigitalhuman";
        String charset = TestUtils.UTF8;
        try {
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("id","1896816581502042113");
            params.put("userid","fd8ae359-64dc-4a57-ab41-5438e2fda975");
            params.put("imageid","1896761492913520641");
            params.put("sceneimgid","1896761492913520641");
            params.put("bkimgid","1896761492913520641");
            params.put("voiceid","1896763411581108225");
            params.put("videoimg","1896763411581108225");
            params.put("videodir","genvideo/202503/5c799cffa5864619b817063f77fe734d.mp4");
            params.put("voicedir","genvoice/202503/A2");
            String body = TestUtils.doPut(url, JSON.toJSONString(params), charset);
            System.out.println(body);
            //param ={"voiceid":"1896763411581108225","videodir":"genvideo/202503/5c799cffa5864619b817063f77fe734d.mp4","imageid":"1896761492913520641","bkimgid":"1896761492913520641","voicedir":"genvoice/202503/A2","videoimg":"1896763411581108225","id":"1896816581502042113","userid":"fd8ae359-64dc-4a57-ab41-5438e2fda975","sceneimgid":"1896761492913520641"}
            //{"code":0,"msg":"success","data":null}
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
