RemoteCUserServiceTest.java
1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package cn.com.glsx.admin.modules.remote;
import cn.com.glsx.Application;
import cn.com.glsx.auth.api.AuthFeignClient;
import cn.com.glsx.auth.model.SyntheticUser;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.usercenter.api.dto.response.CUser;
import cn.hutool.json.JSONUtil;
import com.glsx.plat.core.web.R;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
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 java.util.Map;
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class RemoteCUserServiceTest {
@Autowired
private RemoteCUserService remoteCUserService;
@Autowired
private AuthFeignClient authFeignClient;
@BeforeEach
public void runBeforeTestMethod() {
R<SyntheticUser> userR = authFeignClient.getAuthUserById(1L);
ShieldContextHolder.setUser(userR.getData(SyntheticUser.class));
}
@Test
public void getCUserMapByCUserIds() {
Map<Long, CUser> userMap = remoteCUserService.getLocalUserMap(Lists.newArrayList(1L, 2L, 3L, 4L, 5L));
System.out.println("userMap = " + JSONUtil.toJsonStr(userMap));
}
}