Skip to content

Commit 76d7b06

Browse files
Fix PR Comments
1 parent cba6e40 commit 76d7b06

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/main/java/main/controllers/Project/SuiteController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public TestSuiteDto get(String name, Integer projectId) throws AqualityException
5252
template.setProject_id(projectId);
5353
try{
5454
return get(template, false).get(0);
55-
} catch (Exception e) {
55+
} catch (IndexOutOfBoundsException e) {
5656
throw new AqualityException("The '%s' suite does not exist.", name);
5757
}
5858
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ private void createTestRun() throws AqualityException {
8383
TestRunDto template = new TestRunDto();
8484
template.setProject_id(testRun.getProject_id());
8585
template.setId(testRun.getId());
86-
testRun = controllerFactory.getHandler(template).get(template, false, 1).get(0);
86+
List<TestRunDto> testRuns = controllerFactory.getHandler(template).get(template, false, 1);
87+
if(testRuns.size() > 0){
88+
testRun = testRuns.get(0);
89+
} else {
90+
throw new AqualityException("Test run with %s id does not exist!", testRun.getId());
91+
}
8792
}
8893
else{
8994
createTestRun((testRun.getBuild_name() != null && !testRun.getBuild_name().equals(""))

src/main/java/main/model/db/imports/SAXHandlers/NUnitV3Handler.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.*;
1515

1616
import static main.model.db.imports.ResultStatus.*;
17+
import static main.model.db.imports.TestNameNodeType.*;
1718

1819
public class NUnitV3Handler extends Handler {
1920
private TestSuiteDto testSuite = new TestSuiteDto();
@@ -62,7 +63,7 @@ public void startElement(String uri, String localName, String qName, Attributes
6263
testRun.setAuthor(String.format("%s\\%s", attributes.getValue("user-domain"), attributes.getValue("user")));
6364
break;
6465
case "test-suite":
65-
if(attributes.getValue("type").equals("TestFixture") && testNameNodeType == TestNameNodeType.featureNameTestName) {
66+
if(attributes.getValue("type").equals("TestFixture") && testNameNodeType == featureNameTestName) {
6667
currentFixture = attributes.getValue("name");
6768
}
6869
break;
@@ -170,13 +171,15 @@ public void characters(char[] ch, int start, int length) {
170171
}
171172

172173
private void setTestName(Attributes attributes) throws SAXException {
173-
if(testNameNodeType == TestNameNodeType.featureNameTestName) {
174-
test.setName(String.format("%s: %s", currentFixture, attributes.getValue("name")) );
175-
}
176-
else if(testNameNodeType == TestNameNodeType.className) {
177-
test.setName(attributes.getValue("fullname"));
178-
} else {
179-
throw new SAXException("testNameNodeType is not correct for NUnitV3 parser.");
174+
switch (testNameNodeType) {
175+
case featureNameTestName:
176+
test.setName(String.format("%s: %s", currentFixture, attributes.getValue("name")) );
177+
break;
178+
case className:
179+
test.setName(attributes.getValue("fullname"));
180+
break;
181+
default:
182+
throw new SAXException("testNameNodeType is not correct for NUnitV3 parser.");
180183
}
181184
}
182185

0 commit comments

Comments
 (0)