package com.izouma.jiashanxia.service;

import cn.hutool.core.collection.CollUtil;
import com.izouma.jiashanxia.domain.User;
import com.izouma.jiashanxia.dto.PageQuery;
import com.izouma.jiashanxia.dto.PromotionDTO;
import com.izouma.jiashanxia.exception.BusinessException;
import com.izouma.jiashanxia.repo.UserRepo;
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.data.domain.Page;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;


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

    @Autowired
    private UserService userService;
    @Autowired
    private UserRepo    userRepo;

    @Test
    public void myPromotion() {
//        Page<PromotionDTO> users = userService.myPromotion(new PageQuery(), 40L);
        Set<User> users = userService.myPromotion( 125L);
        users.forEach(System.out::println);
    }

    @Test
    public void test1() {
        User user = userRepo.findById(1L).orElseThrow(new BusinessException("无用户"));
        System.out.println(userService.myEmployee(new PageQuery(), user).getContent());
    }

    @Test
    public void test2() {
//        System.out.println(userService.overview(102L));
//        System.out.println(1 * 0.01);
        List<Integer> newList = CollUtil.newArrayList(1,2,3,4,5,6,7);
//        List<Integer> newList1= new ArrayList<>(newList);
        List<Integer> oldList = CollUtil.newArrayList(4,5,6,7,8,9,10);
        List<Integer> oldList1= new ArrayList<>(oldList);
        System.out.println(oldList.removeAll(newList));
        System.out.println(newList);
        System.out.println(oldList);
        System.out.println("----------");
        System.out.println(newList.removeAll(oldList1));
        System.out.println(newList);
        System.out.println(oldList1);
    }
}