Skip to content

Commit

Permalink
Use correct license codes everywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarvelle committed Feb 19, 2025
1 parent 28d3b78 commit fe77995
Show file tree
Hide file tree
Showing 34 changed files with 200 additions and 1,169 deletions.
15 changes: 12 additions & 3 deletions article-api/src/test/scala/no/ndla/articleapi/TestData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ trait TestData {
None,
Seq(Title("test", "en")),
Seq(ArticleContent("<article><div>test</div></article>", "en")),
Copyright("publicdomain", None, Seq(), Seq(), Seq(), None, None, false),
Copyright(License.PublicDomain.toString, None, Seq(), Seq(), Seq(), None, None, false),
Seq(),
Seq(),
Seq(),
Expand Down Expand Up @@ -228,7 +228,7 @@ trait TestData {
"en"
)
),
Copyright("publicdomain", None, Seq(), Seq(), Seq(), None, None, false),
Copyright(License.PublicDomain.toString, None, Seq(), Seq(), Seq(), None, None, false),
Seq(),
Seq(),
Seq(),
Expand Down Expand Up @@ -263,7 +263,16 @@ trait TestData {
"en"
),
model.api
.CopyrightDTO(model.api.LicenseDTO("publicdomain", None, None), None, Seq(), Seq(), Seq(), None, None, false),
.CopyrightDTO(
model.api.LicenseDTO(License.PublicDomain.toString, None, None),
None,
Seq(),
Seq(),
Seq(),
None,
None,
false
),
article.ArticleTagDTO(Seq.empty, "en"),
Seq.empty,
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import no.ndla.articleapi.*
import no.ndla.common.CirceUtil
import no.ndla.common.model.NDLADate
import no.ndla.common.model.domain.{ArticleMetaImage, Availability}
import no.ndla.mapping.License
import no.ndla.search.model.{LanguageValue, SearchableLanguageList, SearchableLanguageValues}

class SearchableArticleSerializerTest extends UnitSuite with TestEnvironment {
Expand All @@ -31,7 +32,7 @@ class SearchableArticleSerializerTest extends UnitSuite with TestEnvironment {
Vector(LanguageValue("nb", List("m", "e", "r", "k")), LanguageValue("en", List("t", "a", "g", "s")))
),
lastUpdated = NDLADate.of(2018, 2, 22, 14, 0, 51),
license = "by-sa",
license = License.CC_BY_SA.toString,
authors = Seq("Jonas Natty"),
articleType = "standard",
defaultTitle = Some("tjuppidu"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import no.ndla.common.model.domain.article.{
Copyright,
PartialPublishArticleDTO
}
import no.ndla.mapping.License
import org.mockito.Mockito.when

import scala.util.Success
Expand Down Expand Up @@ -149,7 +150,7 @@ class ConverterServiceTest extends UnitSuite with TestEnvironment {
val introduction = "Baldur"
val metaDescription = "Hurr Durr"
val metaImageAlt = "Alt text is here"
val license = "publicdomain"
val license = License.PublicDomain.toString
val articleType = "topic-article"
val supportedLanguages = Seq("nb", "en")
val availability = "everyone"
Expand Down
14 changes: 12 additions & 2 deletions audio-api/src/test/scala/no/ndla/audioapi/TestData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import no.ndla.audioapi.model.domain.{AudioMetaInformation, AudioType, SearchSet
import no.ndla.audioapi.model.domain
import no.ndla.audioapi.model.api
import no.ndla.common.model.domain.article.Copyright
import no.ndla.common.model.{NDLADate, domain => common, api => commonApi}
import no.ndla.common.model.{NDLADate, api as commonApi, domain as common}
import no.ndla.mapping.License
import no.ndla.network.tapir.auth.Permission.AUDIO_API_WRITE
import no.ndla.network.tapir.auth.TokenUser

Expand Down Expand Up @@ -118,7 +119,16 @@ object TestData {
1,
api.TitleDTO("title", "nb"),
api.AudioDTO("audio/test.mp3", "audio/mpeg", 1024, "nb"),
commonApi.CopyrightDTO(commonApi.LicenseDTO("by-sa", None, None), None, Seq(), Seq(), Seq(), None, None, false),
commonApi.CopyrightDTO(
commonApi.LicenseDTO(License.CC_BY_SA.toString, None, None),
None,
Seq(),
Seq(),
Seq(),
None,
None,
false
),
api.TagDTO(Seq("tag"), "nb"),
Seq("nb"),
"standard",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import no.ndla.audioapi.model.domain.{AudioMetaInformation, AudioType}
import no.ndla.audioapi.{TestEnvironment, UnitSuite}
import no.ndla.common.model.domain.article.Copyright
import no.ndla.common.model.domain as common
import no.ndla.mapping.License
import no.ndla.tapirtesting.TapirControllerTest
import org.mockito.ArgumentMatchers.any
import org.mockito.Mockito.{doReturn, never, reset, verify, verifyNoMoreInteractions, when}
Expand All @@ -30,7 +31,7 @@ class InternControllerTest extends UnitSuite with TestEnvironment with TapirCont
Some(1),
Seq(common.Title("title", "nb")),
Seq(domain.Audio("audio/test.mp3", "audio/mpeg", 1024, "nb")),
Copyright("by-sa", None, Seq(), Seq(), Seq(), None, None, false),
Copyright(License.CC_BY_SA.toString, None, Seq(), Seq(), Seq(), None, None, false),
Seq(common.Tag(Seq("tag"), "nb")),
"ndla124",
updated,
Expand All @@ -47,7 +48,7 @@ class InternControllerTest extends UnitSuite with TestEnvironment with TapirCont
Some(1),
Seq(common.Title("title", "unknown")),
Seq(domain.Audio("audio/test.mp3", "audio/mpeg", 1024, "unknown")),
Copyright("by-sa", None, Seq(), Seq(), Seq(), None, None, false),
Copyright(License.CC_BY_SA.toString, None, Seq(), Seq(), Seq(), None, None, false),
Seq(common.Tag(Seq("tag"), "unknown")),
"ndla124",
updated,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import no.ndla.common.model
import no.ndla.common.model.api.{CopyrightDTO, LicenseDTO}
import no.ndla.common.model.domain.UploadedFile
import no.ndla.common.model.{NDLADate, domain as common}
import no.ndla.mapping.License
import org.mockito.ArgumentMatchers.{any, eq as eqTo}
import org.mockito.Mockito.{reset, times, verify, when, withSettings}
import org.mockito.invocation.InvocationOnMock
Expand Down Expand Up @@ -68,7 +69,7 @@ class WriteServiceTest extends UnitSuite with TestEnvironment {
val updated1: model.NDLADate = NDLADate.of(2017, 4, 1, 12, 15, 32)

val publicDomain: common.article.Copyright = common.article.Copyright(
"publicdomain",
License.PublicDomain.toString,
Some("Metropolis"),
List(common.Author("Forfatter", "Bruce Wayne")),
Seq(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,19 @@ class AudioSearchServiceTest
override val searchConverterService = new SearchConverterService

val byNcSa: Copyright =
Copyright("by-nc-sa", Some("Gotham City"), List(Author("Forfatter", "DC Comics")), Seq(), Seq(), None, None, false)
Copyright(
License.CC_BY_NC_SA.toString,
Some("Gotham City"),
List(Author("Forfatter", "DC Comics")),
Seq(),
Seq(),
None,
None,
false
)

val publicDomain: Copyright = Copyright(
"publicdomain",
License.PublicDomain.toString,
Some("Metropolis"),
List(Author("Forfatter", "Bruce Wayne")),
Seq(),
Expand Down Expand Up @@ -281,7 +290,8 @@ class AudioSearchServiceTest
}

test("That filtering on license only returns documents with given license for all languages") {
val Success(results) = audioSearchService.matchingQuery(searchSettings.copy(license = Some("publicdomain")))
val Success(results) =
audioSearchService.matchingQuery(searchSettings.copy(license = Some(License.PublicDomain.toString)))
results.totalCount should be(2)
results.results.head.id should be(4)
results.results.last.id should be(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,31 @@

package no.ndla.audioapi.service.search

import no.ndla.audioapi.model.domain._
import no.ndla.audioapi.model.domain.*
import no.ndla.audioapi.model.search.SearchableAudioInformation
import no.ndla.audioapi.model.{api, domain}
import no.ndla.audioapi.{TestEnvironment, UnitSuite}
import no.ndla.common.model.NDLADate
import no.ndla.common.model.domain.article.Copyright
import no.ndla.common.model.domain.{Author, Tag, Title}
import no.ndla.mapping.License
import no.ndla.search.model.{SearchableLanguageList, SearchableLanguageValues}

class SearchConverterServiceTest extends UnitSuite with TestEnvironment {

override val searchConverterService = new SearchConverterService

val byNcSa: Copyright =
Copyright("by-nc-sa", Some("Gotham City"), List(Author("Forfatter", "DC Comics")), Seq(), Seq(), None, None, false)
Copyright(
License.CC_BY_NC_SA.toString,
Some("Gotham City"),
List(Author("Forfatter", "DC Comics")),
Seq(),
Seq(),
None,
None,
false
)
def updated(): NDLADate = NDLADate.of(2017, 4, 1, 12, 15, 32)
def created(): NDLADate = NDLADate.of(2017, 3, 1, 12, 15, 32)

Expand Down
12 changes: 11 additions & 1 deletion concept-api/src/test/scala/no/ndla/conceptapi/TestData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import no.ndla.common.model.domain.concept.{
Status,
VisualElement
}
import no.ndla.mapping.License

object TestData {

Expand Down Expand Up @@ -101,7 +102,16 @@ object TestData {
title = Seq(common.Title("Tittel for begrep", "nb")),
content = Seq(ConceptContent("Innhold for begrep", "nb")),
copyright = Some(
common.draft.DraftCopyright(Some("publicdomain"), Some(""), Seq.empty, Seq.empty, Seq.empty, None, None, false)
common.draft.DraftCopyright(
Some(License.PublicDomain.toString),
Some(""),
Seq.empty,
Seq.empty,
Seq.empty,
None,
None,
false
)
),
created = NDLADate.now().minusDays(4),
updated = NDLADate.now().minusDays(2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class DraftConceptSearchServiceTest extends IntegrationSuite(EnableElasticsearch
override val searchConverterService = new SearchConverterService

val byNcSa: DraftCopyright = DraftCopyright(
Some("by-nc-sa"),
Some(License.CC_BY_NC_SA.toString),
Some("Gotham City"),
List(Author("Forfatter", "DC Comics")),
List(),
Expand All @@ -63,7 +63,7 @@ class DraftConceptSearchServiceTest extends IntegrationSuite(EnableElasticsearch
)

val publicDomain: DraftCopyright = DraftCopyright(
Some("publicdomain"),
Some(License.PublicDomain.toString),
Some("Metropolis"),
List(Author("Forfatter", "Bruce Wayne")),
List(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PublishedConceptSearchServiceTest
override val searchConverterService = new SearchConverterService

val byNcSa: DraftCopyright = DraftCopyright(
Some("by-nc-sa"),
Some(License.CC_BY_NC_SA.toString),
Some("Gotham City"),
List(Author("Forfatter", "DC Comics")),
List(),
Expand All @@ -59,7 +59,7 @@ class PublishedConceptSearchServiceTest
)

val publicDomain: DraftCopyright = DraftCopyright(
Some("publicdomain"),
Some(License.PublicDomain.toString),
Some("Metropolis"),
List(Author("Forfatter", "Bruce Wayne")),
List(),
Expand Down Expand Up @@ -723,9 +723,9 @@ class PublishedConceptSearchServiceTest
sumOtherDocCount = 0,
docCountErrorUpperBound = 0,
buckets = Seq(
Bucket("by-nc-sa", 7),
Bucket("copyrighted", 2),
Bucket("publicdomain", 2)
Bucket(License.CC_BY_NC_SA.toString, 7),
Bucket(License.Copyrighted.toString, 2),
Bucket(License.PublicDomain.toString, 2)
)
)

Expand Down
26 changes: 22 additions & 4 deletions draft-api/src/test/scala/no/ndla/draftapi/TestData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ object TestData {
TokenUser("unit test", Set(DRAFT_API_WRITE, DRAFT_API_PUBLISH, DRAFT_API_ADMIN), None)

val publicDomainCopyright: common.draft.DraftCopyright =
common.draft.DraftCopyright(Some("publicdomain"), Some(""), List.empty, List(), List(), None, None, false)
common.draft.DraftCopyright(
Some(License.PublicDomain.toString),
Some(""),
List.empty,
List(),
List(),
None,
None,
false
)
private val byNcSaCopyright = common.draft.DraftCopyright(
Some(CC_BY_NC_SA.toString),
Some("Gotham City"),
Expand Down Expand Up @@ -412,7 +421,7 @@ object TestData {
None,
Some(
model.api.DraftCopyrightDTO(
Some(commonApi.LicenseDTO("publicdomain", None, None)),
Some(commonApi.LicenseDTO(License.PublicDomain.toString, None, None)),
Some(""),
Seq.empty,
Seq.empty,
Expand Down Expand Up @@ -461,7 +470,16 @@ object TestData {
)
),
copyright = Some(
common.draft.DraftCopyright(Some("publicdomain"), Some(""), Seq.empty, Seq.empty, Seq.empty, None, None, false)
common.draft.DraftCopyright(
Some(License.PublicDomain.toString),
Some(""),
Seq.empty,
Seq.empty,
Seq.empty,
None,
None,
false
)
),
tags = Seq.empty,
requiredLibraries = Seq.empty,
Expand Down Expand Up @@ -509,7 +527,7 @@ object TestData {
),
copyright = Some(
model.api.DraftCopyrightDTO(
Some(commonApi.LicenseDTO("publicdomain", None, None)),
Some(commonApi.LicenseDTO(License.PublicDomain.toString, None, None)),
Some(""),
Seq.empty,
Seq.empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import no.ndla.common.CirceUtil
import no.ndla.common.model.NDLADate
import no.ndla.common.model.domain.draft.DraftStatus
import no.ndla.draftapi.{TestEnvironment, UnitSuite}
import no.ndla.mapping.License
import no.ndla.search.model.{LanguageValue, SearchableLanguageList, SearchableLanguageValues}

class SearchableArticleSerializerTest extends UnitSuite with TestEnvironment {
Expand All @@ -26,7 +27,7 @@ class SearchableArticleSerializerTest extends UnitSuite with TestEnvironment {
List(LanguageValue("nb", List("m", "e", "r", "k")), LanguageValue("en", List("t", "a", "g", "s")))
),
lastUpdated = NDLADate.of(2018, 2, 22, 13, 0, 51),
license = Some("by-sa"),
license = Some(License.CC_BY_SA.toString),
authors = Seq("Jonas Natty"),
notes = Seq("jak"),
articleType = "standard",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ArticleSearchServiceTest extends IntegrationSuite(EnableElasticsearchConta
override val searchConverterService = new SearchConverterService

val byNcSa: DraftCopyright = DraftCopyright(
Some("by-nc-sa"),
Some(License.CC_BY_NC_SA.toString),
Some("Gotham City"),
List(Author("Forfatter", "DC Comics")),
List(),
Expand All @@ -44,7 +44,7 @@ class ArticleSearchServiceTest extends IntegrationSuite(EnableElasticsearchConta
)

val publicDomain: DraftCopyright = DraftCopyright(
Some("publicdomain"),
Some(License.PublicDomain.toString),
Some("Metropolis"),
List(Author("Forfatter", "Bruce Wayne")),
List(),
Expand Down Expand Up @@ -362,7 +362,7 @@ class ArticleSearchServiceTest extends IntegrationSuite(EnableElasticsearchConta
test("That all filtering on license only returns documents with given license") {
val Success(results) = articleSearchService.matchingQuery(
searchSettings.copy(
license = Some("publicdomain"),
license = Some(License.PublicDomain.toString),
sort = Sort.ByTitleAsc
)
)
Expand Down
Loading

0 comments on commit fe77995

Please sign in to comment.