mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-30 19:36:41 +00:00
* fix: Validate EntityLink column existence during test case creation - Update EntityRepository.validateColumn() to use case-insensitive comparison - Add column existence validation to TestCaseRepository.validateColumnTestCase() - Prevents test case creation with invalid column references due to case sensitivity Fixes #20888 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: IceS2 <IceS2@users.noreply.github.com> * small fix * Add tests * Fix test --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: IceS2 <IceS2@users.noreply.github.com> Co-authored-by: Shailesh Parmar <shailesh.parmar.webdev@gmail.com>
This commit is contained in:
parent
7bf06c5ecd
commit
a2541d25ce
@ -575,6 +575,12 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
|
||||
+ " e.g. <#E::table::{entityFqn}::columns::{columnName}>",
|
||||
entityLink.getFieldName()));
|
||||
}
|
||||
|
||||
// Validate that the referenced column actually exists in the table
|
||||
if (entityLink.getArrayFieldName() != null) {
|
||||
Table table = Entity.getEntity(entityLink, "columns", ALL);
|
||||
validateColumn(table, entityLink.getArrayFieldName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -531,6 +531,38 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes
|
||||
"Parameter 'invalidParameter' is not defined in the test definition. Defined parameters are: [missingValueMatch, missingCountValue]");
|
||||
}
|
||||
|
||||
@Test
|
||||
void post_testWithInvalidColumnName_4xx(TestInfo test) {
|
||||
String invalidColumnLink =
|
||||
String.format(
|
||||
"<#E::table::%s::columns::%s>",
|
||||
TEST_TABLE1.getFullyQualifiedName(), "nonExistentColumn");
|
||||
CreateTestCase create =
|
||||
createRequest(test)
|
||||
.withTestDefinition(TEST_DEFINITION2.getFullyQualifiedName())
|
||||
.withEntityLink(invalidColumnLink);
|
||||
|
||||
assertResponseContains(
|
||||
() -> createAndCheckEntity(create, ADMIN_AUTH_HEADERS),
|
||||
BAD_REQUEST,
|
||||
"Invalid column name nonExistentColumn");
|
||||
}
|
||||
|
||||
@Test
|
||||
void post_testWithWrongCaseColumnName_4xx(TestInfo test) {
|
||||
String wrongCaseColumnLink =
|
||||
String.format("<#E::table::%s::columns::%s>", TEST_TABLE1.getFullyQualifiedName(), "C1");
|
||||
CreateTestCase create =
|
||||
createRequest(test)
|
||||
.withTestDefinition(TEST_DEFINITION2.getFullyQualifiedName())
|
||||
.withEntityLink(wrongCaseColumnLink);
|
||||
|
||||
assertResponseContains(
|
||||
() -> createAndCheckEntity(create, ADMIN_AUTH_HEADERS),
|
||||
BAD_REQUEST,
|
||||
"Invalid column name C1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createUpdateDelete_tests_200(TestInfo test) throws IOException {
|
||||
// Create a test case
|
||||
|
@ -520,10 +520,16 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
|
||||
|
||||
MessageParser.EntityLink TABLE4_COLUMN_LINK =
|
||||
MessageParser.EntityLink.parse(
|
||||
String.format("<#E::table::%s::columns::c1>", TABLES.get(4).getFullyQualifiedName()));
|
||||
String.format(
|
||||
"<#E::table::%s::columns::%s>",
|
||||
TABLES.get(4).getFullyQualifiedName(),
|
||||
TABLES.get(4).getColumns().get(0).getName()));
|
||||
MessageParser.EntityLink TABLE6_COLUMN_LINK =
|
||||
MessageParser.EntityLink.parse(
|
||||
String.format("<#E::table::%s::columns::c1>", TABLES.get(6).getFullyQualifiedName()));
|
||||
String.format(
|
||||
"<#E::table::%s::columns::%s>",
|
||||
TABLES.get(6).getFullyQualifiedName(),
|
||||
TABLES.get(6).getColumns().get(0).getName()));
|
||||
CreateTestCase create4 = testCaseResourceTest.createRequest(test);
|
||||
CreateTestCase create6 = testCaseResourceTest.createRequest(test, 2);
|
||||
create4
|
||||
|
Loading…
x
Reference in New Issue
Block a user