mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-27 08:44:49 +00:00
* fix: error if no testCaseResult exists when updating testSuite summary state * fix: add return statement on resultsummaries update
This commit is contained in:
parent
0332fb9fe5
commit
bd09755fc0
@ -401,26 +401,14 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
|
||||
}
|
||||
|
||||
if (storedResultSummary != null) {
|
||||
// if the state already exists then we'll remove it before adding the new one
|
||||
resultSummaries.removeIf(
|
||||
summary -> summary.getTestCaseName().equals(resultSummary.getTestCaseName()));
|
||||
}
|
||||
|
||||
if (!isDeleted) {
|
||||
resultSummaries.add(resultSummary);
|
||||
} else {
|
||||
// Add the latest state when removing a state
|
||||
String json =
|
||||
daoCollection
|
||||
.dataQualityDataTimeSeriesDao()
|
||||
.getLatestExtension(testCase.getFullyQualifiedName(), TESTCASE_RESULT_EXTENSION);
|
||||
TestCaseResult testCaseResult = JsonUtils.readValue(json, TestCaseResult.class);
|
||||
ResultSummary newResultSummary =
|
||||
getResultSummary(
|
||||
testCase, testCaseResult.getTimestamp(), testCaseResult.getTestCaseStatus());
|
||||
resultSummaries.add(newResultSummary);
|
||||
}
|
||||
updateResultSummaries(testCase, isDeleted, resultSummaries, resultSummary);
|
||||
|
||||
// Update test case result summary for the test suite
|
||||
// Update test case result summary attribute for the test suite
|
||||
testSuite.setTestCaseResultSummary(resultSummaries);
|
||||
daoCollection
|
||||
.testSuiteDAO()
|
||||
@ -431,6 +419,30 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateResultSummaries(
|
||||
TestCase testCase,
|
||||
boolean isDeleted,
|
||||
List<ResultSummary> resultSummaries,
|
||||
ResultSummary resultSummary) {
|
||||
if (!isDeleted) {
|
||||
resultSummaries.add(resultSummary);
|
||||
return;
|
||||
}
|
||||
// If the result was deleted, we need to update the summary
|
||||
// with the latest one from the database (if one exists)
|
||||
String json =
|
||||
daoCollection
|
||||
.dataQualityDataTimeSeriesDao()
|
||||
.getLatestExtension(testCase.getFullyQualifiedName(), TESTCASE_RESULT_EXTENSION);
|
||||
if (json != null) {
|
||||
TestCaseResult testCaseResult = JsonUtils.readValue(json, TestCaseResult.class);
|
||||
ResultSummary newResultSummary =
|
||||
getResultSummary(
|
||||
testCase, testCaseResult.getTimestamp(), testCaseResult.getTestCaseStatus());
|
||||
resultSummaries.add(newResultSummary);
|
||||
}
|
||||
}
|
||||
|
||||
private ResultSummary findMatchingResultSummary(
|
||||
List<ResultSummary> resultSummaries, String testCaseNameToMatch) {
|
||||
return resultSummaries.stream()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user