package com.prolog.cs.biz.outbound.service.impl;

import com.alibaba.fastjson.JSON;
import com.prolog.cs.biz.outbound.Application;
import com.prolog.cs.biz.outbound.dao.WaveBillMapper;
import com.prolog.cs.biz.outbound.resource.OperateResource;
import com.prolog.cs.biz.outbound.resource.WarehouseResource;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.exception.BizException;
import com.prolog.upcloud.base.wh.operate.vo.ReplenishCancelVO;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

import java.math.BigDecimal;


/**
 * 基础测试类
 *
 * @author stylefeng
 * @Date 2017/5/21 16:10
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
@WebAppConfiguration
@Slf4j
//@Transactional //打开的话测试之后数据可自动回滚
public class WarehouseTest {

    @Autowired
    WebApplicationContext webApplicationContext;
    @Autowired
    OperateResource OperateResource;

    @Autowired
    private WarehouseResource warehouseResource;

    protected MockMvc mockMvc;

    @Autowired
    private WaveBillMapper billMapper;
    
    @Before
    public void setupMockMvc(){
        mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
    }

    @Before
    public void initDatabase(){
    }

    
    @Test
    public void cancelReplenish() throws Exception {
        ReplenishCancelVO vo = new ReplenishCancelVO();
        vo.setDetailIds("132,123412".split(","));
        RestMessage restMessage1 = OperateResource.cancelReplenish(vo);
        if (!restMessage1.isSuccess()) {
            throw new BizException("调用库内补货取消接口出错: " + restMessage1.getMessage());
        }
    }

    @Test
    public void getLocationBasicInfos() throws Exception {
        String[] locatorIds= {"KQLOCATOR06672"};
        System.out.println(JSON.toJSONString(warehouseResource.getLocationBasicInfos(locatorIds)));
    }

    public static void main(String[] args) {
//        List list= Arrays.asList(new Integer[]{1,2,3,4});
//        list.forEach(x -> {
//            if((Integer) x==2){
//                return;
//            }
//            System.out.println(x);
//        });
        long l=0L;
        System.out.println(l==0);
        //System.out.println(new BigDecimal(51).divide(new BigDecimal(10),0,BigDecimal.ROUND_UP));
    }
}
