package com.estate.expert.admin.io;
|
|
import com.estate.expert.admin.domain.exam.eval.formatter.impl.DeviceFuzzySummaryResultFormatter;
|
import com.estate.expert.admin.domain.exam.eval.formatter.impl.DeviceScoreResultSummaryFormatter;
|
import com.estate.expert.admin.domain.exam.eval.formatter.impl.SysFuzzyResultFormatter;
|
import com.estate.expert.admin.domain.exam.eval.formatter.impl.SysScoreResultFormatter;
|
import com.estate.expert.admin.service.DeviceService;
|
import com.estate.expert.admin.service.eval.EvalFuzzyService;
|
import com.estate.expert.admin.service.eval.EvalScoreService;
|
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.IOException;
|
import java.nio.file.Files;
|
import java.nio.file.Path;
|
|
@Slf4j
|
@SpringBootTest
|
@ExtendWith(SpringExtension.class)
|
@Transactional
|
public class EvalResultFormatterTest {
|
|
@Resource
|
EvalFuzzyService fuzzyService;
|
|
@Resource
|
EvalScoreService scoreService;
|
|
@Resource
|
DeviceService deviceService;
|
|
@Resource
|
ObjectMapper objectMapper;
|
|
@Test
|
public void testFormatSysFuzzy() throws IOException {
|
var results = fuzzyService.findAll();
|
var res = results.get( results.size() - 1);
|
|
var formatter = new SysFuzzyResultFormatter();
|
var table = formatter.format(res);
|
// write to file
|
Files.write(Path.of("/Volumes/Works/tmp/sys_fuzzy_format.json"), objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(table).getBytes());
|
}
|
|
@Test
|
public void testFormatSysScore() throws IOException {
|
var results = scoreService.findAll();
|
var res = results.get( results.size() - 1);
|
|
var formatter = new SysScoreResultFormatter();
|
var table = formatter.format(res);
|
Files.write(Path.of("/Volumes/Works/tmp/sys_score_format.json"), objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(table).getBytes());
|
}
|
|
@Test
|
public void testFormatDeviceFuzzySummary() throws IOException {
|
var results = fuzzyService.findAll();
|
var res = results.get( results.size() - 1);
|
|
var formatter = new DeviceFuzzySummaryResultFormatter(deviceService);
|
var table = formatter.format(res);
|
Files.write(Path.of("/Volumes/Works/tmp/device_fuzzy_format.json"), objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(table).getBytes());
|
}
|
|
@Test
|
public void testFormatDeviceScoreSummary() throws IOException {
|
var results = scoreService.findAll();
|
var res = results.get( results.size() - 1);
|
|
var formatter = new DeviceScoreResultSummaryFormatter(deviceService);
|
var table = formatter.format(res);
|
Files.write(Path.of("/Volumes/Works/tmp/device_score_format.json"),
|
objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(table).getBytes());
|
}
|
|
}
|