package com.prolog.cs.biz.inbound.service.impl.mq;

import com.alibaba.fastjson.JSONObject;
import com.prolog.entity.vo.InBoundRequestVO;
import com.prolog.inte.EisHandler;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.util.Lists;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

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

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class RabbitMQInBoundProducerImplTest {

    @Resource
    EisHandler eisHandler;

    @Test
    public void inBoundRequest() {
        String textStr = "{\n" +
                "  \"msgId\": \"test_f3dba58af9cd\",\n" +
                "  \"warehouseId\": \"test_3b9c2dd362fc\",\n" +
                "  \"enterpriseId\": \"test_4ddf6a7b81a0\",\n" +
                "  \"containerNo\": \"test_a663ed15b843\",\n" +
                "  \"taskId\": \"test_bb6d5811da37\",\n" +
                "  \"workType\": \"test_7d3790c535fc\",\n" +
                "  \"businessType\": \"test_adc6ac54c35f\",\n" +
                "  \"wmsLocationCode\": \"test_544acd0a97a0\",\n" +
                "  \"originalArea\": \"test_ec2e2bce9df9\",\n" +
                "  \"originalLocation\": \"test_f883b32739ba\",\n" +
                "  \"targetArea\": \"test_c42f7745771d\",\n" +
                "  \"targetLocation\": \"test_70eb3a958d85\",\n" +
                "  \"subList\": [\n" +
                "    {\n" +
                "      \"ownerId\": \"test_c9ee572c93a0\",\n" +
                "      \"itemId\": \"test_566ba2fc5665\",\n" +
                "      \"lotId\": \"test_f18378f2a4cf\",\n" +
                "      \"packId\": \"test_f2b91606775d\",\n" +
                "      \"qty\": \"test_5adc0c204869\",\n" +
                "      \"attrStr1\": \"test_578e761ba217\",\n" +
                "      \"attrStr2\": \"test_c4f3b34ee760\",\n" +
                "      \"attrStr3\": \"test_7334d8c78e0b\",\n" +
                "      \"attrStr4\": \"test_be2305c212c8\",\n" +
                "      \"attrStr5\": \"test_33b93ffa94fb\"\n" +
                "    }\n" +
                "  ]\n" +
                "}";
        InBoundRequestVO inBoundRequestVO = JSONObject.parseObject(textStr, InBoundRequestVO.class);
        List<InBoundRequestVO> list = Lists.newArrayList(inBoundRequestVO);
        log.info("inBoundRequestVO:{}", JSONObject.toJSONString(list));
        eisHandler.inBoundRequest(list);
//        try {
//            Thread.sleep(60000);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
    }
}