“mitao”
2026-01-20 4e5beb844f03daec12f2b039365730b0683f8a9e
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package com.estate.expert.admin.service;
 
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
 
/**
 *  报告服务测试
 **/
@Slf4j
@SpringBootTest
@ExtendWith(SpringExtension.class)
@Transactional
public class ReportServiceTest {
 
    @Resource
    private ReportService reportService;
 
    @Resource
    ObjectMapper objectMapper;
 
    @Test
    public void testSystemReportData() throws IOException {
        var reportData = reportService.scoreReportData(1347, 1);
        var string = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(reportData);
        // write to file
        Files.writeString(new File("/Volumes/Works/tmp/system_report.json").toPath(), string);
    }
 
    @Test
    public void testSystemReportData2() throws IOException {
        var reportData = reportService.scoreReportData(1222, 1);
        var string = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(reportData);
        // write to file
        Files.writeString(new File("/Volumes/Works/tmp/system_report_2.json").toPath(), string);
    }
 
    @Test
    public void testFuzzyReportData() throws IOException {
        var reportData = reportService.fuzzyReportData(1347, 1);
        var string = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(reportData);
        Files.writeString(new File("/Volumes/Works/tmp/fuzzy_report.json").toPath(), string);
    }
 
    @Test
    public void testDeviceReportData() throws IOException {
        var reportData = reportService.fuzzyReportData(1256, 2);
        var string = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(reportData);
 
        // write to file
        Files.writeString(new File("/Volumes/Works/tmp/device_report.json").toPath(), string);
    }
 
    @Test
    public void testBuildSystemFuzzyReport() throws IOException {
        var template = reportService.fuzzyReport(1347, 1);
        template.writeToFile("/Volumes/Works/tmp/system_fuzzy_report.docx");
    }
 
    @Test
    public void testBuildDeviceFuzzyReport() throws IOException {
        var template = reportService.fuzzyReport(555, 2);
        template.writeToFile("/Volumes/Works/tmp/device_fuzzy_report.docx");
    }
 
    @Test
    public void testBuildSystemScoreReport() throws IOException {
        var template = reportService.scoreReport(1256, 1);
        template.writeToFile("/Volumes/Works/tmp/system_score_report.docx");
    }
 
    @Test
    public void testBuildSystemScoreReport2() throws IOException {
        var template = reportService.scoreReport(1222, 1);
        template.writeToFile("/Volumes/Works/tmp/system_score_report_2.docx");
    }
 
    @Test
    public void testBuildDeviceScoreReport() throws IOException {
        var template = reportService.scoreReport(1, 2);
        template.writeToFile("/Volumes/Works/tmp/device_score_report.docx");
    }
 
}