fix: removed single relationship test between testCase and testSuite + throw error if no executable test suite can be found for a test case (#13032)

This commit is contained in:
Teddy 2023-08-31 18:53:05 +02:00 committed by GitHub
parent ba2201f4ea
commit c198970217
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,25 +122,25 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
validateTestParameters(test.getParameterValues(), testDefinition.getParameterDefinition()); validateTestParameters(test.getParameterValues(), testDefinition.getParameterDefinition());
} }
private EntityReference getTestSuite(TestCase test) { private EntityReference getTestSuite(TestCase test) throws EntityNotFoundException {
// `testSuite` field returns the executable `testSuite` linked to that testCase // `testSuite` field returns the executable `testSuite` linked to that testCase
List<CollectionDAO.EntityRelationshipRecord> records = List<CollectionDAO.EntityRelationshipRecord> records =
findFromRecords(test.getId(), entityType, Relationship.CONTAINS, TEST_SUITE); findFromRecords(test.getId(), entityType, Relationship.CONTAINS, TEST_SUITE);
ensureSingleRelationship(entityType, test.getId(), records, Relationship.CONTAINS.value(), true);
for (CollectionDAO.EntityRelationshipRecord testSuiteId : records) { for (CollectionDAO.EntityRelationshipRecord testSuiteId : records) {
TestSuite testSuite = Entity.getEntity(TEST_SUITE, testSuiteId.getId(), "", Include.ALL); TestSuite testSuite = Entity.getEntity(TEST_SUITE, testSuiteId.getId(), "", Include.ALL);
if (Boolean.TRUE.equals(testSuite.getExecutable())) { if (Boolean.TRUE.equals(testSuite.getExecutable())) {
return testSuite.getEntityReference(); return testSuite.getEntityReference();
} }
} }
return null; throw new EntityNotFoundException(
String.format("Error occurred when retrieving executable test suite for testCase %s. ", test.getName())
+ "No executable test suite was found.");
} }
private List<TestSuite> getTestSuites(TestCase test) { private List<TestSuite> getTestSuites(TestCase test) {
// `testSuites` field returns all the `testSuite` (executable and logical) linked to that testCase // `testSuites` field returns all the `testSuite` (executable and logical) linked to that testCase
List<CollectionDAO.EntityRelationshipRecord> records = List<CollectionDAO.EntityRelationshipRecord> records =
findFromRecords(test.getId(), entityType, Relationship.CONTAINS, TEST_SUITE); findFromRecords(test.getId(), entityType, Relationship.CONTAINS, TEST_SUITE);
ensureSingleRelationship(entityType, test.getId(), records, Relationship.CONTAINS.value(), true);
return records.stream() return records.stream()
.map(testSuiteId -> Entity.<TestSuite>getEntity(TEST_SUITE, testSuiteId.getId(), "", Include.ALL)) .map(testSuiteId -> Entity.<TestSuite>getEntity(TEST_SUITE, testSuiteId.getId(), "", Include.ALL))
.collect(Collectors.toList()); .collect(Collectors.toList());