fix: dynamic assertion to create json (#16865)

This commit is contained in:
Teddy 2024-07-01 16:52:09 +02:00 committed by GitHub
parent 65ba2d19ac
commit f766ba872d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 1 deletions

View File

@ -79,7 +79,7 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
private static final String UPDATE_FIELDS =
"owner,entityLink,testSuite,testSuites,testDefinition";
private static final String PATCH_FIELDS =
"owner,entityLink,testSuite,testDefinition,computePassedFailedRowCount";
"owner,entityLink,testSuite,testDefinition,computePassedFailedRowCount,useDynamicAssertion";
public static final String TESTCASE_RESULT_EXTENSION = "testCase.testCaseResult";
public static final String FAILED_ROWS_SAMPLE_EXTENSION = "testCase.failedRowsSample";
@ -972,6 +972,10 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
"computePassedFailedRowCount",
original.getComputePassedFailedRowCount(),
updated.getComputePassedFailedRowCount());
recordChange(
"useDynamicAssertion",
original.getUseDynamicAssertion(),
updated.getUseDynamicAssertion());
recordChange("testCaseResult", original.getTestCaseResult(), updated.getTestCaseResult());
}
}

View File

@ -1175,6 +1175,7 @@ public class TestCaseResource extends EntityResource<TestCase, TestCaseRepositor
.withParameterValues(create.getParameterValues())
.withEntityLink(create.getEntityLink())
.withComputePassedFailedRowCount(create.getComputePassedFailedRowCount())
.withUseDynamicAssertion(create.getUseDynamicAssertion())
.withEntityFQN(entityLink.getFullyQualifiedFieldValue())
.withTestSuite(getEntityReference(Entity.TEST_SUITE, create.getTestSuite()))
.withTestDefinition(getEntityReference(Entity.TEST_DEFINITION, create.getTestDefinition()));

View File

@ -2652,6 +2652,18 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes
() -> createEntity(request3, ADMIN_AUTH_HEADERS), BAD_REQUEST, "name must match");
}
@Test
void createUpdate_DynamicAssertionTests(TestInfo testInfo) throws IOException {
CreateTestCase create = createRequest(testInfo).withUseDynamicAssertion(true);
TestCase testCase = createAndCheckEntity(create, ADMIN_AUTH_HEADERS);
testCase = getTestCase(testCase.getFullyQualifiedName(), ADMIN_AUTH_HEADERS);
assertTrue(testCase.getUseDynamicAssertion());
CreateTestCase update = create.withUseDynamicAssertion(false);
updateEntity(update, OK, ADMIN_AUTH_HEADERS);
testCase = getTestCase(testCase.getFullyQualifiedName(), ADMIN_AUTH_HEADERS);
assertFalse(testCase.getUseDynamicAssertion());
}
private void putInspectionQuery(TestCase testCase, String sql, Map<String, String> authHeaders)
throws IOException {
TestCase putResponse = putInspectionQuery(testCase.getId(), sql, authHeaders);

View File

@ -44,6 +44,11 @@
"description": "Compute the passed and failed row count for the test case.",
"type": "boolean",
"default": false
},
"useDynamicAssertion": {
"description": "If the test definition supports it, use dynamic assertion to evaluate the test case.",
"type": "boolean",
"default": false
}
},
"required": ["name", "testDefinition", "entityLink", "testSuite"],