Skip to content

Commit 7482a8d

Browse files
Merge branch 'develop' into feature/dao-unit-tests
2 parents 7e0dc11 + 9f6a114 commit 7482a8d

29 files changed

+636
-67
lines changed

CHANGELOG.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
Features:
66
- Added unit tests for checking DAO's -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/80)
77

8-
## 0.3.8 (Unreleased)
8+
## 0.3.8 (2020-03-11)
99

1010
Features:
11-
- [Doc] Update Swagger with Statistic endpoints -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/76)
11+
- Update Swagger with Statistic endpoints -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/76)
12+
- Mark import as failed when import is failed -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/79)
13+
14+
Bugfixes:
15+
- Import was finished with Error! You are trying to edit entity which is locked -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/44)
16+
- Incorrect "Duration" count if import several *.json's -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/37)
1217

13-
Features:
14-
- [BUG] Import was finished with Error! You are trying to edit entity which is locked -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/44)
1518
## 0.3.7 (2020-03-02)
1619

1720
Features:

src/main/java/main/model/db/imports/BaseImporter.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ private void updateImportTestRun() throws AqualityException {
8888
}
8989

9090
void logToImport(String log) throws AqualityException {
91+
importDto.setProject_id(this.projectId);
9192
importDto.addToLog(log);
9293
importDto = importDao.create(importDto);
9394
}
@@ -105,22 +106,15 @@ private void createTestRun() throws AqualityException {
105106
}
106107
}
107108
else{
108-
createTestRun((testRun.getBuild_name() != null && !testRun.getBuild_name().equals(""))
109-
? testRun.getBuild_name()
110-
: file.getName().substring(0, file.getName().lastIndexOf(".")));
109+
setTestRunStartDate();
110+
setTestRunFinishDate();
111+
testRun.setTest_suite_id(testSuite.getId());
112+
testRun.setId(controllerFactory.getHandler(testRun).create(testRun).getId());
111113
}
112114
updateImportTestRun();
113115
logToImport("Test Run is updated.");
114116
}
115117

116-
private void createTestRun(String buildName) throws AqualityException {
117-
testRun.setBuild_name(buildName);
118-
setTestRunStartDate();
119-
setTestRunFinishDate();
120-
testRun.setTest_suite_id(testSuite.getId());
121-
testRun.setId(controllerFactory.getHandler(testRun).create(testRun).getId());
122-
}
123-
124118
private void setTestRunStartDate(){
125119
Comparator<TestResultDto> startDate = Comparator.comparing(TestResultDto::getStart_date);
126120
if(testRun.getStart_time() == null){

src/main/java/main/model/db/imports/Handler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
public abstract class Handler extends DefaultHandler {
1818
protected SAXParser parser;
19+
protected TestRunDto testRun = new TestRunDto();
1920
public Handler() throws AqualityException {
2021
try {
2122
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
@@ -33,4 +34,7 @@ public Handler() throws AqualityException {
3334
public abstract TestRunDto getTestRun();
3435
public abstract List<TestDto> getTests();
3536
public abstract List<TestResultDto> getTestResults();
37+
public void setTestRun(TestRunDto testRun){
38+
this.testRun = testRun;
39+
}
3640
}

src/main/java/main/model/db/imports/HandlerFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
import main.model.db.imports.ImportHandlers.*;
55

66
import java.io.File;
7+
import java.util.Date;
78

89
class HandlerFactory {
9-
Handler getHandler(File file, String type, TestNameNodeType testNameNodeType) throws AqualityException {
10+
Handler getHandler(File file, String type, TestNameNodeType testNameNodeType, Date finishTime) throws AqualityException {
1011
switch (ImportTypes.valueOf(type)){
1112
case MSTest:
1213
if(testNameNodeType == null){
@@ -23,7 +24,7 @@ Handler getHandler(File file, String type, TestNameNodeType testNameNodeType) th
2324
return new JavaTestNG(file, testNameNodeType);
2425
case Cucumber:
2526
case TestNGCucumber:
26-
return new Cucumber(file);
27+
return new Cucumber(file, finishTime);
2728
case PHPCodeception:
2829
return new PHPCodeception(file);
2930
case NUnit_v2:

src/main/java/main/model/db/imports/ImportHandlers/Cucumber.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@
1616

1717
public class Cucumber extends Handler{
1818
private List<FeatureDto> features;
19-
private TestRunDto testRun;
2019
private List<TestDto> tests = new ArrayList<>();
2120
private List<TestResultDto> results = new ArrayList<>();
2221
private DateUtils dateUtils = new DateUtils();
2322
private FeatureDto currentFeature;
2423
private TestResultDto currentResult;
2524
private Integer testTime = 0;
26-
private Date dateCounter = new Date();
25+
private Date dateCounter;
2726
private boolean previousWasBackground = false;
2827
private TestDto currentTest;
2928

30-
public Cucumber(@NotNull File file) throws AqualityException {
29+
public Cucumber(@NotNull File file, Date finishTime) throws AqualityException {
3130
super();
3231
FileUtils fileUtils = new FileUtils();
3332
String json = fileUtils.readFile(file.getPath());
3433
CucumberUtils cucumberUtils = new CucumberUtils(json);
3534
this.features = cucumberUtils.getFeatures();
35+
dateCounter = finishTime;
3636
parse();
3737
}
3838

@@ -42,9 +42,9 @@ private void parse() {
4242

4343
private void handleTestRun() {
4444
testRun = new TestRunDto();
45-
testRun.setStart_time(dateCounter);
46-
features.forEach(this::handleFeature);
4745
testRun.setFinish_time(dateCounter);
46+
features.forEach(this::handleFeature);
47+
testRun.setStart_time(dateCounter);
4848
}
4949

5050
private void handleFeature(@NotNull FeatureDto feature) {
@@ -72,14 +72,14 @@ private void handleScenario(@NotNull ScenarioDto scenario) {
7272
String[] strings = scenario.getId().split(";;");
7373
currentTest.setName(String.format("%s: %s%s", currentFeature.getName(), scenario.getName(), strings.length > 1 ? String.format(": %s", strings[1]) : ""));
7474

75-
currentResult.setStart_date(dateCounter);
75+
currentResult.setFinish_date(dateCounter);
7676
if(currentResult.getFail_reason() == null) currentResult.setFail_reason("");
7777
if(scenario.getBefore() != null) scenario.getBefore().forEach(this::handleStep);
7878
scenario.getSteps().forEach(this::handleStep);
7979
if(scenario.getAfter() != null) scenario.getAfter().forEach(this::handleStep);
80-
dateCounter = dateUtils.addMS(dateCounter, testTime);
80+
dateCounter = dateUtils.removeMS(dateCounter, testTime);
81+
currentResult.setStart_date(dateCounter);
8182
testTime = 0;
82-
currentResult.setFinish_date(dateCounter);
8383
tests.add(currentTest);
8484
results.add(currentResult);
8585
} else {

src/main/java/main/model/db/imports/ImportHandlers/JavaTestNG.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ public List<TestDto> getTests() {
4545
public List<TestResultDto> getTestResults() {
4646
return handler.getTestResults();
4747
}
48+
49+
public void setTestRun(TestRunDto testRun){
50+
handler.setTestRun(testRun);
51+
}
4852
}

src/main/java/main/model/db/imports/ImportHandlers/NUnitV2.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ public List<TestDto> getTests() {
4545
public List<TestResultDto> getTestResults() {
4646
return handler.getTestResults();
4747
}
48+
49+
public void setTestRun(TestRunDto testRun){
50+
handler.setTestRun(testRun);
51+
}
4852
}

src/main/java/main/model/db/imports/ImportHandlers/NUnitV3.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@ public List<TestDto> getTests() {
4646
public List<TestResultDto> getTestResults() {
4747
return handler.getTestResults();
4848
}
49+
50+
public void setTestRun(TestRunDto testRun){
51+
handler.setTestRun(testRun);
52+
}
4953
}

src/main/java/main/model/db/imports/ImportHandlers/PHPCodeception.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ public List<TestDto> getTests() {
4545
public List<TestResultDto> getTestResults() {
4646
return handler.getTestResults();
4747
}
48+
49+
public void setTestRun(TestRunDto testRun){
50+
handler.setTestRun(testRun);
51+
}
4852
}

src/main/java/main/model/db/imports/ImportHandlers/Robot.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ public List<TestDto> getTests() {
4545
public List<TestResultDto> getTestResults() {
4646
return handler.getTestResults();
4747
}
48+
49+
public void setTestRun(TestRunDto testRun){
50+
handler.setTestRun(testRun);
51+
}
4852
}

0 commit comments

Comments
 (0)