From c1989702175c37a11f800e56ecfa670bdd65da92 Mon Sep 17 00:00:00 2001 From: Teddy Date: Thu, 31 Aug 2023 18:53:05 +0200 Subject: [PATCH] fix: removed single relationship test between testCase and testSuite + throw error if no executable test suite can be found for a test case (#13032) --- .../openmetadata/service/jdbi3/TestCaseRepository.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseRepository.java index d86ff742ccd..5ad19eb7b50 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseRepository.java @@ -122,25 +122,25 @@ public class TestCaseRepository extends EntityRepository { 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 List records = findFromRecords(test.getId(), entityType, Relationship.CONTAINS, TEST_SUITE); - ensureSingleRelationship(entityType, test.getId(), records, Relationship.CONTAINS.value(), true); for (CollectionDAO.EntityRelationshipRecord testSuiteId : records) { TestSuite testSuite = Entity.getEntity(TEST_SUITE, testSuiteId.getId(), "", Include.ALL); if (Boolean.TRUE.equals(testSuite.getExecutable())) { 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 getTestSuites(TestCase test) { // `testSuites` field returns all the `testSuite` (executable and logical) linked to that testCase List records = findFromRecords(test.getId(), entityType, Relationship.CONTAINS, TEST_SUITE); - ensureSingleRelationship(entityType, test.getId(), records, Relationship.CONTAINS.value(), true); return records.stream() .map(testSuiteId -> Entity.getEntity(TEST_SUITE, testSuiteId.getId(), "", Include.ALL)) .collect(Collectors.toList());