| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package com.seecoder.dataanalysis.logic.parser.impl;
- import com.seecoder.dataanalysis.logic.parser.ParsingException;
- import com.seecoder.dataanalysis.util.FileUtil;
- import com.seecoder.dataanalysis.vo.EvalExamInfoDTO;
- import com.seecoder.dataanalysis.vo.SimpleLog;
- import org.junit.jupiter.api.AfterEach;
- import org.junit.jupiter.api.BeforeEach;
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.*;
- /**
- * @author miaomuzhi
- * @since 2022/1/30
- */
- class LogParsingServiceImplTest {
- private LogParsingServiceImpl parsingService;
- @BeforeEach
- void setUp() {
- parsingService = new LogParsingServiceImpl();
- parsingService.buildOpTypesTable();
- }
- @AfterEach
- void tearDown() {
- }
- @Test
- void parseLog() throws ParsingException{
- try {
- parsingService.parseLog("dsaf");
- } catch (Exception e) {
- assertEquals(ParsingException.class.getName(), e.getClass().getName());
- }
- String logContent = FileUtil.readFile(getClass().getResource("/sample_logs/gen0.log").getFile());
- SimpleLog simpleLog = parsingService.parseLog(logContent);
- assertEquals(0, simpleLog.getOpType());
- assertEquals(1, simpleLog.getTarget());
- }
- @Test
- void parseLogData() throws ParsingException {
- String logContent = FileUtil.readFile(getClass().getResource("/sample_logs/gen0.log").getFile());
- SimpleLog simpleLog = parsingService.parseLog(logContent);
- Object o = parsingService.parseLogData(simpleLog, false);
- assertTrue(o instanceof EvalExamInfoDTO);
- System.out.println(o);
- }
- @Test
- void parseOpType() throws ParsingException {
- assertEquals("com.seecoder.dataanalysis.vo.EvalExamInfoDTO", parsingService.parseOpType(0));
- try {
- parsingService.parseOpType(-1);
- } catch (Exception e) {
- assertEquals(ParsingException.class.getName(), e.getClass().getName());
- }
- }
- }
|