From 57e9ac085ea839379a7744fc260201dce7cbdc7a Mon Sep 17 00:00:00 2001 From: Pavan Manish Date: Fri, 10 Jan 2025 01:10:12 +0530 Subject: [PATCH] Checking if the exported file is correct --- .../kotlin/ExportDomainRelationshipTest.kt | 36 ++++++++++++++++++- .../src/test/resources/domain_relation.csv | 5 +++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 samples/packages/asset-export-basic/src/test/resources/domain_relation.csv diff --git a/samples/packages/asset-export-basic/src/test/kotlin/ExportDomainRelationshipTest.kt b/samples/packages/asset-export-basic/src/test/kotlin/ExportDomainRelationshipTest.kt index 332858dd4..1d5906f75 100644 --- a/samples/packages/asset-export-basic/src/test/kotlin/ExportDomainRelationshipTest.kt +++ b/samples/packages/asset-export-basic/src/test/kotlin/ExportDomainRelationshipTest.kt @@ -7,6 +7,7 @@ import com.atlan.pkg.PackageTest import com.atlan.pkg.Utils import com.atlan.util.AssetBatch import org.testng.annotations.Test +import java.nio.file.Paths /* * Test export of domain and asset relationships @@ -82,7 +83,7 @@ class ExportDomainRelationshipTest : PackageTest("edr") { createConnections() createAssets() runCustomPackage(AssetExportBasicCfg( - exportScope = "", + exportScope = "ALL", qnPrefix = Connection.findByName(client, c1, connectorType)?.get(0)?.qualifiedName!!, includeGlossaries = false, includeProducts = false, @@ -97,6 +98,24 @@ class ExportDomainRelationshipTest : PackageTest("edr") { removeConnection(c1, connectorType) } + private fun prepFile() { + // Prepare a copy of the file with unique names for domains and connection + val testFile = "input.csv" + val input = Paths.get("src", "test", "resources", "domain_relation.csv").toFile() + val output = Paths.get(testDirectory, testFile).toFile() + val connection = Connection.findByName(client, c1, connectorType)?.get(0)?.qualifiedName!! + input.useLines { lines -> + lines.forEach { line -> + val revised = + line + .replace("{{CONNECTIONNAME}}", connection) + .replace("{{CONNECTIONID}}", c1) + .replace("{{DOMAINNAME}}", c1) + output.appendText("$revised\n") + } + } + } + @Test fun filesCreated() { validateFilesExist(files) @@ -106,4 +125,19 @@ class ExportDomainRelationshipTest : PackageTest("edr") { fun errorFreeLog() { validateErrorFreeLog() } + + @Test + fun isExported() { + prepFile() + val testFile = Paths.get(testDirectory, "input.csv").toFile() + val originalFile = Paths.get(testDirectory, "asset-export.csv").toFile() + + // compare the contents of the exported file with the expected file + val testLines = testFile.readLines() + val originalLines = originalFile.readLines() + assert(testLines.size == originalLines.size) { "Number of lines in the files do not match" } + for (i in testLines.indices) { + assert(testLines[i] == originalLines[i]) { "Line $i does not match" } + } + } } diff --git a/samples/packages/asset-export-basic/src/test/resources/domain_relation.csv b/samples/packages/asset-export-basic/src/test/resources/domain_relation.csv new file mode 100644 index 000000000..44f65eacd --- /dev/null +++ b/samples/packages/asset-export-basic/src/test/resources/domain_relation.csv @@ -0,0 +1,5 @@ +"qualifiedName","typeName","name","displayName","description","userDescription","ownerUsers","ownerGroups","certificateStatus","certificateStatusMessage","announcementType","announcementTitle","announcementMessage","assignedTerms","atlanTags","links","readme","starredDetails","domainGUIDs","jsdk_RACI_7jt2E::Responsible","jsdk_RACI_7jt2E::Accountable","jsdk_RACI_7jt2E::Consulted","jsdk_RACI_7jt2E::Informed","jsdk_RACI_7jt2E::Extra","psdk_DM_lU6cF_CM::psdk_DM_lU6cF_ATTRIBUTE","psdk_CM_Uveq5_RACI::Responsible","psdk_CM_Uveq5_RACI::Accountable","psdk_CM_Uveq5_RACI::Consulted","psdk_CM_Uveq5_RACI::Informed","psdk_CM_Uveq5_RACI::Extra","psdk_DM_ZGayw_CM::psdk_DM_ZGayw_ATTRIBUTE","psdk_CM_74beQ_RACI::Responsible","psdk_CM_74beQ_RACI::Accountable","psdk_CM_74beQ_RACI::Consulted","psdk_CM_74beQ_RACI::Informed","psdk_CM_74beQ_RACI::Extra","psdk_CM_74beQ_RACI::Test","psdk_CM_74beQ_RACI::Test2","psdk_CM_74beQ_RACI::Test3","jsdk_DQ_7jt2E::Count","jsdk_DQ_7jt2E::SQL","jsdk_DQ_7jt2E::Type","psdk_CM_sTT8A_RACI::Responsible","psdk_CM_sTT8A_RACI::Accountable","psdk_CM_sTT8A_RACI::Consulted","psdk_CM_sTT8A_RACI::Informed","psdk_CM_sTT8A_RACI::Extra","psdk_CM_pBrk6_RACI::Responsible","psdk_CM_pBrk6_RACI::Accountable","psdk_CM_pBrk6_RACI::Consulted","psdk_CM_pBrk6_RACI::Informed","psdk_CM_byJCp_IPR::License","psdk_CM_byJCp_IPR::Version","psdk_CM_byJCp_IPR::Mandatory","psdk_CM_byJCp_IPR::Date","psdk_CM_byJCp_IPR::URL","psdk_CM_pBrk6_DQ::Count","psdk_CM_pBrk6_DQ::SQL","psdk_CM_pBrk6_DQ::Type","jsdk_IPR_7jt2E::License","jsdk_IPR_7jt2E::Version","jsdk_IPR_7jt2E::Mandatory","jsdk_IPR_7jt2E::Date","jsdk_IPR_7jt2E::URL","psdk_CM_ZRHfV_RACI::Responsible","psdk_CM_ZRHfV_RACI::Accountable","psdk_CM_ZRHfV_RACI::Consulted","psdk_CM_ZRHfV_RACI::Informed","psdk_CM_ZRHfV_RACI::Extra","psdk_CM_ZRHfV_RACI::Test33","psdk_CM_ZRHfV_RACI::test-final","psdk_CM_byJCp_DQ::Count","psdk_CM_byJCp_DQ::SQL","psdk_CM_byJCp_DQ::Type","psdk_CM_Uveq5_IPR::License","psdk_CM_Uveq5_IPR::Version","psdk_CM_Uveq5_IPR::Mandatory","psdk_CM_Uveq5_IPR::Date","psdk_CM_Uveq5_IPR::URL","psdk_CM_ZRHfV_DQ::Count","psdk_CM_ZRHfV_DQ::SQL","psdk_CM_ZRHfV_DQ::Type" +"{{CONNECTIONNAME}}/db1","Database","db1",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +"{{CONNECTIONNAME}}/db1/sch1","Schema","sch1",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +"{{CONNECTIONNAME}}","Connection","{{CONNECTIONID}}",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +"{{CONNECTIONNAME}}/db1/sch1/tbl1","Table","tbl1",,,"Export Domain Relationship Test Table Java SDK",,,,,,,,,,,,,"{{DOMAINNAME}}",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,