mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-27 18:36:08 +00:00
MINOR - Validate basic suites do have basicEntityRef (#19763)
* MINOR - Validate basic suites do have basicEntityRef * add test
This commit is contained in:
parent
e873ba0f1b
commit
ede8108a5a
@ -127,7 +127,7 @@ public class TestSuiteRepository extends EntityRepository<TestSuite> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInheritedFields(TestSuite testSuite, EntityUtil.Fields fields) {
|
public void setInheritedFields(TestSuite testSuite, EntityUtil.Fields fields) {
|
||||||
if (Boolean.TRUE.equals(testSuite.getBasic())) {
|
if (Boolean.TRUE.equals(testSuite.getBasic()) && testSuite.getBasicEntityReference() != null) {
|
||||||
Table table =
|
Table table =
|
||||||
Entity.getEntity(
|
Entity.getEntity(
|
||||||
TABLE, testSuite.getBasicEntityReference().getId(), "owners,domain", ALL);
|
TABLE, testSuite.getBasicEntityReference().getId(), "owners,domain", ALL);
|
||||||
@ -156,7 +156,7 @@ public class TestSuiteRepository extends EntityRepository<TestSuite> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityInterface getParentEntity(TestSuite entity, String fields) {
|
public EntityInterface getParentEntity(TestSuite entity, String fields) {
|
||||||
if (entity.getBasic()) {
|
if (entity.getBasic() && entity.getBasicEntityReference() != null) {
|
||||||
return Entity.getEntity(entity.getBasicEntityReference(), fields, ALL);
|
return Entity.getEntity(entity.getBasicEntityReference(), fields, ALL);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -81,6 +81,8 @@ public class TestSuiteResource extends EntityResource<TestSuite, TestSuiteReposi
|
|||||||
"Cannot delete logical test suite. To delete logical test suite, use DELETE /v1/dataQuality/testSuites/<...>";
|
"Cannot delete logical test suite. To delete logical test suite, use DELETE /v1/dataQuality/testSuites/<...>";
|
||||||
public static final String NON_BASIC_TEST_SUITE_DELETION_ERROR =
|
public static final String NON_BASIC_TEST_SUITE_DELETION_ERROR =
|
||||||
"Cannot delete executable test suite. To delete executable test suite, use DELETE /v1/dataQuality/testSuites/basic/<...>";
|
"Cannot delete executable test suite. To delete executable test suite, use DELETE /v1/dataQuality/testSuites/basic/<...>";
|
||||||
|
public static final String BASIC_TEST_SUITE_WITHOUT_REF_ERROR =
|
||||||
|
"Cannot create a basic test suite without the BasicEntityReference field informed.";
|
||||||
|
|
||||||
static final String FIELDS = "owners,tests,summary";
|
static final String FIELDS = "owners,tests,summary";
|
||||||
static final String SEARCH_FIELDS_EXCLUDE = "table,database,databaseSchema,service";
|
static final String SEARCH_FIELDS_EXCLUDE = "table,database,databaseSchema,service";
|
||||||
@ -566,6 +568,9 @@ public class TestSuiteResource extends EntityResource<TestSuite, TestSuiteReposi
|
|||||||
@Valid CreateTestSuite create) {
|
@Valid CreateTestSuite create) {
|
||||||
TestSuite testSuite =
|
TestSuite testSuite =
|
||||||
mapper.createToEntity(create, securityContext.getUserPrincipal().getName());
|
mapper.createToEntity(create, securityContext.getUserPrincipal().getName());
|
||||||
|
if (testSuite.getBasicEntityReference() == null) {
|
||||||
|
throw new IllegalArgumentException(BASIC_TEST_SUITE_WITHOUT_REF_ERROR);
|
||||||
|
}
|
||||||
testSuite.setBasic(true);
|
testSuite.setBasic(true);
|
||||||
// Set the deprecation header based on draft specification from IETF
|
// Set the deprecation header based on draft specification from IETF
|
||||||
// https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-deprecation-header-02
|
// https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-deprecation-header-02
|
||||||
@ -598,6 +603,9 @@ public class TestSuiteResource extends EntityResource<TestSuite, TestSuiteReposi
|
|||||||
@Valid CreateTestSuite create) {
|
@Valid CreateTestSuite create) {
|
||||||
TestSuite testSuite =
|
TestSuite testSuite =
|
||||||
mapper.createToEntity(create, securityContext.getUserPrincipal().getName());
|
mapper.createToEntity(create, securityContext.getUserPrincipal().getName());
|
||||||
|
if (testSuite.getBasicEntityReference() == null) {
|
||||||
|
throw new IllegalArgumentException(BASIC_TEST_SUITE_WITHOUT_REF_ERROR);
|
||||||
|
}
|
||||||
testSuite.setBasic(true);
|
testSuite.setBasic(true);
|
||||||
List<AuthRequest> authRequests = getAuthRequestsForPost(testSuite);
|
List<AuthRequest> authRequests = getAuthRequestsForPost(testSuite);
|
||||||
return create(uriInfo, securityContext, authRequests, AuthorizationLogic.ANY, testSuite);
|
return create(uriInfo, securityContext, authRequests, AuthorizationLogic.ANY, testSuite);
|
||||||
|
@ -70,7 +70,9 @@ public record TestCaseIndex(TestCase testCase) implements SearchIndex {
|
|||||||
}
|
}
|
||||||
TestSuite testSuite = Entity.getEntityOrNull(testSuiteEntityReference, "", Include.ALL);
|
TestSuite testSuite = Entity.getEntityOrNull(testSuiteEntityReference, "", Include.ALL);
|
||||||
EntityReference entityReference = testSuite.getBasicEntityReference();
|
EntityReference entityReference = testSuite.getBasicEntityReference();
|
||||||
TestSuiteIndex.addTestSuiteParentEntityRelations(entityReference, doc);
|
if (entityReference != null) {
|
||||||
|
TestSuiteIndex.addTestSuiteParentEntityRelations(entityReference, doc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Float> getFields() {
|
public static Map<String, Float> getFields() {
|
||||||
|
@ -65,7 +65,9 @@ public record TestCaseResolutionStatusIndex(TestCaseResolutionStatus testCaseRes
|
|||||||
TestSuite testSuite = Entity.getEntityOrNull(testCase.getTestSuite(), "", Include.ALL);
|
TestSuite testSuite = Entity.getEntityOrNull(testCase.getTestSuite(), "", Include.ALL);
|
||||||
if (testSuite == null) return;
|
if (testSuite == null) return;
|
||||||
doc.put("testSuite", testSuite.getEntityReference());
|
doc.put("testSuite", testSuite.getEntityReference());
|
||||||
TestSuiteIndex.addTestSuiteParentEntityRelations(testSuite.getBasicEntityReference(), doc);
|
if (testSuite.getBasicEntityReference() != null) {
|
||||||
|
TestSuiteIndex.addTestSuiteParentEntityRelations(testSuite.getBasicEntityReference(), doc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Float> getFields() {
|
public static Map<String, Float> getFields() {
|
||||||
|
@ -182,6 +182,15 @@ public class TestSuiteResourceTest extends EntityResourceTest<TestSuite, CreateT
|
|||||||
assertEquals(true, deletedTestSuite.getDeleted());
|
assertEquals(true, deletedTestSuite.getDeleted());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void create_basicTestSuiteWithoutRef(TestInfo test) {
|
||||||
|
CreateTestSuite createTestSuite = createRequest(test);
|
||||||
|
assertResponse(
|
||||||
|
() -> createBasicEmptySuite(createTestSuite, ADMIN_AUTH_HEADERS),
|
||||||
|
BAD_REQUEST,
|
||||||
|
"Cannot create a basic test suite without the BasicEntityReference field informed.");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void list_testSuitesIncludeEmpty_200(TestInfo test) throws IOException {
|
void list_testSuitesIncludeEmpty_200(TestInfo test) throws IOException {
|
||||||
List<CreateTestSuite> testSuites = new ArrayList<>();
|
List<CreateTestSuite> testSuites = new ArrayList<>();
|
||||||
@ -834,6 +843,12 @@ public class TestSuiteResourceTest extends EntityResourceTest<TestSuite, CreateT
|
|||||||
return TestUtils.post(target, createTestSuite, TestSuite.class, authHeaders);
|
return TestUtils.post(target, createTestSuite, TestSuite.class, authHeaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TestSuite createBasicEmptySuite(
|
||||||
|
CreateTestSuite createTestSuite, Map<String, String> authHeaders) throws IOException {
|
||||||
|
WebTarget target = getResource("dataQuality/testSuites/basic");
|
||||||
|
return TestUtils.post(target, createTestSuite, TestSuite.class, authHeaders);
|
||||||
|
}
|
||||||
|
|
||||||
public void addTestCasesToLogicalTestSuite(TestSuite testSuite, List<UUID> testCaseIds)
|
public void addTestCasesToLogicalTestSuite(TestSuite testSuite, List<UUID> testCaseIds)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
WebTarget target = getResource("dataQuality/testCases/logicalTestCases");
|
WebTarget target = getResource("dataQuality/testCases/logicalTestCases");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user