package com.prolog.upcloud.base.wh.operate.controller;

import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import com.prolog.entity.vo.CompleteTaskVO;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.upcloud.base.wh.operate.WhOperateApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = {WhOperateApplication.class})
public class ExternalControllerTest {
    @Resource
    ExternalController externalController;

    @Test
    public void completeTask() {
        String msg = "[{\n" +
                "  \"msgId\": \"msgId_1ba9961911ca\",\n" +
                "  \"warehouseId\": \"warehouseId_9fdd16aab0b5\",\n" +
                "  \"workType\": \"workType_73efbbb93a00\",\n" +
                "  \"businessType\": \"businessType_8fce6b978506\",\n" +
                "  \"taskId\": \"taskId_e2e0e74a552e\",\n" +
                "  \"billNo\": \"billNo_8aa643a41e58\",\n" +
                "  \"containerNo\": \"containerNo_8af244d789ef\",\n" +
                "  \"taskLineId\": \"taskLineId_165ec8f48d1f\",\n" +
                "  \"ownerId\": \"ownerId_aa18491cef65\",\n" +
                "  \"itemId\": \"itemId_6d866fdfea7b\",\n" +
                "  \"lotId\": \"lotId_d4e5b42b59d5\",\n" +
                "  \"packId\": \"packId_6c66c0182579\",\n" +
                "  \"wmsLocationCode\": \"wmsLocationCode_4ae6b652b6e0\",\n" +
                "  \"originalArea\": \"originalArea_8f99a44edfa7\",\n" +
                "  \"locNo\": \"locNo_e5f118b8b304\",\n" +
                "  \"inventoryQty\": 0.00,\n" +
                "  \"lackQty\": 0.00,\n" +
                "  \"isLack\": \"isLack_14baefa500e4\",\n" +
                "  \"countQty\": 0.00,\n" +
                "  \"employeeId\": \"employeeId_ca6acccfc293\",\n" +
                "  \"itemList\": [\n" +
                "    {\n" +
                "      \"locationNo\": \"locationNo_803632f6c80c\",\n" +
                "      \"inventoryQty\": 0.00,\n" +
                "      \"yhResult\": \"yhResult_c6e2f8b92072\",\n" +
                "      \"yhItem1\": \"yhItem1_5d35ee08739f\",\n" +
                "      \"yhItem2\": \"yhItem2_2ca839dea567\",\n" +
                "      \"yhItem3\": \"yhItem3_b53c55bfc9d4\",\n" +
                "      \"yhItem4\": \"yhItem4_acfaf4aa631a\",\n" +
                "      \"yhItem5\": \"yhItem5_5595343246eb\",\n" +
                "      \"yhItem6\": \"yhItem6_1f599a591ecd\",\n" +
                "      \"yhItem7\": \"yhItem7_1ca4c2bb9e02\",\n" +
                "      \"yhItem9\": \"yhItem9_d12a9475014f\",\n" +
                "      \"yhItem10\": \"yhItem10_60924f2b68df\",\n" +
                "      \"yhItem11\": \"yhItem11_9fbe145b5f81\",\n" +
                "      \"yhItem12\": \"yhItem12_025fce8d4f75\"\n" +
                "    }\n" +
                "  ]\n" +
                "}]";
        List<CompleteTaskVO> list = JSONObject.parseArray(msg, CompleteTaskVO.class);
        externalController.completeTask(list);

    }

    @Test
    public void getToken() {
        Map<String, Object> map = Maps.newHashMap();
        RestMessage<Object> token = externalController.getToken(null);
        System.out.println(JSONObject.toJSONString(token));
    }
}