package com.prolog.cs.biz.inbound.controller.external;

import com.alibaba.fastjson.JSONObject;
import com.prolog.cs.biz.inbound.model.EisToWmsMiddle;
import com.prolog.cs.biz.inbound.utils.SpringUtils;
import com.prolog.cs.biz.inbound.vo.EisWmsRequestParamVO;
import com.prolog.framework.common.message.RestMessage;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

@SpringBootTest
@RunWith(SpringRunner.class)
public class ExternalControllerTest {

    @Test
    public void acceptEisContainerMessage() {
        ExternalController controller = SpringUtils.getBeansByType(ExternalController.class);
//        String msg = "{\n" +
//                "  \"msgId\": \"c5d4390baa0248e8a0af792356e90b9c\",\n" +
//                "  \"warehouseId\": \"901884530611326976\",\n" +
//                "  \"enterpriseId\": \"900356013474058240\",\n" +
//                "  \"taskId\": \"909500053184450560\",\n" +
//                "  \"containerNo\": \"800472\"\n" +
//                "}";
        String msg = "{\n" +
                "  \"msgId\": \"b8ecd578d701421ba6b2bfff0b99eadb\",\n" +
                "  \"warehouseId\": \"901884530611326976\",\n" +
                "  \"enterpriseId\": \"900356013474058240\",\n" +
                "  \"taskId\": \"908046180380971008\",\n" +
                "  \"containerNo\": \"800500\",\n" +
                "  \"workType\": \"10\",\n" +
                "  \"businessType\": \"PO_NORM\",\n" +
                "  \"wmsLocationCode\": \"AGVZ\",\n" +
                "  \"attrStr1\": null,\n" +
                "  \"attrStr2\": null,\n" +
                "  \"attrStr3\": null,\n" +
                "  \"attrStr4\": null,\n" +
                "  \"attrStr5\": null,\n" +
                "  \"containerType\": null,\n" +
                "  \"lotId\": null,\n" +
                "  \"ownerId\": null,\n" +
                "  \"packId\": null,\n" +
                "  \"qty\": null,\n" +
                "  \"itemId\": null,\n" +
                "  \"seqNo\": null\n" +
                "}";
        EisWmsRequestParamVO vo = JSONObject.parseObject(msg, EisWmsRequestParamVO.class);
        RestMessage<List<EisToWmsMiddle>> result = controller.acceptEisToWmsRequestMessage(vo);
        Assert.assertEquals(result.isSuccess(), false);
    }
}