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");
|
}
|
|
}
|