mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-02 12:26:42 +00:00
Fix failing tests from sdk (#23641)
* Fix Failing Test * Fix testst * Fix table Resource tests * Fix Glossary Test * Fix Type Resource Test * Add sdk path * Fix Tests --------- Co-authored-by: Sriharsha Chintalapani <harshach@users.noreply.github.com>
This commit is contained in:
parent
1fb18ef815
commit
347c26b10c
1
.github/workflows/maven-build-collate.yml
vendored
1
.github/workflows/maven-build-collate.yml
vendored
@ -22,6 +22,7 @@ on:
|
||||
- "openmetadata-spec/src/main/resources/json/schema/**"
|
||||
- "openmetadata-dist/**"
|
||||
- "openmetadata-clients/**"
|
||||
- "openmetadata-sdk/**"
|
||||
- "common/**"
|
||||
- "pom.xml"
|
||||
- "yarn.lock"
|
||||
|
1
.github/workflows/maven-build-skip.yml
vendored
1
.github/workflows/maven-build-skip.yml
vendored
@ -22,6 +22,7 @@ on:
|
||||
- "openmetadata-spec/src/main/resources/json/schema/**"
|
||||
- "openmetadata-dist/**"
|
||||
- "openmetadata-clients/**"
|
||||
- "openmetadata-sdk/**"
|
||||
- "common/**"
|
||||
- "pom.xml"
|
||||
- "yarn.lock"
|
||||
|
2
.github/workflows/maven-build.yml
vendored
2
.github/workflows/maven-build.yml
vendored
@ -22,6 +22,7 @@ on:
|
||||
- "openmetadata-spec/src/main/resources/json/schema/**"
|
||||
- "openmetadata-dist/**"
|
||||
- "openmetadata-clients/**"
|
||||
- "openmetadata-sdk/**"
|
||||
- "common/**"
|
||||
- "pom.xml"
|
||||
- "yarn.lock"
|
||||
@ -34,6 +35,7 @@ on:
|
||||
- "openmetadata-spec/src/main/resources/json/schema/**"
|
||||
- "openmetadata-dist/**"
|
||||
- "openmetadata-clients/**"
|
||||
- "openmetadata-sdk/**"
|
||||
- "common/**"
|
||||
- "pom.xml"
|
||||
- "yarn.lock"
|
||||
|
@ -19,6 +19,7 @@ on:
|
||||
- "openmetadata-spec/src/main/resources/json/schema/**"
|
||||
- "openmetadata-dist/**"
|
||||
- "openmetadata-clients/**"
|
||||
- "openmetadata-sdk/**"
|
||||
- "common/**"
|
||||
- "pom.xml"
|
||||
- "yarn.lock"
|
||||
|
@ -21,6 +21,7 @@ on:
|
||||
- "openmetadata-spec/src/main/resources/json/schema/**"
|
||||
- "openmetadata-dist/**"
|
||||
- "openmetadata-clients/**"
|
||||
- "openmetadata-sdk/**"
|
||||
- "common/**"
|
||||
- "pom.xml"
|
||||
- "yarn.lock"
|
||||
@ -33,6 +34,7 @@ on:
|
||||
- "openmetadata-spec/src/main/resources/json/schema/**"
|
||||
- "openmetadata-dist/**"
|
||||
- "openmetadata-clients/**"
|
||||
- "openmetadata-sdk/**"
|
||||
- "common/**"
|
||||
- "pom.xml"
|
||||
- "yarn.lock"
|
||||
|
1
.github/workflows/maven-sonar-build.yml
vendored
1
.github/workflows/maven-sonar-build.yml
vendored
@ -20,6 +20,7 @@ on:
|
||||
- "openmetadata-spec/src/main/resources/json/schema/**"
|
||||
- "openmetadata-dist/**"
|
||||
- "openmetadata-clients/**"
|
||||
- "openmetadata-sdk/**"
|
||||
- "common/**"
|
||||
- "pom.xml"
|
||||
- "yarn.lock"
|
||||
|
@ -27,17 +27,7 @@ public class Classification {
|
||||
// Static CRUD methods
|
||||
public static org.openmetadata.schema.entity.classification.Classification create(
|
||||
CreateClassification request) {
|
||||
// Convert CreateClassification to Classification
|
||||
org.openmetadata.schema.entity.classification.Classification entity =
|
||||
new org.openmetadata.schema.entity.classification.Classification();
|
||||
entity.setName(request.getName());
|
||||
if (request.getDisplayName() != null) {
|
||||
entity.setDisplayName(request.getDisplayName());
|
||||
}
|
||||
if (request.getDescription() != null) {
|
||||
entity.setDescription(request.getDescription());
|
||||
}
|
||||
return getClient().classifications().create(entity);
|
||||
return getClient().classifications().create(request);
|
||||
}
|
||||
|
||||
public static org.openmetadata.schema.entity.classification.Classification retrieve(String id) {
|
||||
|
@ -23,25 +23,7 @@ public class DatabaseService extends org.openmetadata.schema.entity.services.Dat
|
||||
// Static CRUD methods
|
||||
public static org.openmetadata.schema.entity.services.DatabaseService create(
|
||||
CreateDatabaseService request) {
|
||||
// Convert CreateDatabaseService to DatabaseService
|
||||
org.openmetadata.schema.entity.services.DatabaseService service =
|
||||
new org.openmetadata.schema.entity.services.DatabaseService();
|
||||
service.setName(request.getName());
|
||||
if (request.getDisplayName() != null) {
|
||||
service.setDisplayName(request.getDisplayName());
|
||||
}
|
||||
if (request.getDescription() != null) {
|
||||
service.setDescription(request.getDescription());
|
||||
}
|
||||
service.setServiceType(request.getServiceType());
|
||||
service.setConnection(request.getConnection());
|
||||
if (request.getTags() != null) {
|
||||
service.setTags(request.getTags());
|
||||
}
|
||||
if (request.getOwners() != null) {
|
||||
service.setOwners(request.getOwners());
|
||||
}
|
||||
return getClient().databaseServices().create(service);
|
||||
return getClient().databaseServices().create(request);
|
||||
}
|
||||
|
||||
public static org.openmetadata.schema.entity.services.DatabaseService retrieve(String id) {
|
||||
|
@ -4,7 +4,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.openmetadata.schema.api.data.CreateGlossaryTerm;
|
||||
import org.openmetadata.schema.type.EntityReference;
|
||||
import org.openmetadata.sdk.client.OpenMetadataClient;
|
||||
|
||||
/**
|
||||
@ -28,33 +27,7 @@ public class GlossaryTerm {
|
||||
// Static CRUD methods
|
||||
public static org.openmetadata.schema.entity.data.GlossaryTerm create(
|
||||
CreateGlossaryTerm request) {
|
||||
// Convert CreateGlossaryTerm to GlossaryTerm
|
||||
org.openmetadata.schema.entity.data.GlossaryTerm entity =
|
||||
new org.openmetadata.schema.entity.data.GlossaryTerm();
|
||||
entity.setName(request.getName());
|
||||
if (request.getDisplayName() != null) {
|
||||
entity.setDisplayName(request.getDisplayName());
|
||||
}
|
||||
if (request.getDescription() != null) {
|
||||
entity.setDescription(request.getDescription());
|
||||
}
|
||||
if (request.getGlossary() != null) {
|
||||
entity.setGlossary(
|
||||
new EntityReference().withFullyQualifiedName(request.getGlossary()).withType("glossary"));
|
||||
}
|
||||
if (request.getParent() != null) {
|
||||
entity.setParent(
|
||||
new EntityReference()
|
||||
.withFullyQualifiedName(request.getParent())
|
||||
.withType("glossaryTerm"));
|
||||
}
|
||||
if (request.getOwners() != null) {
|
||||
entity.setOwners(request.getOwners());
|
||||
}
|
||||
if (request.getTags() != null) {
|
||||
entity.setTags(request.getTags());
|
||||
}
|
||||
return getClient().glossaryTerms().create(entity);
|
||||
return getClient().glossaryTerms().create(request);
|
||||
}
|
||||
|
||||
public static org.openmetadata.schema.entity.data.GlossaryTerm retrieve(String id) {
|
||||
|
@ -32,8 +32,9 @@ public class TestCase {
|
||||
|
||||
// Static methods for CRUD operations
|
||||
public static org.openmetadata.schema.tests.TestCase create(
|
||||
org.openmetadata.schema.tests.TestCase testCase) throws OpenMetadataException {
|
||||
return getClient().testCases().create(testCase);
|
||||
org.openmetadata.schema.api.tests.CreateTestCase createTestCase)
|
||||
throws OpenMetadataException {
|
||||
return getClient().testCases().create(createTestCase);
|
||||
}
|
||||
|
||||
public static org.openmetadata.schema.tests.TestCase retrieve(String id)
|
||||
|
@ -3,6 +3,8 @@ package org.openmetadata.sdk.fluent;
|
||||
import java.util.*;
|
||||
import org.openmetadata.schema.api.data.CreateDatabaseSchema;
|
||||
import org.openmetadata.schema.entity.data.DatabaseSchema;
|
||||
import org.openmetadata.schema.type.EntityReference;
|
||||
import org.openmetadata.schema.type.TagLabel;
|
||||
import org.openmetadata.sdk.client.OpenMetadataClient;
|
||||
import org.openmetadata.sdk.fluent.collections.DatabaseSchemaCollection;
|
||||
|
||||
@ -171,7 +173,7 @@ public final class DatabaseSchemas {
|
||||
}
|
||||
|
||||
public DatabaseSchemaFinder includeAll() {
|
||||
includes.addAll(Arrays.asList("owners", "tags", "followers", "domains"));
|
||||
includes.addAll(Arrays.asList("owners", "tags", "followers", "domains", "dataProducts"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -285,6 +287,12 @@ public final class DatabaseSchemas {
|
||||
return databaseSchema;
|
||||
}
|
||||
|
||||
public FluentDatabaseSchema withOwners(List<EntityReference> owners) {
|
||||
databaseSchema.setOwners(owners);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentDatabaseSchema withDescription(String description) {
|
||||
databaseSchema.setDescription(description);
|
||||
modified = true;
|
||||
@ -297,6 +305,24 @@ public final class DatabaseSchemas {
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentDatabaseSchema withTags(List<TagLabel> tags) {
|
||||
databaseSchema.setTags(tags);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentDatabaseSchema withDomains(List<EntityReference> domain) {
|
||||
databaseSchema.setDomains(domain);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentDatabaseSchema withDataProducts(List<EntityReference> dataProducts) {
|
||||
databaseSchema.setDataProducts(dataProducts);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentDatabaseSchema save() {
|
||||
if (modified) {
|
||||
DatabaseSchema updated =
|
||||
|
@ -3,6 +3,8 @@ package org.openmetadata.sdk.fluent;
|
||||
import java.util.*;
|
||||
import org.openmetadata.schema.api.data.CreateDatabase;
|
||||
import org.openmetadata.schema.entity.data.Database;
|
||||
import org.openmetadata.schema.type.EntityReference;
|
||||
import org.openmetadata.schema.type.TagLabel;
|
||||
import org.openmetadata.sdk.client.OpenMetadataClient;
|
||||
import org.openmetadata.sdk.fluent.collections.DatabaseCollection;
|
||||
|
||||
@ -171,7 +173,7 @@ public final class Databases {
|
||||
}
|
||||
|
||||
public DatabaseFinder includeAll() {
|
||||
includes.addAll(Arrays.asList("owners", "tags", "followers", "domains"));
|
||||
includes.addAll(Arrays.asList("owners", "tags", "followers", "domains", "dataProducts"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -295,6 +297,30 @@ public final class Databases {
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentDatabase withOwners(List<EntityReference> owners) {
|
||||
database.setOwners(owners);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentDatabase withTags(List<TagLabel> tags) {
|
||||
database.setTags(tags);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentDatabase withDomains(List<EntityReference> domain) {
|
||||
database.setDomains(domain);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentDatabase withDataProducts(List<EntityReference> dataProducts) {
|
||||
database.setDataProducts(dataProducts);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentDatabase save() {
|
||||
if (modified) {
|
||||
Database updated = client.databases().update(database.getId().toString(), database);
|
||||
|
@ -4,6 +4,7 @@ import java.util.*;
|
||||
import org.openmetadata.schema.api.data.CreateGlossaryTerm;
|
||||
import org.openmetadata.schema.api.data.TermReference;
|
||||
import org.openmetadata.schema.entity.data.GlossaryTerm;
|
||||
import org.openmetadata.schema.type.TagLabel;
|
||||
import org.openmetadata.sdk.client.OpenMetadataClient;
|
||||
import org.openmetadata.sdk.fluent.collections.GlossaryTermCollection;
|
||||
|
||||
@ -328,6 +329,12 @@ public final class GlossaryTerms {
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentGlossaryTerm withTags(List<TagLabel> tags) {
|
||||
glossaryTerm.setTags(tags);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentGlossaryTerm save() {
|
||||
if (modified) {
|
||||
GlossaryTerm updated =
|
||||
|
@ -3,7 +3,10 @@ package org.openmetadata.sdk.fluent;
|
||||
import java.util.*;
|
||||
import org.openmetadata.schema.api.data.CreateTable;
|
||||
import org.openmetadata.schema.entity.data.Table;
|
||||
import org.openmetadata.schema.type.Column;
|
||||
import org.openmetadata.schema.type.ColumnDataType;
|
||||
import org.openmetadata.schema.type.EntityReference;
|
||||
import org.openmetadata.schema.type.TagLabel;
|
||||
import org.openmetadata.sdk.client.OpenMetadataClient;
|
||||
|
||||
/**
|
||||
@ -170,7 +173,7 @@ public final class Tables {
|
||||
}
|
||||
|
||||
public TableFinder includeAll() {
|
||||
includes.addAll(Arrays.asList("owners", "tags", "followers", "domains"));
|
||||
includes.addAll(Arrays.asList("owners", "tags", "followers", "domains", "dataProducts"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -297,6 +300,36 @@ public final class Tables {
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentTable withOwners(List<EntityReference> owners) {
|
||||
table.setOwners(owners);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentTable withTags(List<TagLabel> tags) {
|
||||
table.setTags(tags);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentTable withDomains(List<EntityReference> domain) {
|
||||
table.setDomains(domain);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentTable withDataProducts(List<EntityReference> dataProducts) {
|
||||
table.setDataProducts(dataProducts);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentTable withColumns(List<Column> columns) {
|
||||
table.setColumns(columns);
|
||||
modified = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluentTable save() {
|
||||
if (modified) {
|
||||
Table updated = client.tables().update(table.getId().toString(), table);
|
||||
|
@ -51,7 +51,7 @@ public class ClassificationMockTest {
|
||||
expectedClassification.setDisplayName("Data Classification");
|
||||
expectedClassification.setFullyQualifiedName("DataClassification");
|
||||
|
||||
when(mockClassificationService.create(any(Classification.class)))
|
||||
when(mockClassificationService.create(any(CreateClassification.class)))
|
||||
.thenReturn(expectedClassification);
|
||||
|
||||
// Act
|
||||
@ -61,7 +61,7 @@ public class ClassificationMockTest {
|
||||
assertNotNull(result);
|
||||
assertEquals("DataClassification", result.getName());
|
||||
assertEquals("Data Classification", result.getDisplayName());
|
||||
verify(mockClassificationService).create(any(Classification.class));
|
||||
verify(mockClassificationService).create(any(CreateClassification.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -79,7 +79,7 @@ public class ClassificationMockTest {
|
||||
expectedTag.setDisplayName("Personally Identifiable Information");
|
||||
expectedTag.setFullyQualifiedName("DataClassification.PII");
|
||||
|
||||
when(mockTagService.create(any(Tag.class))).thenReturn(expectedTag);
|
||||
when(mockTagService.create(any(CreateTag.class))).thenReturn(expectedTag);
|
||||
|
||||
// Act
|
||||
Tag result = org.openmetadata.sdk.entities.Tag.create(createRequest);
|
||||
@ -89,7 +89,7 @@ public class ClassificationMockTest {
|
||||
assertEquals("PII", result.getName());
|
||||
assertEquals("Personally Identifiable Information", result.getDisplayName());
|
||||
assertEquals("DataClassification.PII", result.getFullyQualifiedName());
|
||||
verify(mockTagService).create(any(Tag.class));
|
||||
verify(mockTagService).create(any(CreateTag.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -49,7 +49,7 @@ public class ContainerMockTest {
|
||||
expectedContainer.setFullyQualifiedName("s3.data-lake-bucket");
|
||||
expectedContainer.setDisplayName("Data Lake Bucket");
|
||||
|
||||
when(mockContainerService.create(any(Container.class))).thenReturn(expectedContainer);
|
||||
when(mockContainerService.create(any(CreateContainer.class))).thenReturn(expectedContainer);
|
||||
|
||||
// Act
|
||||
Container result = org.openmetadata.sdk.entities.Container.create(createRequest);
|
||||
@ -58,7 +58,7 @@ public class ContainerMockTest {
|
||||
assertNotNull(result);
|
||||
assertEquals("data-lake-bucket", result.getName());
|
||||
assertEquals("Data Lake Bucket", result.getDisplayName());
|
||||
verify(mockContainerService).create(any(Container.class));
|
||||
verify(mockContainerService).create(any(CreateContainer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,7 +47,7 @@ public class DashboardMockTest {
|
||||
expectedDashboard.setFullyQualifiedName("superset.sales_dashboard");
|
||||
expectedDashboard.setDisplayName("Sales Dashboard");
|
||||
|
||||
when(mockDashboardService.create(any(Dashboard.class))).thenReturn(expectedDashboard);
|
||||
when(mockDashboardService.create(any(CreateDashboard.class))).thenReturn(expectedDashboard);
|
||||
|
||||
// Act
|
||||
Dashboard result = org.openmetadata.sdk.entities.Dashboard.create(createRequest);
|
||||
@ -57,7 +57,7 @@ public class DashboardMockTest {
|
||||
assertEquals("sales_dashboard", result.getName());
|
||||
assertEquals("Sales Dashboard", result.getDisplayName());
|
||||
assertEquals("superset.sales_dashboard", result.getFullyQualifiedName());
|
||||
verify(mockDashboardService).create(any(Dashboard.class));
|
||||
verify(mockDashboardService).create(any(CreateDashboard.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -56,7 +56,8 @@ public class DatabaseServiceMockTest {
|
||||
expectedService.setServiceType(CreateDatabaseService.DatabaseServiceType.Mysql);
|
||||
expectedService.setConnection(connection);
|
||||
|
||||
when(mockDatabaseServiceApi.create(any(DatabaseService.class))).thenReturn(expectedService);
|
||||
when(mockDatabaseServiceApi.create(any(CreateDatabaseService.class)))
|
||||
.thenReturn(expectedService);
|
||||
|
||||
// Act
|
||||
DatabaseService result = org.openmetadata.sdk.entities.DatabaseService.create(createRequest);
|
||||
@ -65,7 +66,7 @@ public class DatabaseServiceMockTest {
|
||||
assertNotNull(result);
|
||||
assertEquals("test_mysql_service", result.getName());
|
||||
assertEquals(CreateDatabaseService.DatabaseServiceType.Mysql, result.getServiceType());
|
||||
verify(mockDatabaseServiceApi).create(any(DatabaseService.class));
|
||||
verify(mockDatabaseServiceApi).create(any(CreateDatabaseService.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -53,7 +53,7 @@ public class GlossaryMockTest {
|
||||
expectedGlossary.setDisplayName("Business Glossary");
|
||||
expectedGlossary.setFullyQualifiedName("business-glossary");
|
||||
|
||||
when(mockGlossaryService.create(any(Glossary.class))).thenReturn(expectedGlossary);
|
||||
when(mockGlossaryService.create(any(CreateGlossary.class))).thenReturn(expectedGlossary);
|
||||
|
||||
// Act
|
||||
Glossary result = org.openmetadata.sdk.entities.Glossary.create(createRequest);
|
||||
@ -62,7 +62,7 @@ public class GlossaryMockTest {
|
||||
assertNotNull(result);
|
||||
assertEquals("business-glossary", result.getName());
|
||||
assertEquals("Business Glossary", result.getDisplayName());
|
||||
verify(mockGlossaryService).create(any(Glossary.class));
|
||||
verify(mockGlossaryService).create(any(CreateGlossary.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -82,7 +82,7 @@ public class GlossaryMockTest {
|
||||
expectedTerm.setFullyQualifiedName("business-glossary.customer-lifetime-value");
|
||||
expectedTerm.setSynonyms(List.of("CLV", "LTV"));
|
||||
|
||||
when(mockGlossaryTermService.create(any(GlossaryTerm.class))).thenReturn(expectedTerm);
|
||||
when(mockGlossaryTermService.create(any(CreateGlossaryTerm.class))).thenReturn(expectedTerm);
|
||||
|
||||
// Act
|
||||
GlossaryTerm result = org.openmetadata.sdk.entities.GlossaryTerm.create(createRequest);
|
||||
@ -93,7 +93,7 @@ public class GlossaryMockTest {
|
||||
assertEquals("Customer Lifetime Value", result.getDisplayName());
|
||||
assertNotNull(result.getSynonyms());
|
||||
assertEquals(2, result.getSynonyms().size());
|
||||
verify(mockGlossaryTermService).create(any(GlossaryTerm.class));
|
||||
verify(mockGlossaryTermService).create(any(CreateGlossaryTerm.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -48,7 +48,7 @@ public class MlModelMockTest {
|
||||
expectedModel.setFullyQualifiedName("mlflow.customer-churn-predictor");
|
||||
expectedModel.setAlgorithm("XGBoost");
|
||||
|
||||
when(mockMlModelService.create(any(MlModel.class))).thenReturn(expectedModel);
|
||||
when(mockMlModelService.create(any(CreateMlModel.class))).thenReturn(expectedModel);
|
||||
|
||||
// Act
|
||||
MlModel result = org.openmetadata.sdk.entities.MlModel.create(createRequest);
|
||||
@ -57,7 +57,7 @@ public class MlModelMockTest {
|
||||
assertNotNull(result);
|
||||
assertEquals("customer-churn-predictor", result.getName());
|
||||
assertEquals("XGBoost", result.getAlgorithm());
|
||||
verify(mockMlModelService).create(any(MlModel.class));
|
||||
verify(mockMlModelService).create(any(CreateMlModel.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -45,7 +45,7 @@ public class PipelineMockTest {
|
||||
expectedPipeline.setFullyQualifiedName("airflow.etl_pipeline");
|
||||
expectedPipeline.setDisplayName("ETL Pipeline");
|
||||
|
||||
when(mockPipelineService.create(any(Pipeline.class))).thenReturn(expectedPipeline);
|
||||
when(mockPipelineService.create(any(CreatePipeline.class))).thenReturn(expectedPipeline);
|
||||
|
||||
// Act
|
||||
Pipeline result = org.openmetadata.sdk.entities.Pipeline.create(createRequest);
|
||||
@ -55,7 +55,7 @@ public class PipelineMockTest {
|
||||
assertEquals("etl_pipeline", result.getName());
|
||||
assertEquals("ETL Pipeline", result.getDisplayName());
|
||||
assertEquals("airflow.etl_pipeline", result.getFullyQualifiedName());
|
||||
verify(mockPipelineService).create(any(Pipeline.class));
|
||||
verify(mockPipelineService).create(any(CreatePipeline.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,7 +47,7 @@ public class QueryMockTest {
|
||||
expectedQuery.setQuery("SELECT date, SUM(revenue) FROM sales GROUP BY date");
|
||||
expectedQuery.setFullyQualifiedName("queries.daily-revenue-report");
|
||||
|
||||
when(mockQueryService.create(any(Query.class))).thenReturn(expectedQuery);
|
||||
when(mockQueryService.create(any(CreateQuery.class))).thenReturn(expectedQuery);
|
||||
|
||||
// Act
|
||||
Query result = org.openmetadata.sdk.entities.Query.create(createRequest);
|
||||
@ -56,7 +56,7 @@ public class QueryMockTest {
|
||||
assertNotNull(result);
|
||||
assertEquals("daily-revenue-report", result.getName());
|
||||
assertEquals("SELECT date, SUM(revenue) FROM sales GROUP BY date", result.getQuery());
|
||||
verify(mockQueryService).create(any(Query.class));
|
||||
verify(mockQueryService).create(any(CreateQuery.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,7 +47,7 @@ public class TeamMockTest {
|
||||
expectedTeam.setTeamType(CreateTeam.TeamType.DEPARTMENT);
|
||||
expectedTeam.setFullyQualifiedName("engineering");
|
||||
|
||||
when(mockTeamService.create(any(Team.class))).thenReturn(expectedTeam);
|
||||
when(mockTeamService.create(any(CreateTeam.class))).thenReturn(expectedTeam);
|
||||
|
||||
// Act
|
||||
Team result = org.openmetadata.sdk.entities.Team.create(createRequest);
|
||||
@ -57,7 +57,7 @@ public class TeamMockTest {
|
||||
assertEquals("engineering", result.getName());
|
||||
assertEquals("Engineering Team", result.getDisplayName());
|
||||
assertEquals(CreateTeam.TeamType.DEPARTMENT, result.getTeamType());
|
||||
verify(mockTeamService).create(any(Team.class));
|
||||
verify(mockTeamService).create(any(CreateTeam.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -51,21 +51,15 @@ public class TestCaseMockTest {
|
||||
expectedTestCase.setName("null-check-test");
|
||||
expectedTestCase.setFullyQualifiedName("quality-test-suite.null-check-test");
|
||||
|
||||
when(mockTestCaseService.create(any(TestCase.class))).thenReturn(expectedTestCase);
|
||||
when(mockTestCaseService.create(any(CreateTestCase.class))).thenReturn(expectedTestCase);
|
||||
|
||||
// Act
|
||||
// Convert CreateTestCase to TestCase for the create method
|
||||
TestCase testCaseEntity = new TestCase();
|
||||
testCaseEntity.setName(createRequest.getName());
|
||||
testCaseEntity.setDisplayName(createRequest.getDisplayName());
|
||||
testCaseEntity.setDescription(createRequest.getDescription());
|
||||
|
||||
TestCase result = org.openmetadata.sdk.entities.TestCase.create(testCaseEntity);
|
||||
TestCase result = org.openmetadata.sdk.entities.TestCase.create(createRequest);
|
||||
|
||||
// Assert
|
||||
assertNotNull(result);
|
||||
assertEquals("null-check-test", result.getName());
|
||||
verify(mockTestCaseService).create(any(TestCase.class));
|
||||
verify(mockTestCaseService).create(any(CreateTestCase.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,7 +47,7 @@ public class TopicMockTest {
|
||||
expectedTopic.setPartitions(10);
|
||||
expectedTopic.setReplicationFactor(3);
|
||||
|
||||
when(mockTopicService.create(any(Topic.class))).thenReturn(expectedTopic);
|
||||
when(mockTopicService.create(any(CreateTopic.class))).thenReturn(expectedTopic);
|
||||
|
||||
// Act
|
||||
Topic result = org.openmetadata.sdk.entities.Topic.create(createRequest);
|
||||
@ -57,7 +57,7 @@ public class TopicMockTest {
|
||||
assertEquals("user_events", result.getName());
|
||||
assertEquals(10, result.getPartitions());
|
||||
assertEquals(3, result.getReplicationFactor());
|
||||
verify(mockTopicService).create(any(Topic.class));
|
||||
verify(mockTopicService).create(any(CreateTopic.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,7 +47,7 @@ public class UserMockTest {
|
||||
expectedUser.setDisplayName("John Doe");
|
||||
expectedUser.setFullyQualifiedName("john.doe");
|
||||
|
||||
when(mockUserService.create(any(User.class))).thenReturn(expectedUser);
|
||||
when(mockUserService.create(any(CreateUser.class))).thenReturn(expectedUser);
|
||||
|
||||
// Act
|
||||
User result = org.openmetadata.sdk.entities.User.create(createRequest);
|
||||
@ -57,7 +57,7 @@ public class UserMockTest {
|
||||
assertEquals("john.doe", result.getName());
|
||||
assertEquals("john.doe@example.com", result.getEmail());
|
||||
assertEquals("John Doe", result.getDisplayName());
|
||||
verify(mockUserService).create(any(User.class));
|
||||
verify(mockUserService).create(any(CreateUser.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -7437,7 +7437,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
.withState(TagLabel.State.CONFIRMED));
|
||||
|
||||
// Update entity with tags using reflection
|
||||
entityWithTags.getClass().getMethod("setTags", List.class).invoke(entityWithTags, tags);
|
||||
entityWithTags.setTags(tags);
|
||||
|
||||
// Update with SDK
|
||||
T updatedEntity = null;
|
||||
@ -7470,13 +7470,12 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
assertNotNull(updatedEntity);
|
||||
List<TagLabel> updatedTags =
|
||||
(List<TagLabel>) updatedEntity.getClass().getMethod("getTags").invoke(updatedEntity);
|
||||
List<TagLabel> updatedTags = updatedEntity.getTags();
|
||||
assertEquals(2, updatedTags.size());
|
||||
|
||||
// Remove one tag and update
|
||||
updatedTags.remove(0);
|
||||
updatedEntity.getClass().getMethod("setTags", List.class).invoke(updatedEntity, updatedTags);
|
||||
updatedEntity.setTags(updatedTags);
|
||||
|
||||
T finalEntity = null;
|
||||
switch (entityType) {
|
||||
@ -7507,8 +7506,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
}
|
||||
|
||||
List<TagLabel> finalTags =
|
||||
(List<TagLabel>) finalEntity.getClass().getMethod("getTags").invoke(finalEntity);
|
||||
List<TagLabel> finalTags = finalEntity.getTags();
|
||||
assertEquals(1, finalTags.size());
|
||||
assertEquals("PII.Sensitive", finalTags.get(0).getTagFQN());
|
||||
|
||||
@ -7561,30 +7559,10 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
assertNotNull(createdEntity);
|
||||
String entityId = createdEntity.getId().toString();
|
||||
|
||||
// Fetch with owners field
|
||||
T entityWithOwners = null;
|
||||
switch (entityType) {
|
||||
case Entity.TABLE -> {
|
||||
Tables.setDefaultClient(sdkClient);
|
||||
entityWithOwners = (T) Tables.find(entityId).includeOwners().fetch().get();
|
||||
}
|
||||
case Entity.DATABASE -> {
|
||||
Databases.setDefaultClient(sdkClient);
|
||||
entityWithOwners = (T) Databases.find(entityId).includeOwners().fetch().get();
|
||||
}
|
||||
case Entity.DATABASE_SCHEMA -> {
|
||||
DatabaseSchemas.setDefaultClient(sdkClient);
|
||||
entityWithOwners = (T) DatabaseSchemas.find(entityId).includeOwners().fetch().get();
|
||||
}
|
||||
}
|
||||
|
||||
// Add owners
|
||||
List<EntityReference> owners = new ArrayList<>();
|
||||
owners.add(new EntityReference().withId(USER1.getId()).withType(Entity.USER));
|
||||
owners.add(new EntityReference().withId(TEAM11.getId()).withType(Entity.TEAM));
|
||||
|
||||
// Update entity with owners using reflection
|
||||
entityWithOwners.getClass().getMethod("setOwners", List.class).invoke(entityWithOwners, owners);
|
||||
owners.add(new EntityReference().withId(USER2.getId()).withType(Entity.USER));
|
||||
|
||||
// Update with SDK
|
||||
T updatedEntity = null;
|
||||
@ -7592,74 +7570,66 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
case Entity.TABLE -> {
|
||||
Tables.setDefaultClient(sdkClient);
|
||||
var fluentTable = Tables.find(entityId).fetch();
|
||||
var tableEntity = fluentTable.get();
|
||||
tableEntity.setOwners(
|
||||
((org.openmetadata.schema.entity.data.Table) entityWithOwners).getOwners());
|
||||
fluentTable.withOwners(owners);
|
||||
updatedEntity = (T) fluentTable.save().get();
|
||||
}
|
||||
case Entity.DATABASE -> {
|
||||
Databases.setDefaultClient(sdkClient);
|
||||
var fluentDatabase = Databases.find(entityId).fetch();
|
||||
var dbEntity = fluentDatabase.get();
|
||||
dbEntity.setOwners(
|
||||
((org.openmetadata.schema.entity.data.Database) entityWithOwners).getOwners());
|
||||
fluentDatabase.withOwners(owners);
|
||||
updatedEntity = (T) fluentDatabase.save().get();
|
||||
}
|
||||
case Entity.DATABASE_SCHEMA -> {
|
||||
DatabaseSchemas.setDefaultClient(sdkClient);
|
||||
var fluentSchema = DatabaseSchemas.find(entityId).fetch();
|
||||
var schemaEntity = fluentSchema.get();
|
||||
schemaEntity.setOwners(
|
||||
((org.openmetadata.schema.entity.data.DatabaseSchema) entityWithOwners).getOwners());
|
||||
fluentSchema.withOwners(owners);
|
||||
updatedEntity = (T) fluentSchema.save().get();
|
||||
}
|
||||
}
|
||||
|
||||
assertNotNull(updatedEntity);
|
||||
List<EntityReference> updatedOwners =
|
||||
(List<EntityReference>)
|
||||
updatedEntity.getClass().getMethod("getOwners").invoke(updatedEntity);
|
||||
List<EntityReference> updatedOwners = updatedEntity.getOwners();
|
||||
assertEquals(2, updatedOwners.size());
|
||||
|
||||
// Remove one owner and add another
|
||||
updatedOwners.remove(0);
|
||||
updatedOwners.add(new EntityReference().withId(USER2.getId()).withType(Entity.USER));
|
||||
updatedEntity
|
||||
.getClass()
|
||||
.getMethod("setOwners", List.class)
|
||||
.invoke(updatedEntity, updatedOwners);
|
||||
updatedOwners.add(new EntityReference().withId(USER3.getId()).withType(Entity.USER));
|
||||
updatedEntity.setOwners(updatedOwners);
|
||||
|
||||
T finalEntity = null;
|
||||
switch (entityType) {
|
||||
case Entity.TABLE -> {
|
||||
Tables.setDefaultClient(sdkClient);
|
||||
var fluentTable = Tables.find(entityId).fetch();
|
||||
var tableEntity = fluentTable.get();
|
||||
tableEntity.setTags(((org.openmetadata.schema.entity.data.Table) updatedEntity).getTags());
|
||||
tableEntity.setDescription(updatedEntity.getDescription());
|
||||
fluentTable
|
||||
.withOwners(updatedOwners)
|
||||
.withTags(updatedEntity.getTags())
|
||||
.withDescription(updatedEntity.getDescription());
|
||||
finalEntity = (T) fluentTable.save().get();
|
||||
}
|
||||
case Entity.DATABASE -> {
|
||||
Databases.setDefaultClient(sdkClient);
|
||||
var fluentDatabase = Databases.find(entityId).fetch();
|
||||
var dbEntity = fluentDatabase.get();
|
||||
dbEntity.setTags(((org.openmetadata.schema.entity.data.Database) updatedEntity).getTags());
|
||||
dbEntity.setDescription(updatedEntity.getDescription());
|
||||
finalEntity = (T) fluentDatabase.save().get();
|
||||
fluentDatabase
|
||||
.withOwners(updatedOwners)
|
||||
.withTags(updatedEntity.getTags())
|
||||
.withDescription(updatedEntity.getDescription());
|
||||
fluentDatabase.save();
|
||||
finalEntity = (T) Databases.find(entityId).includeOwners().fetch().get();
|
||||
}
|
||||
case Entity.DATABASE_SCHEMA -> {
|
||||
DatabaseSchemas.setDefaultClient(sdkClient);
|
||||
var fluentSchema = DatabaseSchemas.find(entityId).fetch();
|
||||
var schemaEntity = fluentSchema.get();
|
||||
schemaEntity.setTags(
|
||||
((org.openmetadata.schema.entity.data.DatabaseSchema) updatedEntity).getTags());
|
||||
schemaEntity.setDescription(updatedEntity.getDescription());
|
||||
finalEntity = (T) fluentSchema.save().get();
|
||||
fluentSchema
|
||||
.withOwners(updatedOwners)
|
||||
.withTags(updatedEntity.getTags())
|
||||
.withDescription(updatedEntity.getDescription());
|
||||
fluentSchema.save();
|
||||
finalEntity = (T) DatabaseSchemas.find(entityId).includeOwners().fetch().get();
|
||||
}
|
||||
}
|
||||
|
||||
List<EntityReference> finalOwners =
|
||||
(List<EntityReference>) finalEntity.getClass().getMethod("getOwners").invoke(finalEntity);
|
||||
List<EntityReference> finalOwners = finalEntity.getOwners();
|
||||
assertEquals(2, finalOwners.size());
|
||||
|
||||
// Clean up
|
||||
@ -7741,23 +7711,11 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
|
||||
// Set domain
|
||||
EntityReference domain = new EntityReference().withId(DOMAIN.getId()).withType(Entity.DOMAIN);
|
||||
entityWithDomain
|
||||
.getClass()
|
||||
.getMethod("setDomain", EntityReference.class)
|
||||
.invoke(entityWithDomain, domain);
|
||||
|
||||
// Set data products (if entity supports it - skip if NoSuchMethodException)
|
||||
try {
|
||||
List<EntityReference> dataProducts = new ArrayList<>();
|
||||
dataProducts.add(
|
||||
new EntityReference().withId(DOMAIN_DATA_PRODUCT.getId()).withType(Entity.DATA_PRODUCT));
|
||||
entityWithDomain
|
||||
.getClass()
|
||||
.getMethod("setDataProducts", List.class)
|
||||
.invoke(entityWithDomain, dataProducts);
|
||||
} catch (NoSuchMethodException e) {
|
||||
// Entity doesn't support dataProducts, continue with just domain
|
||||
}
|
||||
List<EntityReference> dataProducts = new ArrayList<>();
|
||||
dataProducts.add(
|
||||
new EntityReference().withId(DOMAIN_DATA_PRODUCT.getId()).withType(Entity.DATA_PRODUCT));
|
||||
|
||||
// Update with SDK
|
||||
T updatedEntity = null;
|
||||
@ -7765,44 +7723,34 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
case Entity.TABLE -> {
|
||||
Tables.setDefaultClient(sdkClient);
|
||||
var fluentTable = Tables.find(entityId).fetch();
|
||||
var tableEntity = fluentTable.get();
|
||||
tableEntity.setDomains(
|
||||
((org.openmetadata.schema.entity.data.Table) entityWithDomain).getDomains());
|
||||
updatedEntity = (T) fluentTable.save().get();
|
||||
fluentTable.withDomains(List.of(domain)).withDataProducts(dataProducts);
|
||||
fluentTable.save();
|
||||
updatedEntity = (T) Tables.find(entityId).includeAll().fetch().get();
|
||||
}
|
||||
case Entity.DATABASE -> {
|
||||
Databases.setDefaultClient(sdkClient);
|
||||
var fluentDatabase = Databases.find(entityId).fetch();
|
||||
var dbEntity = fluentDatabase.get();
|
||||
dbEntity.setDomains(
|
||||
((org.openmetadata.schema.entity.data.Database) entityWithDomain).getDomains());
|
||||
updatedEntity = (T) fluentDatabase.save().get();
|
||||
fluentDatabase.withDomains(List.of(domain)).withDataProducts(dataProducts);
|
||||
fluentDatabase.save();
|
||||
updatedEntity = (T) Databases.find(entityId).includeAll().fetch().get();
|
||||
}
|
||||
case Entity.DATABASE_SCHEMA -> {
|
||||
DatabaseSchemas.setDefaultClient(sdkClient);
|
||||
var fluentSchema = DatabaseSchemas.find(entityId).fetch();
|
||||
var schemaEntity = fluentSchema.get();
|
||||
schemaEntity.setDomains(
|
||||
((org.openmetadata.schema.entity.data.DatabaseSchema) entityWithDomain).getDomains());
|
||||
updatedEntity = (T) fluentSchema.save().get();
|
||||
fluentSchema.withDomains(List.of(domain)).withDataProducts(dataProducts);
|
||||
fluentSchema.save();
|
||||
updatedEntity = (T) DatabaseSchemas.find(entityId).includeAll().fetch().get();
|
||||
}
|
||||
}
|
||||
|
||||
assertNotNull(updatedEntity);
|
||||
EntityReference updatedDomain =
|
||||
(EntityReference) updatedEntity.getClass().getMethod("getDomain").invoke(updatedEntity);
|
||||
List<EntityReference> updatedDomain = updatedEntity.getDomains();
|
||||
assertNotNull(updatedDomain);
|
||||
assertEquals(DOMAIN.getId(), updatedDomain.getId());
|
||||
assertReferenceList(List.of(DOMAIN.getEntityReference()), updatedDomain);
|
||||
|
||||
// Check data products if supported
|
||||
try {
|
||||
List<EntityReference> updatedDataProducts =
|
||||
(List<EntityReference>)
|
||||
updatedEntity.getClass().getMethod("getDataProducts").invoke(updatedEntity);
|
||||
assertEquals(1, updatedDataProducts.size());
|
||||
} catch (NoSuchMethodException e) {
|
||||
// Entity doesn't support dataProducts
|
||||
}
|
||||
List<EntityReference> updatedDataProducts = updatedEntity.getDataProducts();
|
||||
assertEquals(1, updatedDataProducts.size());
|
||||
|
||||
// Clean up
|
||||
WebTarget target = getResource(createdEntity.getId());
|
||||
|
@ -158,7 +158,12 @@ public class BotResourceTest extends EntityResourceTest<Bot, CreateBot> {
|
||||
.withBotUser(
|
||||
Objects.requireNonNull(new UserResourceTest().createUser(name, true)).getName());
|
||||
}
|
||||
return new CreateBot().withName(name).withBotUser(botUser.getName());
|
||||
User bUser = new UserResourceTest().createUser(name, true);
|
||||
if (bUser == null) {
|
||||
// User already exists, fetch the user
|
||||
return new CreateBot().withName(name).withBotUser(botUser.getName());
|
||||
}
|
||||
return new CreateBot().withName(name).withBotUser(bUser.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -168,8 +173,7 @@ public class BotResourceTest extends EntityResourceTest<Bot, CreateBot> {
|
||||
assertNotNull(entity.getBotUser());
|
||||
TestUtils.validateEntityReference(entity.getBotUser());
|
||||
Assertions.assertEquals(
|
||||
request.getBotUser().toLowerCase(),
|
||||
entity.getBotUser().getFullyQualifiedName().toLowerCase());
|
||||
request.getBotUser().toLowerCase(), entity.getBotUser().getName().toLowerCase());
|
||||
} else {
|
||||
Assertions.assertNull(entity.getBotUser());
|
||||
}
|
||||
|
@ -5279,7 +5279,7 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
||||
|
||||
// Update the table using the clean API
|
||||
var fluentTable = Tables.find(createdTable.getId().toString()).fetch();
|
||||
fluentTable.get().setColumns(createdTable.getColumns());
|
||||
fluentTable.withColumns(createdTable.getColumns());
|
||||
Table updatedTable = fluentTable.save().get();
|
||||
assertNotNull(updatedTable);
|
||||
assertEquals(4, updatedTable.getColumns().size());
|
||||
|
@ -1,12 +1,14 @@
|
||||
package org.openmetadata.service.resources.glossary;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.openmetadata.service.security.SecurityUtil.authHeaders;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.openmetadata.schema.api.data.CreateGlossary;
|
||||
@ -31,17 +33,19 @@ public class GlossaryFluentAPITest extends OpenMetadataApplicationTest {
|
||||
private static final String ADMIN_AUTH_HEADERS = "admin@open-metadata.org";
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
public static void setup(TestInfo testInfo) throws URISyntaxException, IOException {
|
||||
// Initialize SDK client with admin auth headers
|
||||
new GlossaryResourceTest().setup(testInfo);
|
||||
int port = APP.getLocalPort();
|
||||
String serverUrl = String.format("http://localhost:%d/api", port);
|
||||
|
||||
OpenMetadataConfig config =
|
||||
OpenMetadataConfig.builder()
|
||||
.serverUrl(serverUrl)
|
||||
.apiKey(authHeaders(ADMIN_AUTH_HEADERS).get("Authorization"))
|
||||
.apiKey(ADMIN_AUTH_HEADERS)
|
||||
.connectTimeout(30000)
|
||||
.readTimeout(60000)
|
||||
.testMode(true)
|
||||
.build();
|
||||
|
||||
sdkClient = new OpenMetadataClient(config);
|
||||
@ -49,6 +53,7 @@ public class GlossaryFluentAPITest extends OpenMetadataApplicationTest {
|
||||
// Set default client for fluent APIs
|
||||
Glossaries.setDefaultClient(sdkClient);
|
||||
GlossaryTerms.setDefaultClient(sdkClient);
|
||||
Bulk.setDefaultClient(sdkClient);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -111,14 +116,14 @@ public class GlossaryFluentAPITest extends OpenMetadataApplicationTest {
|
||||
.name(termName)
|
||||
.withDescription("Test term created with fluent API")
|
||||
.withDisplayName("Test Term")
|
||||
.in(glossary.getId().toString())
|
||||
.in(glossary.getFullyQualifiedName())
|
||||
.execute();
|
||||
|
||||
assertNotNull(term);
|
||||
assertNotNull(term.getId());
|
||||
assertEquals(termName, term.getName());
|
||||
assertEquals("Test term created with fluent API", term.getDescription());
|
||||
assertEquals(2, term.getSynonyms().size());
|
||||
assertEquals(0, term.getSynonyms().size());
|
||||
|
||||
// Find and update term
|
||||
var fluentTerm = GlossaryTerms.find(term.getId()).fetch();
|
||||
@ -134,7 +139,7 @@ public class GlossaryFluentAPITest extends OpenMetadataApplicationTest {
|
||||
GlossaryTerms.create()
|
||||
.name(secondTermName)
|
||||
.withDescription("Second term")
|
||||
.in(glossary.getId().toString())
|
||||
.in(glossary.getFullyQualifiedName())
|
||||
.execute();
|
||||
|
||||
assertNotNull(secondTerm);
|
||||
@ -142,15 +147,16 @@ public class GlossaryFluentAPITest extends OpenMetadataApplicationTest {
|
||||
|
||||
// List terms
|
||||
var terms = GlossaryTerms.list().limit(10).fetch();
|
||||
assertTrue(terms.size() > 0);
|
||||
assertFalse(terms.isEmpty());
|
||||
|
||||
// Delete terms and glossary
|
||||
GlossaryTerms.find(secondTerm.getId()).delete().confirm();
|
||||
GlossaryTerms.find(term.getId()).delete().confirm();
|
||||
Glossaries.find(glossary.getId()).delete().confirm();
|
||||
GlossaryTerms.find(secondTerm.getId()).delete().recursively().permanently().confirm();
|
||||
GlossaryTerms.find(term.getId()).delete().recursively().permanently().confirm();
|
||||
Glossaries.find(glossary.getId()).delete().recursively().permanently().confirm();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
void test_bulkImportExportGlossary(TestInfo test) {
|
||||
// Create test data
|
||||
List<Object> entities = new ArrayList<>();
|
||||
@ -207,7 +213,7 @@ public class GlossaryFluentAPITest extends OpenMetadataApplicationTest {
|
||||
GlossaryTerms.create()
|
||||
.name(termName)
|
||||
.withDescription("Term with tags")
|
||||
.in(glossary.getId().toString())
|
||||
.in(glossary.getFullyQualifiedName())
|
||||
.execute();
|
||||
|
||||
// Add tags to term
|
||||
@ -219,7 +225,7 @@ public class GlossaryFluentAPITest extends OpenMetadataApplicationTest {
|
||||
.withSource(TagLabel.TagSource.CLASSIFICATION)
|
||||
.withState(TagLabel.State.CONFIRMED));
|
||||
|
||||
fluentTerm.get().setTags(tags);
|
||||
fluentTerm.withTags(tags);
|
||||
GlossaryTerm taggedTerm = fluentTerm.save().get();
|
||||
|
||||
assertNotNull(taggedTerm.getTags());
|
||||
@ -227,8 +233,8 @@ public class GlossaryFluentAPITest extends OpenMetadataApplicationTest {
|
||||
assertEquals("PII.Sensitive", taggedTerm.getTags().get(0).getTagFQN());
|
||||
|
||||
// Clean up
|
||||
GlossaryTerms.find(term.getId()).delete().confirm();
|
||||
Glossaries.find(glossary.getId()).delete().confirm();
|
||||
GlossaryTerms.find(term.getId()).delete().recursively().permanently().confirm();
|
||||
Glossaries.find(glossary.getId()).delete().recursively().permanently().confirm();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -244,7 +250,7 @@ public class GlossaryFluentAPITest extends OpenMetadataApplicationTest {
|
||||
GlossaryTerms.create()
|
||||
.name(parentTermName)
|
||||
.withDescription("Parent term")
|
||||
.in(rootGlossary.getId().toString())
|
||||
.in(rootGlossary.getFullyQualifiedName())
|
||||
.execute();
|
||||
|
||||
// Create multiple child terms
|
||||
@ -255,7 +261,7 @@ public class GlossaryFluentAPITest extends OpenMetadataApplicationTest {
|
||||
GlossaryTerms.create()
|
||||
.name(childTermName)
|
||||
.withDescription("Child term " + i)
|
||||
.in(rootGlossary.getId().toString())
|
||||
.in(rootGlossary.getFullyQualifiedName())
|
||||
.execute();
|
||||
childTerms.add(childTerm);
|
||||
}
|
||||
@ -273,11 +279,12 @@ public class GlossaryFluentAPITest extends OpenMetadataApplicationTest {
|
||||
child -> {
|
||||
GlossaryTerms.find(child.getId()).delete().confirm();
|
||||
});
|
||||
GlossaryTerms.find(parentTerm.getId()).delete().confirm();
|
||||
Glossaries.find(rootGlossary.getId()).delete().confirm();
|
||||
GlossaryTerms.find(parentTerm.getId()).delete().recursively().permanently().confirm();
|
||||
Glossaries.find(rootGlossary.getId()).delete().recursively().permanently().confirm();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
void test_bulkImportGlossaryTerms(TestInfo test) {
|
||||
// Create parent glossary first
|
||||
String glossaryName = "terms_glossary_" + UUID.randomUUID().toString().substring(0, 8);
|
||||
|
@ -479,6 +479,7 @@ public class TypeResourceTest extends EntityResourceTest<Type, CreateType> {
|
||||
return new CreateType()
|
||||
.withName(name)
|
||||
.withCategory(Category.Field)
|
||||
.withDescription("Type Test Description")
|
||||
.withSchema(INT_TYPE.getSchema());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user