package com.izouma.nineth.service;

import com.github.binarywang.wxpay.exception.WxPayException;
import com.izouma.nineth.ApplicationTests;
import com.izouma.nineth.domain.Order;
import com.izouma.nineth.enums.OrderStatus;
import com.izouma.nineth.repo.OrderRepo;
import org.apache.commons.codec.EncoderException;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

public class OrderServiceTest extends ApplicationTests {
    @Autowired
    private OrderService orderService;
    @Autowired
    private OrderRepo    orderRepo;

    @Test
    public void create() throws EncoderException, WxPayException {
        Order order = orderService.create(1110L, 1777L, 1, null, 1896L, null);
        assert order.getStatus() == OrderStatus.FINISH;
    }

    @Test
    public void setNumber() {
        orderService.setNumber();
    }

    @Test
    public void setSales() {
        orderService.setSales();
    }

    @Test
    public void commission() {
        orderService.commission(orderRepo.findById(4437L).get());
    }

    @Test
    public void refund() throws WxPayException {
        orderService.refund(4627L);
    }
}