fix: add domain params for test suite search list filter (#18263)

This commit is contained in:
Teddy 2024-10-15 20:45:19 +02:00 committed by GitHub
parent be82086e25
commit c6586d338d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 39 additions and 1 deletions

View File

@ -147,7 +147,8 @@ public class TestSuiteRepository extends EntityRepository<TestSuite> {
public void setInheritedFields(TestSuite testSuite, EntityUtil.Fields fields) {
if (Boolean.TRUE.equals(testSuite.getExecutable())) {
Table table =
Entity.getEntity(TABLE, testSuite.getExecutableEntityReference().getId(), "owners", ALL);
Entity.getEntity(
TABLE, testSuite.getExecutableEntityReference().getId(), "owners,domain", ALL);
inheritOwners(testSuite, fields, table);
inheritDomain(testSuite, fields, table);
}

View File

@ -230,6 +230,9 @@ public class TestSuiteResource extends EntityResource<TestSuite, TestSuiteReposi
@QueryParam("includeEmptyTestSuites")
@DefaultValue("true")
Boolean includeEmptyTestSuites,
@Parameter(description = "Filter a test suite by domain.", schema = @Schema(type = "string"))
@QueryParam("domain")
String domain,
@Parameter(
description = "Filter a test suite by fully qualified name.",
schema = @Schema(type = "string"))
@ -283,6 +286,7 @@ public class TestSuiteResource extends EntityResource<TestSuite, TestSuiteReposi
searchListFilter.addQueryParam("includeEmptyTestSuites", includeEmptyTestSuites);
searchListFilter.addQueryParam("fullyQualifiedName", fullyQualifiedName);
searchListFilter.addQueryParam("excludeFields", SEARCH_FIELDS_EXCLUDE);
searchListFilter.addQueryParam("domain", domain);
if (!nullOrEmpty(owner)) {
EntityInterface entity;
try {

View File

@ -5,6 +5,7 @@ import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.openmetadata.service.util.TestUtils.ADMIN_AUTH_HEADERS;
import static org.openmetadata.service.util.TestUtils.LONG_ENTITY_NAME;
import static org.openmetadata.service.util.TestUtils.assertListNotNull;
@ -274,6 +275,38 @@ public class TestSuiteResourceTest extends EntityResourceTest<TestSuite, CreateT
assertOwners(table.getOwners(), testSuite.getOwners());
}
@Test
void test_inheritDomainFromTable(TestInfo test) throws IOException {
TableResourceTest tableResourceTest = new TableResourceTest();
CreateTable tableReq =
tableResourceTest
.createRequest(test)
.withColumns(
List.of(
new Column()
.withName(C1)
.withDisplayName("c1")
.withDataType(ColumnDataType.VARCHAR)
.withDataLength(10)))
.withDomain(DOMAIN1.getFullyQualifiedName());
Table table = tableResourceTest.createEntity(tableReq, ADMIN_AUTH_HEADERS);
table = tableResourceTest.getEntity(table.getId(), "*", ADMIN_AUTH_HEADERS);
CreateTestSuite createExecutableTestSuite = createRequest(table.getFullyQualifiedName());
TestSuite executableTestSuite =
createExecutableTestSuite(createExecutableTestSuite, ADMIN_AUTH_HEADERS);
TestSuite testSuite = getEntity(executableTestSuite.getId(), "domain", ADMIN_AUTH_HEADERS);
assertEquals(DOMAIN1.getId(), testSuite.getDomain().getId());
ResultList<TestSuite> testSuites =
listEntitiesFromSearch(
Map.of("domain", DOMAIN1.getFullyQualifiedName(), "fields", "domain"),
100,
0,
ADMIN_AUTH_HEADERS);
assertTrue(
testSuites.getData().stream()
.allMatch(ts -> ts.getDomain().getId().equals(DOMAIN1.getId())));
}
@Test
void post_createLogicalTestSuiteAndAddTests_200(TestInfo test) throws IOException {
TestCaseResourceTest testCaseResourceTest = new TestCaseResourceTest();