UserTest.java 1.1 KB
package com.tianbo.warehouse;

import com.tianbo.warehouse.WarehouseApplication;
import com.tianbo.warehouse.model.ROLE;
import com.tianbo.warehouse.security.CustomUserDetailService;
import lombok.extern.slf4j.Slf4j;
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.security.core.userdetails.UserDetails;
import org.springframework.test.context.junit4.SpringRunner;
import com.tianbo.warehouse.dao.ROLEMapper;

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

@RunWith(SpringRunner.class)
@SpringBootTest(classes = WarehouseApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Slf4j
public class UserTest {

    @Autowired
    CustomUserDetailService customUserDetailService;

    @Resource
    ROLEMapper roleMapper;

    @Test
    public void contextLoads() {

        UserDetails u = customUserDetailService.loadUserByUsername("nmms");
        List<ROLE> roles =  roleMapper.findAllWithChildAndTree();
        log.info("ok");
    }
}