-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
article-api + draft-api: Make use of
OptLanguageFields
for disclaimer
This patch adds a migration of disclaimer to `OptLanguageFields` as well as retypes the `diclaimer` of the domain type to `OptLanguageFields`.
- Loading branch information
Showing
30 changed files
with
303 additions
and
107 deletions.
There are no files selected for viewing
This file contains 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
17 changes: 17 additions & 0 deletions
17
...-api/src/main/scala/no/ndla/articleapi/db/migration/V56__DisclaimerToLanguageFields.scala
This file contains 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,17 @@ | ||
/* | ||
* Part of NDLA article-api | ||
* Copyright (C) 2025 NDLA | ||
* | ||
* See LICENSE | ||
* | ||
*/ | ||
|
||
package no.ndla.articleapi.db.migration | ||
|
||
import no.ndla.database.LanguageFieldMigration | ||
|
||
class V56__DisclaimerToLanguageFields extends LanguageFieldMigration { | ||
override val columnName: String = "document" | ||
override val tableName: String = "contentdata" | ||
override val fieldName: String = "disclaimer" | ||
} |
This file contains 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
This file contains 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
This file contains 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
38 changes: 38 additions & 0 deletions
38
.../src/test/scala/no/ndla/articleapi/db/migration/V55__DisclaimerToLanguageFieldsTest.scala
This file contains 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,38 @@ | ||
/* | ||
* Part of NDLA article-api | ||
* Copyright (C) 2024 NDLA | ||
* | ||
* See LICENSE | ||
*/ | ||
|
||
package no.ndla.articleapi.db.migration | ||
|
||
import no.ndla.articleapi.{TestEnvironment, UnitSuite} | ||
import no.ndla.common.model.domain.{ArticleContent, Title} | ||
|
||
class V55__DisclaimerToLanguageFieldsTest extends UnitSuite with TestEnvironment { | ||
test("That old disclaimers are migrated to new language fields") { | ||
val oldDocument = | ||
"""{"disclaimer":[{"disclaimer":"Dette er bokmål","language":"nb"},{"disclaimer":"Dette er nynorsk","language":"nn"}]}""" | ||
val expectedResult = """{"disclaimer":{"nb":"Dette er bokmål","nn":"Dette er nynorsk"}}""" | ||
val migration = new V56__DisclaimerToLanguageFields | ||
val result = migration.convertColumn(oldDocument) | ||
result should be(expectedResult) | ||
} | ||
|
||
test("That no old disclaimers are migrated to new language fields") { | ||
val oldDocument = """{}""" | ||
val expectedResult = """{"disclaimer":{}}""" | ||
val migration = new V56__DisclaimerToLanguageFields | ||
val result = migration.convertColumn(oldDocument) | ||
result should be(expectedResult) | ||
} | ||
|
||
test("That null disclaimers are migrated to new language fields") { | ||
val oldDocument = """{"disclaimer":null}""" | ||
val expectedResult = """{"disclaimer":{}}""" | ||
val migration = new V56__DisclaimerToLanguageFields | ||
val result = migration.convertColumn(oldDocument) | ||
result should be(expectedResult) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.