From ce3fbe17ec4964a4c1f4b02d2917e189c7ac20a9 Mon Sep 17 00:00:00 2001 From: sureshms Date: Mon, 4 Oct 2021 11:59:34 -0700 Subject: [PATCH] Fix #660 Return fully qualified name in EntityReference for all the data assets --- .../java/org/openmetadata/catalog/util/EntityUtil.java | 10 +++++----- .../catalog/resources/databases/TableResourceTest.java | 4 ++-- .../java/org/openmetadata/catalog/util/TestUtils.java | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/util/EntityUtil.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/util/EntityUtil.java index 827ba345828..2d818db2e0a 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/util/EntityUtil.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/util/EntityUtil.java @@ -468,27 +468,27 @@ public final class EntityUtil { public static EntityReference getEntityReference(Database database) { return new EntityReference().withDescription(database.getDescription()).withId(database.getId()) - .withName(database.getName()).withType(Entity.DATABASE); + .withName(database.getFullyQualifiedName()).withType(Entity.DATABASE); } public static EntityReference getEntityReference(Table table) { return new EntityReference().withDescription(table.getDescription()).withId(table.getId()) - .withName(table.getName()).withType(Entity.TABLE); + .withName(table.getFullyQualifiedName()).withType(Entity.TABLE); } public static EntityReference getEntityReference(Report report) { return new EntityReference().withDescription(report.getDescription()).withId(report.getId()) - .withName(report.getName()).withType(Entity.REPORT); + .withName(report.getFullyQualifiedName()).withType(Entity.REPORT); } public static EntityReference getEntityReference(Metrics metrics) { return new EntityReference().withDescription(metrics.getDescription()).withId(metrics.getId()) - .withName(metrics.getName()).withType(Entity.METRICS); + .withName(metrics.getFullyQualifiedName()).withType(Entity.METRICS); } public static EntityReference getEntityReference(Dashboard dashboard) { return new EntityReference().withDescription(dashboard.getDescription()).withId(dashboard.getId()) - .withName(dashboard.getName()).withType(Entity.DASHBOARD); + .withName(dashboard.getFullyQualifiedName()).withType(Entity.DASHBOARD); } public static EntityReference getEntityReference(Team team) { diff --git a/catalog-rest-service/src/test/java/org/openmetadata/catalog/resources/databases/TableResourceTest.java b/catalog-rest-service/src/test/java/org/openmetadata/catalog/resources/databases/TableResourceTest.java index 9d8bc8ece01..44b0313fac6 100644 --- a/catalog-rest-service/src/test/java/org/openmetadata/catalog/resources/databases/TableResourceTest.java +++ b/catalog-rest-service/src/test/java/org/openmetadata/catalog/resources/databases/TableResourceTest.java @@ -870,7 +870,7 @@ public class TableResourceTest extends CatalogApplicationTest { assertEquals(table.getOwner().getId(), USER_OWNER1.getId()); assertEquals(table.getOwner().getType(), USER_OWNER1.getType()); assertEquals(table.getDatabase().getId(), DATABASE.getId()); - assertEquals(table.getDatabase().getName(), DATABASE.getName()); + assertEquals(table.getDatabase().getName(), DATABASE.getFullyQualifiedName()); } // List tables with databaseFQN as filter @@ -1198,7 +1198,7 @@ public class TableResourceTest extends CatalogApplicationTest { assertEquals(table.getOwner().getId(), USER_OWNER1.getId()); assertEquals(table.getOwner().getType(), USER_OWNER1.getType()); assertEquals(table.getDatabase().getId(), DATABASE.getId()); - assertEquals(table.getDatabase().getName(), DATABASE.getName()); + assertEquals(table.getDatabase().getName(), DATABASE.getFullyQualifiedName()); } public static Table createTable(CreateTable create, Map authHeaders) throws HttpResponseException { diff --git a/catalog-rest-service/src/test/java/org/openmetadata/catalog/util/TestUtils.java b/catalog-rest-service/src/test/java/org/openmetadata/catalog/util/TestUtils.java index f32d18c04b2..7d3bd6e1a3b 100644 --- a/catalog-rest-service/src/test/java/org/openmetadata/catalog/util/TestUtils.java +++ b/catalog-rest-service/src/test/java/org/openmetadata/catalog/util/TestUtils.java @@ -194,8 +194,8 @@ public final class TestUtils { assertNotNull(ref.getType()); // Ensure data entities use fully qualified name if (List.of("table", "database", "metrics", "dashboard", "pipeline", "report", "topic", "chart") - .contains(ref.getName())) { - ref.getName().contains("."); // FullyQualifiedName has "." as separator + .contains(ref.getType())) { + assertTrue(ref.getName().contains(".")); // FullyQualifiedName has "." as separator } }