DashboardServiceTest.java
1.77 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package cn.com.glsx.app.modules.service;
import cn.com.glsx.app.Application;
import cn.com.glsx.app.modules.model.param.BasicSearch;
import cn.com.glsx.app.modules.model.view.LowPowerVO;
import cn.com.glsx.app.modules.model.view.StatisticalInfoVO;
import cn.com.glsx.auth.api.AuthFeignClient;
import cn.com.glsx.auth.model.SyntheticUser;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.hutool.db.Page;
import com.alibaba.fastjson.JSON;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.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 java.util.List;
/**
* @author xiangyanlin
* @date 2022/7/5
*/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class DashboardServiceTest {
@Autowired
private AuthFeignClient authFeignClient;
@BeforeEach
public void runBeforeTestMethod() {
R<SyntheticUser> userR = authFeignClient.getAuthUserById(1L);
ShieldContextHolder.setUser(userR.getData(SyntheticUser.class));
}
@Autowired
private DashboardService dashboardService;
@Test
public void testGetStatisticalInfo() {
StatisticalInfoVO statisticalInfo = dashboardService.getStatisticalInfo();
System.out.println(JSON.toJSONString(statisticalInfo));
}
@Test
public void testListTodayLowPower() {
List<LowPowerVO> list = dashboardService.listTodayLowPower(new Page(1, 10));
System.out.println(JSON.toJSONString(list));
}
}