Skip to content

Commit

Permalink
Checking if the exported file is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanmanishd committed Jan 9, 2025
1 parent 0262b5b commit 57e9ac0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -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" }
}
}
}
Original file line number Diff line number Diff line change
@@ -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}}",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

0 comments on commit 57e9ac0

Please sign in to comment.