/**
 * Copyright (c) 2018 人人开源 All rights reserved.
 * <p>
 * https://www.renren.io
 * <p>
 * 版权所有，侵权必究！
 */

package test.com.pjilisense.flxai.controller;

import com.alibaba.fastjson.JSON;
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 KnowledgeBasesControllerTest {
    @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 testGet() {
        String url = TestUtils.WebconnectURL+"/api/robot/knowledgebases/kb_E5EcemGyKnh9";
        String charset = TestUtils.UTF8;
        try {
            String body = TestUtils.doGet(url, charset);
            System.out.println(body);
        } catch (Exception e) {
            e.printStackTrace();
        }
        //{"code":0,"msg":"success","data":{"id":"kb_E5EcemGyKnh9","name":"知识库1","description":"知识库测试2","avatar":null,"type":null,"userId":"fd8ae359-64dc-4a57-ab41-5438e2fda975","isPublic":false,"settings":null,"createdAt":"2025-01-14 14:27:55","updatedAt":"2025-01-16 16:01:51","accessedAt":"2025-01-14 14:27:55"}}
    }
//    @Test
//    public void testsave() {
//        String url = TestUtils.WebconnectURL+"/api/robot/knowledgebases/";
//        String charset = TestUtils.UTF8;
//        try {
//            Map<String, Object> params = new HashMap<String, Object>();
////            params.put("id","kb_E5EcemGyKnh9");
//            params.put("name","知识库4");
//            params.put("description","知识库4测试");
//            params.put("userId","fd8ae359-64dc-4a57-ab41-5438e2fda975");
//            params.put("isPublic",true);
////            params.put("createdAt","2025-01-14 14:27:55");
////            params.put("updatedAt","2025-01-14 14:27:55");
////            params.put("accessedAt","2025-01-14 14:27:55");
////            "id":"kb_E5EcemGyKnh9",
////                    "name":"知识库1",
////                    "description":"知识库测试2",
////                    "avatar":null,
////                    "type":null,
////                    "userId":"fd8ae359-64dc-4a57-ab41-5438e2fda975",
////                    "isPublic":false,
////                    "settings":null,
////                    "createdAt":"2025-01-14 14:27:55",
////                    "updatedAt":"2025-01-14 14:27:55",
////                    "accessedAt":"2025-01-14 14:27:55"
//
//            String body = TestUtils.doPost(url, JSON.toJSONString(params), charset);
//            System.out.println(body);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
    @Test
    public void testmodifyDescriptuon() {
        String url = TestUtils.WebconnectURL+"/api/robot/knowledgebases/modifyDescriptuon";
        String charset = TestUtils.UTF8;
        try {
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("id","kb_E5EcemGyKnh9");
            params.put("description","知识库测试23");
            String body = TestUtils.doPost(url, JSON.toJSONString(params), charset);
            System.out.println(body);
        } catch (Exception e) {
            e.printStackTrace();
        }
        //param ={"description":"知识库测试23","id":"kb_E5EcemGyKnh9"}
        //{"code":0,"msg":"success","data":true}
    }
}