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());