Skip to content

Commit aab44c8

Browse files
committed
fixed getProjectUserByTest
1 parent b5d2999 commit aab44c8

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/main/java/main/controllers/Project/TestController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public TestDto create(TestDto template) throws AqualityException {
4646
}
4747

4848
public List<TestDto> get(TestDto template, boolean withChildren) throws AqualityException {
49-
if(baseUser.isFromGlobalManagement() || baseUser.getProjectUserByTestId(template.getId()).isViewer()){
49+
if(baseUser.isFromGlobalManagement() || baseUser.getProjectUserByTest(template).isViewer()){
5050
return fillTests(testDao.searchAll(template), withChildren);
5151
}else{
5252
throw new AqualityPermissionsException("Account is not allowed to view Tests", baseUser);

src/main/java/main/model/dto/UserDto.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,17 @@ public ProjectUserDto getProjectUserBySuiteId(Integer suite_id) throws AqualityE
109109
return getProjectUser(template.getProject_id());
110110
}
111111

112-
public ProjectUserDto getProjectUserByTestId(Integer test_id) throws AqualityException {
113-
TestDao testDao = new TestDao();
114-
TestDto template = new TestDto();
115-
template.setId(test_id);
116-
template = testDao.searchAll(template).get(0);
117-
return getProjectUser(template.getProject_id());
112+
public ProjectUserDto getProjectUserByTest(TestDto testDto) throws AqualityException {
113+
if(testDto.getProject_id() != null){
114+
return getProjectUser(testDto.getProject_id());
115+
}
116+
117+
try {
118+
TestDao testDao = new TestDao();
119+
return getProjectUser(testDao.searchAll(testDto).get(0).getProject_id());
120+
}catch (IndexOutOfBoundsException e){
121+
throw new AqualityException("Cannot define project id");
122+
}
118123
}
119124

120125
public ProjectUserDto getProjectUserByMilestoneId(Integer milestone_id) throws AqualityException {

0 commit comments

Comments
 (0)