package com.xiaomai.cases.polar.goods;

import com.alibaba.fastjson.JSONObject;
import com.xiaomai.cases.polar.goods.Tools.GoodTools;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class deleteGood extends XMBaseTest {

    GoodTools goodTools=new GoodTools();

    @BeforeMethod
    public void beforeTest() {
        xmAppApi.setApiModule(ApiModule.Polar_Goods)
                .setApiName("API_delete")
                .setLoginUser(LoginAccount.YFF_RC)
                .setTerminal(Terminal.B);

        dal.setCase_owner("yff")
                .setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
        super.beforeTest();
    }


    @Test(description = "删除物品")
    public void testCreateGoods() {

//        JSONObject jsonObject=goodTools.testCreateGoods(true);

        //获取物品列表
        JSONObject studioGoods= goodTools.studioGoods();
        String id=studioGoods.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("id");

        JSONObject jsonObject = new JSONObject();

        jsonObject.put("id", id);
        jsonObject.put("brandId", dataApi.getLoginInfo().getBrandId());
        jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
        jsonObject.put("operatorId", dataApi.getLoginInfo().getAdminId());

        xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);


        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void xun(){
        for(int i=0;i<46;i++){
            testCreateGoods();
        }
    }
}