Skip to content

Commit a4924de

Browse files
Merge pull request #75 from aquality-automation/develop
Develop
2 parents 7a4aab4 + 4835ab3 commit a4924de

21 files changed

+397
-182
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# CHANGELOG
22

3+
## 1.0.0 (Unreleased)
4+
5+
Features:
6+
- Migrate to Angular 9 -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/101)
7+
- Add Execution environment column to Test History table -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/107)
8+
9+
Bugfixes:
10+
- [API] /api/public/test/create-or-update does not update list of suites -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/105)
11+
- External issue link is incorrect on Issues table -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/108)
12+
- Import is blocked when invalid regular expression was saved for issue -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/103)
13+
314
## 0.3.10 (2020-05-17)
415

516
Features:

src/main/java/main/World.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package main;
2+
3+
import lombok.Getter;
4+
import main.exceptions.AqualityException;
5+
import main.model.db.dao.settings.EmailSettingsDao;
6+
import main.model.dto.settings.EmailSettingsDto;
7+
8+
public class World {
9+
10+
private static World instance;
11+
12+
@Getter
13+
private String baseURL;
14+
15+
16+
private World() {
17+
EmailSettingsDao emailSettingsDao = new EmailSettingsDao();
18+
EmailSettingsDto settings;
19+
try {
20+
settings = emailSettingsDao.getEntityById(1);
21+
baseURL = settings.getBase_url();
22+
} catch (AqualityException e) {
23+
e.printStackTrace();
24+
System.out.println("World cannot be initialized!");
25+
}
26+
}
27+
28+
public static World getInstance() {
29+
if (instance == null) {
30+
instance = new World();
31+
}
32+
return instance;
33+
}
34+
35+
public static World updateInstance() {
36+
instance = new World();
37+
return instance;
38+
}
39+
}

src/main/java/main/controllers/Administration/AppSettingsController.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package main.controllers.Administration;
22

3+
import main.World;
34
import main.controllers.BaseController;
45
import main.exceptions.AqualityException;
56
import main.exceptions.AqualityPermissionsException;
@@ -52,7 +53,9 @@ public LdapDto create(LdapDto template) throws AqualityException {
5253
@Override
5354
public AppSettingsDto create(AppSettingsDto template) throws AqualityException {
5455
if (baseUser.isAdmin()) {
55-
return appSettingsDao.create(template);
56+
AppSettingsDto appSettingsDto = appSettingsDao.create(template);
57+
World.updateInstance();
58+
return appSettingsDto;
5659
} else {
5760
throw new AqualityPermissionsException("Account is not allowed to update Application Settings", baseUser);
5861
}

src/main/java/main/controllers/Project/ResultController.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import java.util.ArrayList;
1313
import java.util.List;
14+
import java.util.stream.Collectors;
1415

1516
public class ResultController extends BaseController<TestResultDto> {
1617
private final TestResultDao testResultDao;
@@ -153,20 +154,24 @@ private List<TestResultDto> fillResults(List<TestResultDto> results) throws Aqua
153154
testTemplate.setProject_id(projectId);
154155
List<TestDto> tests = testController.get(testTemplate);
155156

157+
TestResultAttachmentDto testResultAttachmentTemplate = new TestResultAttachmentDto();
158+
testResultAttachmentTemplate.setProject_id(projectId);
159+
List<TestResultAttachmentDto> testResultAttachments = get(testResultAttachmentTemplate);
160+
156161
ProjectUserDto projectUserDto = new ProjectUserDto();
157162
projectUserDto.setProject_id(projectId);
158163

159164
boolean isStepsEnabled = projectController.isStepsEnabled(projectId);
160165

161166
for (TestResultDto result : results) {
162-
fillResult(result, finalResults, tests, issues, isStepsEnabled);
167+
fillResult(result, finalResults, tests, issues, testResultAttachments, isStepsEnabled);
163168
}
164169
}
165170

166171
return results;
167172
}
168173

169-
private void fillResult(TestResultDto result, List<FinalResultDto> finalResults, List<TestDto> tests, List<IssueDto> issues, boolean isStepsEnabled) throws AqualityException {
174+
private void fillResult(TestResultDto result, List<FinalResultDto> finalResults, List<TestDto> tests, List<IssueDto> issues, List<TestResultAttachmentDto> attachments, boolean isStepsEnabled) throws AqualityException {
170175
if (isStepsEnabled) {
171176
fillResultSteps(result);
172177
}
@@ -176,6 +181,7 @@ private void fillResult(TestResultDto result, List<FinalResultDto> finalResults,
176181
if(result.getIssue_id() != null) {
177182
result.setIssue(issues.stream().filter(x -> x.getId().equals(result.getIssue_id())).findFirst().orElse(null));
178183
}
184+
result.setAttachments(attachments.stream().filter(x -> x.getTest_result_id().equals(result.getId())).collect(Collectors.toList()));
179185
}
180186

181187
private void fillResultSteps(TestResultDto result) throws AqualityException {

src/main/java/main/exceptions/AqualitySQLException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private static String getErrorMessage(SQLException exception){
2727
}
2828
return String.format("You have missed required parameter: %s", exception.getMessage());
2929
case "HY000":
30-
return "Your Data Base does not support UTF characters, please contact administrator to allow it.";
30+
return String.format("Data base error: %s", exception.getMessage());
3131
case "42S02":
3232
return "There is some missed table in your Data Base, please contact administrator.";
3333
case "S1000":

src/main/java/main/model/db/dao/project/TestResultAttachmentDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
public class TestResultAttachmentDao extends DAO<TestResultAttachmentDto> {
77
public TestResultAttachmentDao() {
88
super(TestResultAttachmentDto.class);
9-
select = "{call SELECT_TEST_RESULT_ATTACH(?,?)}";
9+
select = "{call SELECT_TEST_RESULT_ATTACH(?,?,?,?)}";
1010
insert = "{call INSERT_TEST_RESULT_ATTACH(?,?,?)}";
1111
remove = "{call REMOVE_TEST_RESULT_ATTACH(?)}";
1212
}

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

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main.model.db.imports;
22

33
import main.controllers.ControllerFactory;
4+
import main.controllers.Project.IssueController;
45
import main.exceptions.AqualityException;
56
import main.model.db.dao.project.*;
67
import main.model.dto.project.*;
@@ -11,9 +12,11 @@
1112
import java.util.*;
1213
import java.util.regex.Matcher;
1314
import java.util.regex.Pattern;
15+
import java.util.regex.PatternSyntaxException;
1416

1517
class BaseImporter {
1618
private ControllerFactory controllerFactory;
19+
private IssueController issueController;
1720
private String pattern;
1821
protected File file;
1922
private List<IssueDto> issues;
@@ -24,7 +27,8 @@ class BaseImporter {
2427
controllerFactory = new ControllerFactory(user);
2528
IssueDto issueTemplate = new IssueDto();
2629
issueTemplate.setProject_id(this.projectId);
27-
issues = controllerFactory.getHandler(issueTemplate).get(issueTemplate);
30+
issueController = controllerFactory.getHandler(issueTemplate);
31+
issues = issueController.get(issueTemplate);
2832
}
2933

3034
private List<TestResultDto> existingResults = new ArrayList<>();
@@ -150,19 +154,23 @@ private void createTests() throws AqualityException {
150154
List<TestDto> completedTests = new ArrayList<>();
151155

152156
for (TestDto test : this.tests) {
153-
test.setProject_id(this.projectId);
154-
TestDto existingTest = tryGetExistingTest(allTests, test);
155-
156-
if (existingTest != null) {
157-
test.setId(existingTest.getId());
158-
} else {
159-
allTests.add(test);
160-
}
157+
try {
158+
test.setProject_id(this.projectId);
159+
TestDto existingTest = tryGetExistingTest(allTests, test);
160+
161+
if (existingTest != null) {
162+
test.setId(existingTest.getId());
163+
} else {
164+
allTests.add(test);
165+
}
161166

162-
test.setId(controllerFactory.getHandler(test).create(test, false).getId());
163-
linkTestToSuite(test);
167+
test.setId(controllerFactory.getHandler(test).create(test, false).getId());
168+
linkTestToSuite(test);
164169

165-
completedTests.add(test);
170+
completedTests.add(test);
171+
} catch (AqualityException exception) {
172+
logToImport(String.format("Was not able to create or update test:\n%s\nCreation was failed with error:\n%s", test.getName(), exception.getMessage()));
173+
}
166174
}
167175
this.tests = completedTests;
168176

@@ -203,9 +211,10 @@ private void createResult(TestResultDto result, boolean update) throws AqualityE
203211
}
204212
controllerFactory.getHandler(result).create(result);
205213
} catch (AqualityException e){
206-
throw e;
207-
} catch (Exception e){
208-
throw new AqualityException("Failed on Result Creation for test id: " + result.getTest_id());
214+
logToImport(
215+
String.format("Failed on Result Creation for test id:\n%s\nCreation was failed with error:\n%s",
216+
result.getTest_id(),
217+
e.getMessage()));
209218
}
210219
}
211220

@@ -242,7 +251,10 @@ private void updateResultWithSimilarError(TestResultDto result) throws AqualityE
242251
}
243252
}
244253
} catch (Exception e){
245-
throw new AqualityException("Failed on update Result with similar error");
254+
logToImport(
255+
String.format("Failed on predicting fail reason for test id:\n%s\nPrediction was failed with error:\n%s",
256+
result.getTest_id(),
257+
e.getMessage()));
246258
}
247259
}
248260

@@ -260,9 +272,18 @@ private TestResultDto compareByRegexp(TestResultDto result, List<TestResultDto>
260272
private boolean tryFillByIssue(TestResultDto result, List<IssueDto> issues) {
261273
if (result.getFail_reason() != null) {
262274
for (IssueDto issue : issues) {
263-
if (issue.getExpression() != null && !issue.getStatus_id().equals(4) && RegexpUtil.match(result.getFail_reason(), issue.getExpression())) {
264-
result.setIssue_id(issue.getId());
265-
return true;
275+
try {
276+
if (issue.getExpression() != null && !issue.getStatus_id().equals(4) && RegexpUtil.match(result.getFail_reason(), issue.getExpression())) {
277+
result.setIssue_id(issue.getId());
278+
return true;
279+
}
280+
} catch (PatternSyntaxException regexException) {
281+
issue.setExpression("$blank");
282+
try {
283+
issueController.create(issue);
284+
} catch (AqualityException controllerException) {
285+
System.out.println(String.format("Was not able to fix invalid issue expression: id: %s", issue.getId()));
286+
}
266287
}
267288
}
268289
}

src/main/java/main/model/dto/project/TestResultAttachmentDto.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import lombok.Data;
44
import lombok.EqualsAndHashCode;
5+
import main.annotations.DataBaseID;
56
import main.annotations.DataBaseInsert;
67
import main.annotations.DataBaseName;
78
import main.annotations.DataBaseSearchable;
@@ -15,6 +16,7 @@ public class TestResultAttachmentDto extends AttachmentDto {
1516
@DataBaseInsert
1617
private Integer test_result_id;
1718

19+
@DataBaseID
1820
@DataBaseName(name = "request_project_id")
1921
@DataBaseSearchable
2022
@DataBaseInsert
@@ -23,4 +25,10 @@ public class TestResultAttachmentDto extends AttachmentDto {
2325
@DataBaseName(name = "request_test_run_id")
2426
@DataBaseSearchable
2527
private Integer test_run_id;
28+
29+
@DataBaseID
30+
@DataBaseName(name = "request_id")
31+
private Integer id;
32+
33+
private String url;
2634
}

src/main/java/main/model/dto/project/TestResultDto.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ public class TestResultDto extends BaseDto {
7474
@DataBaseInsert
7575
private Integer issue_id;
7676
private IssueDto issue;
77+
private List<TestResultAttachmentDto> attachments;
7778
}

src/main/java/main/model/dto/project/TestResultStatDto.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public class TestResultStatDto extends BaseDto {
2626
private String name;
2727
private String status;
2828
private String resolution;
29-
private String assignee;
30-
private String developer;
31-
private String comment;
29+
private String issue_assignee;
30+
private String developer_name;
31+
private String issue_id;
32+
private String issue_title;
3233
}

src/main/java/main/view/Audits/AuditAttachmentsServlet.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main.view.Audits;
22

33
import main.Session;
4+
import main.exceptions.AqualityException;
45
import main.model.dto.audit.AuditAttachmentDto;
56
import main.utils.FileUtils;
67
import main.utils.PathUtils;
@@ -35,7 +36,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp){
3536
resp.getWriter().write(mapper.serialize(attachments));
3637
} else {
3738
resp.setStatus(400);
38-
setErrorHeader(resp, "You have no specify Audit ID!");
39+
throw new AqualityException("You have no specify Audit ID!");
3940
}
4041
}catch (Exception e) {
4142
handleException(resp, e);
@@ -44,7 +45,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp){
4445

4546
@Override
4647
public void doDelete(HttpServletRequest req, HttpServletResponse resp) {
47-
setPostResponseHeaders(resp);
48+
setDeleteResponseHeaders(resp);
4849
try {
4950
Session session = createSession(req);
5051
if (req.getParameterMap().containsKey("id")) {
@@ -62,9 +63,9 @@ public void doDelete(HttpServletRequest req, HttpServletResponse resp) {
6263
@Override
6364
public void doPost(HttpServletRequest req, HttpServletResponse resp) {
6465
try {
66+
setPostResponseHeaders(resp);
6567
req.setCharacterEncoding(StandardCharsets.UTF_8.toString());
6668
setEncoding(resp);
67-
setPostResponseHeaders(resp);
6869
Session session = createSession(req);
6970
if (req.getParameterMap().containsKey("audit_id")) {
7071
FileUtils fileUtils = new FileUtils();
@@ -80,7 +81,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp) {
8081
session.getAuditController().createMultiply(listOfAttachments);
8182
} else {
8283
resp.setStatus(400);
83-
setErrorHeader(resp, "You have no specify Audit ID!");
84+
throw new AqualityException("You have no specify Audit ID!");
8485
}
8586
} catch (Exception e) {
8687
handleException(resp, e);

src/main/java/main/view/Audits/AuditDownloadAttachmentServlet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main.view.Audits;
22

33
import main.Session;
4+
import main.exceptions.AqualityException;
45
import main.model.dto.audit.AuditAttachmentDto;
56
import main.view.BaseServlet;
67
import main.view.IGet;
@@ -28,7 +29,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp){
2829
processResponse(resp, auditAttachments.get(0).getPath());
2930
} else {
3031
resp.setStatus(400);
31-
setErrorHeader(resp, "You have no specify Attachment ID");
32+
throw new AqualityException("You have no specify Attachment ID");
3233
}
3334
}catch (Exception e) {
3435
handleException(resp, e);

0 commit comments

Comments
 (0)