package com.live.cases.fileManage.commonFolder;

import com.alibaba.fastjson.JSONObject;
import com.live.xmutils.GetFolderData;
import com.live.enums.ApiModele;
import com.live.enums.RequestType;
import com.live.enums.Terminal;
import com.live.utils.XMBaseTest;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 删除公共文件列表的文件
 * @author zhangyumeng
 */

public class TestDelCommonFolder extends XMBaseTest {
    @BeforeMethod
    public void beforeTest(){
        xmAppApi.setApiModule(ApiModele.CloudClass_File )
                .setApiName("API_delCommomFolder")
                .setLoginUser("zhangYuM_b")
                .setTerminal(Terminal.B);
        dal.setCase_owner("张莹");
        super.beforeTest();
    }

   @Test
    public void testDelCommonFolderList() throws InterruptedException {
        GetFolderData testCommonFolderList = new GetFolderData();
        JSONObject folderList = testCommonFolderList.getCommonFolderList();
        String id = folderList.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("id");
        System.out.println("获取id" + id);

        JSONObject jsonObject = new JSONObject();
        List StringList = new ArrayList();
        StringList.add(id);
        jsonObject.put("ids", StringList);
        jsonObject.put("instId","1300628703858597889");
        System.out.println("请求" + jsonObject);

        xmAppApi.doRequest(RequestType.JSON,params,jsonObject.toJSONString(),headers).assetsSuccess(true);
        JSONObject responseRes = xmAppApi.getBodyInJSON();

       JSONObject folderList1 = testCommonFolderList.getCommonFolderList();
       String id1 = folderList1.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("id");
       System.out.println("id1  == "+id1);

       Assert.assertEquals("true", responseRes.getString("success"));
       Assert.assertEquals("200", responseRes.getString("code"));
       Assert.assertNotEquals(id1, id);
    }

}
