Skip to content

Commit

Permalink
Merge pull request #54 from aquality-automation/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
VladislavKostyukevich authored Mar 2, 2020
2 parents 67d7c98 + a566b18 commit 98f29ac
Show file tree
Hide file tree
Showing 14 changed files with 816 additions and 39 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# CHANGELOG

## 0.3.7 (2020-03-02)

Features:
- Improve Test Run and Test List page performance -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/71)
- Exclude Debug results from last results column -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/70)
- Milestone: Add selected Suites to milestone -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/63)
- Milestone: Add Due Date to Milestone. -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/61)
- Milestone: Add possibility to Close Milestone. -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/62)

## 0.3.6 (2020-02-24)

Features:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>unifi_reporting_api</groupId>
<artifactId>api</artifactId>
<packaging>war</packaging>
<version>0.3.6</version>
<version>0.3.7</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
70 changes: 68 additions & 2 deletions src/main/java/main/controllers/Project/MilestoneController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,31 @@
import main.exceptions.AqualityException;
import main.exceptions.AqualityPermissionsException;
import main.model.db.dao.project.MilestoneDao;
import main.model.db.dao.project.Suite2MilestoneDao;
import main.model.dto.MilestoneDto;
import main.model.dto.Suite2MilestoneDto;
import main.model.dto.TestSuiteDto;
import main.model.dto.UserDto;

import java.util.List;
import java.util.Objects;

public class MilestoneController extends BaseController<MilestoneDto> {
private MilestoneDao milestoneDao;
private Suite2MilestoneDao milestoneSuitesDao;

public MilestoneController(UserDto user) {
super(user);
milestoneDao = new MilestoneDao();
milestoneSuitesDao = new Suite2MilestoneDao();
}

@Override
public MilestoneDto create(MilestoneDto template) throws AqualityException {
if (baseUser.isManager() || baseUser.getProjectUser(template.getProject_id()).isEditor()) {
return milestoneDao.create(template);
MilestoneDto milestone = milestoneDao.create(template);
template.setId(milestone.getId());
return updateSuites(template);
} else {
throw new AqualityPermissionsException("Account is not allowed to create Milestones", baseUser);
}
Expand All @@ -29,7 +37,8 @@ public MilestoneDto create(MilestoneDto template) throws AqualityException {
@Override
public List<MilestoneDto> get(MilestoneDto template) throws AqualityException {
if (baseUser.isFromGlobalManagement() || baseUser.getProjectUser(template.getProject_id()).isViewer()) {
return milestoneDao.searchAll(template);
List<MilestoneDto> milestones = milestoneDao.searchAll(template);
return fillMilestones(milestones);
} else {
throw new AqualityPermissionsException("Account is not allowed to view Milestones", baseUser);
}
Expand All @@ -43,4 +52,61 @@ public boolean delete(MilestoneDto template) throws AqualityException {
throw new AqualityPermissionsException("Account is not allowed to delete Milestones", baseUser);
}
}

private List<MilestoneDto> fillMilestones(List<MilestoneDto> milestones) throws AqualityException {
for (MilestoneDto milestone : milestones) {
milestone.setSuites(getSuites(milestone.getId()));
}

return milestones;
}

private List<TestSuiteDto> getSuites(Integer milestoneId) throws AqualityException {
Suite2MilestoneDto suite2Milestone = new Suite2MilestoneDto();
suite2Milestone.setMilestone_id(milestoneId);
return milestoneSuitesDao.getSuites(suite2Milestone);
}

private MilestoneDto updateSuites(MilestoneDto template) throws AqualityException {
Suite2MilestoneDto suite2Milestone = new Suite2MilestoneDto();
suite2Milestone.setMilestone_id(template.getId());
List<TestSuiteDto> oldSuites = milestoneSuitesDao.getSuites(suite2Milestone);

addNewSuites(oldSuites, template);
removeSuites(oldSuites, template.getId());

List<MilestoneDto> milestones = get(template);
if(!milestones.isEmpty()) {
return milestones.get(0);
}

throw new AqualityException("Cannot get Milestone after Suites Update!");
}

private void addNewSuites(List<TestSuiteDto> oldSuites, MilestoneDto milestone) throws AqualityException {
if (milestone.getSuites() != null && milestone.getSuites().size() > 0) {
for (TestSuiteDto newSuite : milestone.getSuites()) {
TestSuiteDto alreadyExists = oldSuites.stream().filter(x -> Objects.equals(x.getId(), newSuite.getId())).findAny().orElse(null);
if (alreadyExists != null) {
oldSuites.removeIf(x -> Objects.equals(x.getId(), alreadyExists.getId()));
} else {
Suite2MilestoneDto newSuite2MilestoneDto = new Suite2MilestoneDto();
newSuite2MilestoneDto.setSuite_id(newSuite.getId());
newSuite2MilestoneDto.setMilestone_id(milestone.getId());
milestoneSuitesDao.addSuite(newSuite2MilestoneDto);
}
}
}
}

private void removeSuites(List<TestSuiteDto> oldSuites, Integer milestone_id) throws AqualityException {
if (!oldSuites.isEmpty()) {
for (TestSuiteDto oldSuite : oldSuites) {
Suite2MilestoneDto toRemove = new Suite2MilestoneDto();
toRemove.setSuite_id(oldSuite.getId());
toRemove.setMilestone_id(milestone_id);
milestoneSuitesDao.delete(toRemove);
}
}
}
}
7 changes: 0 additions & 7 deletions src/main/java/main/controllers/Project/TestController.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

public class TestController extends BaseController<TestDto> {
private TestDao testDao;
private ProjectDao projectDao;
private TestSuiteDao suiteDao;
private TestResultDao resultDao;
private Test2SuiteController test2SuiteController;
Expand All @@ -24,7 +23,6 @@ public TestController(UserDto user) {

testDao = new TestDao();
suiteDao = new TestSuiteDao();
projectDao = new ProjectDao();
resultDao = new TestResultDao();
test2SuiteController = new Test2SuiteController(user);
projectUserController = new ProjectUserController(user);
Expand Down Expand Up @@ -157,7 +155,6 @@ private List<TestDto> fillTests(List<TestDto> tests) throws AqualityException {
List<Test2SuiteDto> test2Suites = new ArrayList<>();
ProjectDto projectDto = new ProjectDto();
projectDto.setId(tests.get(0).getProject_id());
projectDto = projectDao.getEntityById(projectDto);

for (TestSuiteDto testSuite : testSuites) {
Test2SuiteDto test2Suite = new Test2SuiteDto();
Expand All @@ -171,10 +168,6 @@ private List<TestDto> fillTests(List<TestDto> tests) throws AqualityException {
test.setDeveloper(projectUsers.stream().filter(x -> x.getUser().getId().equals(test.getDeveloper_id())).findFirst().orElse(null));
}

if(projectDto.getStability_count() != null) {
test.setLastResultColors(testDao.getLastColors(test.getId(), projectDto.getStability_count()));
}

List<Test2SuiteDto> testSuiteLinks = test2Suites.stream().filter(x -> x.getTest_id().equals(test.getId())).collect(Collectors.toList());
test.setSuites(test2SuiteController.convertToSuites(testSuiteLinks, testSuites));
filledTests.add(test);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/main/model/db/dao/project/MilestoneDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ public class MilestoneDao extends DAO<MilestoneDto> {

public MilestoneDao(){
super(MilestoneDto.class);
select = "{call SELECT_MILESTONE(?,?,?)}";
insert = "{call INSERT_MILESTONE(?,?,?)}";
select = "{call SELECT_MILESTONE(?,?,?,?)}";
insert = "{call INSERT_MILESTONE(?,?,?,?,?)}";
remove = "{call REMOVE_MILESTONE(?)}";
}
}
31 changes: 31 additions & 0 deletions src/main/java/main/model/db/dao/project/Suite2MilestoneDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main.model.db.dao.project;

import com.mysql.cj.core.conf.url.ConnectionUrlParser;
import main.exceptions.AqualityException;
import main.exceptions.AqualitySQLException;
import main.model.db.dao.DAO;
import main.model.dto.DtoMapper;
import main.model.dto.Suite2MilestoneDto;
import main.model.dto.TestSuiteDto;
import java.util.List;

public class Suite2MilestoneDao extends DAO<Suite2MilestoneDto> {
public Suite2MilestoneDao() {
super(Suite2MilestoneDto.class);
remove = "{call REMOVE_SUITE_FROM_MILESTONE(?,?)}";
}

public void addSuite(Suite2MilestoneDto entity) throws AqualityException {
String sql = "{call INSERT_SUITE_TO_MILESTONE(?,?)}";
List<ConnectionUrlParser.Pair<String, String>> parameters = entity.getParameters();
CallStoredProcedure(sql, parameters);
}

public List<TestSuiteDto> getSuites(Suite2MilestoneDto entity) throws AqualityException {
List<ConnectionUrlParser.Pair<String, String>> parameters = entity.getSearchParameters();
DtoMapper<TestSuiteDto> suiteMapper = new DtoMapper<>(TestSuiteDto.class);

String sql = "{call SELECT_MILESTONE_SUITES(?)}";
return suiteMapper.mapObjects(CallStoredProcedure(sql, parameters).toString());
}
}
16 changes: 0 additions & 16 deletions src/main/java/main/model/db/dao/project/TestDao.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
package main.model.db.dao.project;

import com.mysql.cj.core.conf.url.ConnectionUrlParser;
import main.exceptions.AqualityException;
import main.model.db.dao.DAO;
import main.model.dto.DtoMapper;
import main.model.dto.LastResultColorsDto;
import main.model.dto.TestDto;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public class TestDao extends DAO<TestDto> {
public TestDao() {
Expand All @@ -18,12 +10,4 @@ public TestDao() {
insert = "{call INSERT_TEST(?,?,?,?,?,?)}";
remove = "{call REMOVE_TEST(?)}";
}

public LastResultColorsDto getLastColors(@NotNull Integer testId, @NotNull Integer limit) throws AqualityException {
DtoMapper<LastResultColorsDto> lastResultColorsMapper = new DtoMapper<>(LastResultColorsDto.class);
List<ConnectionUrlParser.Pair<String, String>> parameters = new ArrayList<>();
parameters.add(new ConnectionUrlParser.Pair<>("request_test_id", testId.toString()));
parameters.add(new ConnectionUrlParser.Pair<>("request_limit", limit.toString()));
return lastResultColorsMapper.mapObjects(CallStoredProcedure("{call SELECT_LAST_RESULT_COLORS(?,?)}", parameters).toString()).get(0);
}
}
1 change: 1 addition & 0 deletions src/main/java/main/model/db/imports/BaseImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ private void createResults(boolean update) throws AqualityException {
result.setTest(tests.get(i));
}

result.setDebug(testRun.getDebug());
result.setTest_id(result.getTest().getId());
result.setTest_run_id(testRun.getId());
result.setFinal_result_updated(result.getFinish_date());
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/main/model/dto/LastResultColorsDto.java

This file was deleted.

14 changes: 14 additions & 0 deletions src/main/java/main/model/dto/MilestoneDto.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package main.model.dto;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Data; import lombok.EqualsAndHashCode;
import main.annotations.*;
import main.utils.CustomerDateAndTimeDeserialize;

import java.util.Date;
import java.util.List;


@Data @EqualsAndHashCode(callSuper = true)
Expand All @@ -18,4 +23,13 @@ public class MilestoneDto extends BaseDto{
@DataBaseName(name = "request_project_id")
@DataBaseInsert
private Integer project_id;
@DataBaseSearchable
@DataBaseName(name = "request_active")
@DataBaseInsert
private Integer active;
@DataBaseName(name = "request_due_date")
@DataBaseInsert
@JsonDeserialize(using= CustomerDateAndTimeDeserialize.class)
private Date due_date;
private List<TestSuiteDto> suites;
}
22 changes: 22 additions & 0 deletions src/main/java/main/model/dto/Suite2MilestoneDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main.model.dto;

import lombok.Data;
import lombok.EqualsAndHashCode;
import main.annotations.DataBaseID;
import main.annotations.DataBaseInsert;
import main.annotations.DataBaseName;
import main.annotations.DataBaseSearchable;


@Data @EqualsAndHashCode(callSuper = true)
public class Suite2MilestoneDto extends BaseDto {
@DataBaseName(name="request_milestone_id")
@DataBaseID
@DataBaseInsert
@DataBaseSearchable
private Integer milestone_id;
@DataBaseName(name="request_suite_id")
@DataBaseID
@DataBaseInsert
private Integer suite_id;
}
4 changes: 3 additions & 1 deletion src/main/java/main/model/dto/TestDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ public class TestDto extends BaseDto {
@DataBaseName(name="request_test_suite_id")
@DataBaseSearchable
private Integer test_suite_id;
private LastResultColorsDto lastResultColors;
private String resolution_colors;
private String result_colors;
private String result_ids;
}
1 change: 1 addition & 0 deletions src/main/resources/db_changelog/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
<include file="db.changelog-0.3.4.xml" relativeToChangelogFile="true"/>
<include file="db.changelog-0.3.5.xml" relativeToChangelogFile="true"/>
<include file="db.changelog-0.3.6.xml" relativeToChangelogFile="true"/>
<include file="db.changelog-0.3.7.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
Loading

0 comments on commit 98f29ac

Please sign in to comment.