@@ -78,21 +78,33 @@ public List<SuiteStatisticDto> get(SuiteStatisticDto template) throws AqualityEx
78
78
}
79
79
}
80
80
81
- private List <TestSuiteDto > fillTestSuites (List <TestSuiteDto > testSuites , boolean withChildren ) throws AqualityException {
82
- if (withChildren ){
83
- for (TestSuiteDto suite : testSuites ){
84
- TestDto testTemplate = new TestDto ();
85
- testTemplate .setTest_suite_id (suite .getId ());
86
- testTemplate .setProject_id (suite .getProject_id ());
87
- List <TestDto > tests = testController .get (testTemplate , false );
88
- suite .setTests (tests );
81
+ public List <TestDto > findLegacyTests (Integer suiteId , Integer notExecutedFor ) throws AqualityException {
82
+ if (baseUser .isManager () || baseUser .getProjectUserBySuiteId (suiteId ).isEditor ()) {
83
+ TestRunDto testRunTemplate = new TestRunDto ();
84
+ testRunTemplate .setTest_suite_id (suiteId );
85
+ testRunTemplate .setLimit (notExecutedFor );
86
+ List <TestRunDto > testRuns = testRunDao .searchAll (testRunTemplate );
87
+ TestDto testTemplate = new TestDto ();
88
+ testTemplate .setTest_suite_id (suiteId );
89
+ List <TestDto > tests = testController .get (testTemplate );
90
+ for (TestRunDto testRun : testRuns ) {
91
+ TestResultDto testResultTemplate = new TestResultDto ();
92
+ testResultTemplate .setTest_run_id (testRun .getId ());
93
+ List <TestResultDto > testResults = testResultDao .searchAll (testResultTemplate );
94
+ tests = tests .stream ().filter (test -> {
95
+ TestResultDto currentResult = testResults .stream ().filter (result -> result .getTest_id ().equals (test .getId ())).findFirst ().orElse (null );
96
+ return currentResult == null || currentResult .getFinal_result_id () == 3 ;
97
+ }).collect (Collectors .toList ());
89
98
}
99
+
100
+ return tests ;
101
+ } else {
102
+ throw new AqualityPermissionsException ("Account is not allowed to Sync Test Suite" , baseUser );
90
103
}
91
- return testSuites ;
92
104
}
93
105
94
106
public void syncLegacyTests (List <TestDto > legacyTests , Integer suiteId , boolean removeNotExecutedResults ) throws AqualityException {
95
- if (baseUser .isManager () || baseUser .getProjectUserBySuiteId (suiteId ).isManager ()){
107
+ if (baseUser .isManager () || baseUser .getProjectUserBySuiteId (suiteId ).isEditor ()){
96
108
legacyTests .forEach (test -> {
97
109
Test2SuiteDto test2Suite = new Test2SuiteDto ();
98
110
test2Suite .setTest_id (test .getId ());
@@ -111,6 +123,19 @@ public void syncLegacyTests(List<TestDto> legacyTests, Integer suiteId, boolean
111
123
}
112
124
}
113
125
126
+ private List <TestSuiteDto > fillTestSuites (List <TestSuiteDto > testSuites , boolean withChildren ) throws AqualityException {
127
+ if (withChildren ){
128
+ for (TestSuiteDto suite : testSuites ){
129
+ TestDto testTemplate = new TestDto ();
130
+ testTemplate .setTest_suite_id (suite .getId ());
131
+ testTemplate .setProject_id (suite .getProject_id ());
132
+ List <TestDto > tests = testController .get (testTemplate , false );
133
+ suite .setTests (tests );
134
+ }
135
+ }
136
+ return testSuites ;
137
+ }
138
+
114
139
private void removePendingResultsForTest (Integer suiteId , Integer testId ) throws AqualityException {
115
140
List <TestResultDto > testResults = testResultDao .selectSuiteLegacyResults (suiteId , testId );
116
141
testResults .forEach (testResult -> {
@@ -121,29 +146,4 @@ private void removePendingResultsForTest(Integer suiteId, Integer testId) throws
121
146
}
122
147
});
123
148
}
124
-
125
- public List <TestDto > findLegacyTests (Integer suiteId , Integer notExecutedFor ) throws AqualityException {
126
- if (baseUser .isManager () || baseUser .getProjectUserBySuiteId (suiteId ).isManager ()) {
127
- TestRunDto testRunTemplate = new TestRunDto ();
128
- testRunTemplate .setTest_suite_id (suiteId );
129
- testRunTemplate .setLimit (notExecutedFor );
130
- List <TestRunDto > testRuns = testRunDao .searchAll (testRunTemplate );
131
- TestDto testTemplate = new TestDto ();
132
- testTemplate .setTest_suite_id (suiteId );
133
- List <TestDto > tests = testController .get (testTemplate );
134
- for (TestRunDto testRun : testRuns ) {
135
- TestResultDto testResultTemplate = new TestResultDto ();
136
- testResultTemplate .setTest_run_id (testRun .getId ());
137
- List <TestResultDto > testResults = testResultDao .searchAll (testResultTemplate );
138
- tests = tests .stream ().filter (test -> {
139
- TestResultDto currentResult = testResults .stream ().filter (result -> result .getTest_id ().equals (test .getId ())).findFirst ().orElse (null );
140
- return currentResult == null || currentResult .getFinal_result_id () == 3 ;
141
- }).collect (Collectors .toList ());
142
- }
143
-
144
- return tests ;
145
- } else {
146
- throw new AqualityPermissionsException ("Account is not allowed to Sync Test Suite" , baseUser );
147
- }
148
- }
149
149
}
0 commit comments