This repository has been archived by the owner on May 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d21aec2
commit ed1f8d4
Showing
4 changed files
with
193 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
src/main/java/com/surenpi/autotest/report/ExcelReport.java
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
src/main/java/com/surenpi/autotest/report/ExcelReportWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.surenpi.autotest.report; | ||
|
||
import com.surenpi.autotest.report.model.ExcelReport; | ||
import com.surenpi.autotest.report.record.ExceptionRecord; | ||
import com.surenpi.autotest.report.record.NormalRecord; | ||
import com.surenpi.autotest.report.record.ProjectRecord; | ||
import com.surenpi.autotest.report.util.DateUtils; | ||
import org.modelmapper.ModelMapper; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.PreDestroy; | ||
import java.io.File; | ||
|
||
/** | ||
* Excel格式报告导出 | ||
* @author suren | ||
*/ | ||
@Component | ||
public class ExcelReportWriter implements RecordReportWriter | ||
{ | ||
private ExcelUtils utils; | ||
|
||
@Override | ||
public void write(ExceptionRecord record) | ||
{ | ||
NormalRecord normalRecord = record.getNormalRecord(); | ||
|
||
ModelMapper mapper = new ModelMapper(); | ||
ExcelReport excelReport = mapper.map(normalRecord, ExcelReport.class); | ||
excelReport.setDetail(record.getStackTraceText()); | ||
excelReport.setStatus(ReportStatus.EXCEPTION.name()); | ||
excelReport.setBeginTime(DateUtils.getDateText(normalRecord.getBeginTime())); | ||
excelReport.setEndTime(DateUtils.getDateText(normalRecord.getEndTime())); | ||
|
||
utils.export(excelReport); | ||
} | ||
|
||
@Override | ||
public void write(NormalRecord normalRecord) | ||
{ | ||
ExcelReport excelReport = new ModelMapper().map(normalRecord, ExcelReport.class); | ||
excelReport.setStatus(ReportStatus.NORMAL.name()); | ||
excelReport.setBeginTime(DateUtils.getDateText(normalRecord.getBeginTime())); | ||
excelReport.setEndTime(DateUtils.getDateText(normalRecord.getEndTime())); | ||
|
||
utils.export(excelReport); | ||
} | ||
|
||
@Override | ||
public void write(ProjectRecord projectRecord) | ||
{ | ||
utils = new ExcelUtils( | ||
new File(projectRecord.getName() + "" + System.currentTimeMillis() + ".xls")); | ||
utils.init(); | ||
} | ||
|
||
@PreDestroy | ||
public void saveFile() | ||
{ | ||
utils.save(); | ||
} | ||
} |
125 changes: 125 additions & 0 deletions
125
src/main/java/com/surenpi/autotest/report/model/ExcelReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* | ||
* | ||
* * Copyright 2002-2007 the original author or authors. | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * http://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.surenpi.autotest.report.model; | ||
|
||
/** | ||
* @author suren | ||
*/ | ||
public class ExcelReport | ||
{ | ||
private String moduleName; | ||
private String moduleDescription; | ||
private String clazzName; | ||
private String methodName; | ||
private String status; | ||
private String project; | ||
private String beginTime; | ||
private String endTime; | ||
private String detail; | ||
|
||
public String getModuleName() | ||
{ | ||
return moduleName; | ||
} | ||
|
||
public void setModuleName(String moduleName) | ||
{ | ||
this.moduleName = moduleName; | ||
} | ||
|
||
public String getModuleDescription() | ||
{ | ||
return moduleDescription; | ||
} | ||
|
||
public void setModuleDescription(String moduleDescription) | ||
{ | ||
this.moduleDescription = moduleDescription; | ||
} | ||
|
||
public String getClazzName() | ||
{ | ||
return clazzName; | ||
} | ||
|
||
public void setClazzName(String clazzName) | ||
{ | ||
this.clazzName = clazzName; | ||
} | ||
|
||
public String getMethodName() | ||
{ | ||
return methodName; | ||
} | ||
|
||
public void setMethodName(String methodName) | ||
{ | ||
this.methodName = methodName; | ||
} | ||
|
||
public String getStatus() | ||
{ | ||
return status; | ||
} | ||
|
||
public void setStatus(String status) | ||
{ | ||
this.status = status; | ||
} | ||
|
||
public String getProject() | ||
{ | ||
return project; | ||
} | ||
|
||
public void setProject(String project) | ||
{ | ||
this.project = project; | ||
} | ||
|
||
public String getBeginTime() | ||
{ | ||
return beginTime; | ||
} | ||
|
||
public void setBeginTime(String beginTime) | ||
{ | ||
this.beginTime = beginTime; | ||
} | ||
|
||
public String getEndTime() | ||
{ | ||
return endTime; | ||
} | ||
|
||
public void setEndTime(String endTime) | ||
{ | ||
this.endTime = endTime; | ||
} | ||
|
||
public String getDetail() | ||
{ | ||
return detail; | ||
} | ||
|
||
public void setDetail(String detail) | ||
{ | ||
this.detail = detail; | ||
} | ||
} |