-
Notifications
You must be signed in to change notification settings - Fork 5
Adds integration test for updating subdomain alone #2172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
samples/packages/asset-import/src/test/kotlin/com/atlan/pkg/aim/UpdateSubdomainTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| /* SPDX-License-Identifier: Apache-2.0 | ||
| Copyright 2023 Atlan Pte. Ltd. */ | ||
| package com.atlan.pkg.aim | ||
|
|
||
| import AssetImportCfg | ||
| import com.atlan.model.assets.Asset | ||
| import com.atlan.model.assets.DataDomain | ||
| import com.atlan.model.fields.AtlanField | ||
| import com.atlan.pkg.PackageTest | ||
| import com.atlan.pkg.Utils | ||
| import java.nio.file.Paths | ||
| import kotlin.test.Test | ||
| import kotlin.test.assertEquals | ||
| import kotlin.test.assertFalse | ||
| import kotlin.test.assertTrue | ||
|
|
||
| class UpdateSubdomainTest : PackageTest("usd") { | ||
| override val logger = Utils.getLogger(this.javaClass.name) | ||
|
|
||
| private val dataDomain = makeUnique("d1") | ||
| private val subDomain = makeUnique("sd1") | ||
| private lateinit var dd: DataDomain | ||
| private lateinit var sd: DataDomain | ||
| private val testFile = "subdomain-alone.csv" | ||
|
|
||
| private val files = | ||
| listOf( | ||
| testFile, | ||
| "debug.log", | ||
| ) | ||
|
|
||
| private fun prepFile() { | ||
| // Prepare a copy of the file with unique names for domains and products | ||
| val input = Paths.get("src", "test", "resources", testFile).toFile() | ||
| val output = Paths.get(testDirectory, testFile).toFile() | ||
| input.useLines { lines -> | ||
| lines.forEach { line -> | ||
| val revised = | ||
| line | ||
| .replace("{{DATADOMAIN}}", dataDomain) | ||
| .replace("{{SUBDOMAIN}}", subDomain) | ||
| output.appendText("$revised\n") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private val dataDomainAttrs: List<AtlanField> = | ||
| listOf( | ||
| DataDomain.NAME, | ||
| DataDomain.ASSET_ICON, | ||
| DataDomain.ASSET_THEME_HEX, | ||
| DataDomain.ASSET_COVER_IMAGE, | ||
| DataDomain.USER_DESCRIPTION, | ||
| DataDomain.OWNER_USERS, | ||
| DataDomain.OWNER_GROUPS, | ||
| DataDomain.CERTIFICATE_STATUS, | ||
| DataDomain.CERTIFICATE_STATUS_MESSAGE, | ||
| DataDomain.PARENT_DOMAIN, | ||
| DataDomain.PARENT_DOMAIN_QUALIFIED_NAME, | ||
| DataDomain.SUPER_DOMAIN_QUALIFIED_NAME, | ||
| DataDomain.ANNOUNCEMENT_TYPE, | ||
| DataDomain.ANNOUNCEMENT_TITLE, | ||
| DataDomain.ANNOUNCEMENT_MESSAGE, | ||
| DataDomain.SUB_DOMAINS, | ||
| ) | ||
|
|
||
| private fun createAssets() { | ||
| val ddCreate = DataDomain.creator(dataDomain).build() | ||
| val ddResponse = ddCreate.save(client) | ||
| dd = ddResponse.getResult(ddCreate) | ||
| val sdCreate = | ||
| DataDomain.creator(subDomain, dd.qualifiedName).build() | ||
| val sdResponse = sdCreate.save(client) | ||
| sd = sdResponse.getResult(sdCreate) | ||
| } | ||
|
|
||
| override fun setup() { | ||
| prepFile() | ||
| createAssets() | ||
| } | ||
|
|
||
| override fun teardown() { | ||
| removeDomain(subDomain) | ||
| removeDomain(dataDomain) | ||
| } | ||
|
|
||
| @Test(groups = ["aim.usd.create"]) | ||
| fun exactlyTwoDomains() { | ||
| val d1 = findDataDomain(dataDomain) | ||
| assertEquals(dataDomain, d1.name) | ||
| assertFalse(d1.subDomains.isNullOrEmpty()) | ||
| assertEquals(1, d1.subDomains.size) | ||
| val d2 = findDataDomain(subDomain) | ||
| assertEquals(subDomain, d2.name) | ||
| assertTrue(d2.subDomains.isNullOrEmpty()) | ||
| } | ||
|
|
||
| @Test(groups = ["aim.usd.runUpsert"], dependsOnGroups = ["aim.usd.create"]) | ||
| fun upsert() { | ||
| runCustomPackage( | ||
| AssetImportCfg( | ||
| dataProductsFile = Paths.get(testDirectory, testFile).toString(), | ||
| dataProductsUpsertSemantic = "upsert", | ||
| dataProductsAttrToOverwrite = listOf(), | ||
| dataProductsFailOnErrors = true, | ||
| ), | ||
| Importer::main, | ||
| ) | ||
| } | ||
|
|
||
| @Test(groups = ["aim.usd.testUpsert"], dependsOnGroups = ["aim.usd.runUpsert"]) | ||
| fun domainsUnchanged() { | ||
| exactlyTwoDomains() | ||
| } | ||
|
|
||
| private fun findDataDomain(domainName: String): DataDomain { | ||
| val request = | ||
| DataDomain | ||
| .select(client) | ||
| .where(DataDomain.NAME.eq(domainName)) | ||
| .includesOnResults(dataDomainAttrs) | ||
| .toRequest() | ||
| val response = retrySearchUntil(request, 1) | ||
| val dataDomains = response.stream().filter { a: Asset? -> a is DataDomain }.toList() | ||
| assertEquals(1, dataDomains.size) | ||
| return dataDomains[0] as DataDomain | ||
| } | ||
|
|
||
| @Test(dependsOnGroups = ["aim.usd.*"]) | ||
| fun filesCreated() { | ||
| validateFilesExist(files) | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @Test(dependsOnGroups = ["aim.usd.*"]) | ||
| fun errorFreeLog() { | ||
| validateErrorFreeLog() | ||
| } | ||
| } | ||
2 changes: 2 additions & 0 deletions
2
samples/packages/asset-import/src/test/resources/subdomain-alone.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| typeName,name,assetIcon,assetThemeHex,assetCoverImage,parentDomain,dataDomain,dataProductAssetsDSL,displayName,description,userDescription,ownerUsers,ownerGroups | ||
| DataDomain,{{SUBDOMAIN}},,,,{{DATADOMAIN}},,,,,Test subdomain,chris,admins |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.