<commit_before>package uk.ac.wellcome.display.models.v2

import org.scalatest.{FunSpec, Matchers}
import uk.ac.wellcome.models.work.internal._
import uk.ac.wellcome.models.work.test.util.IdentifiersUtil

class DisplayAbstractAgentV2Test extends FunSpec with Matchers with IdentifiersUtil {

  val label: String = randomAlphanumeric(length = 25)
  val sourceIdentifier: SourceIdentifier = createSourceIdentifier
  val otherIdentifiers: List[SourceIdentifier] = (1 to 3).map { _ => createSourceIdentifier }.toList
  val canonicalId: String = createCanonicalId

  describe("Agent") {
    val agent = Agent(label = label)

    val unidentifiedAgent = Unidentifiable(agent)

    val identifiedAgent = Identified(
      canonicalId = canonicalId,
      sourceIdentifier = sourceIdentifier,
      otherIdentifiers = otherIdentifiers,
      agent = agent
    )

    val expectedUnidentifiedAgent: DisplayAgentV2 = DisplayAgentV2(
      id = None,
      identifiers = None,
      label = label
    )

    it("converts an Unidentifiable Agent to a DisplayAgentV2 (includesIdentifiers = true)") {
      DisplayAbstractAgentV2(
        unidentifiedAgent,
        includesIdentifiers = true) shouldBe expectedUnidentifiedAgent
    }

    it("converts an Unidentifiable Agent to a DisplayAgentV2 (includesIdentifiers = false)") {
      DisplayAbstractAgentV2(
        unidentifiedAgent,
        includesIdentifiers = false) shouldBe expectedUnidentifiedAgent
    }

    it("converts an Identified Agent to a DisplayAgentV2 (includesIdentifiers = true)") {
      val expectedAgent = DisplayAgentV2(
        id = Some(canonicalId),
        identifiers = Some((List(sourceIdentifier) ++ otherIdentifiers).map { DisplayIdentifierV2(_) }),
        label = label
      )

      DisplayAbstractAgentV2(
        identifiedAgent,
        includesIdentifiers = true) shouldBe expectedAgent
    }

    it("converts an Identified Agent to a DisplayAgentV2 (includesIdentifiers = false)") {
      val expectedAgent = DisplayAgentV2(
        id = Some(canonicalId),
        identifiers = None,
        label = label
      )

      DisplayAbstractAgentV2(
        identifiedAgent,
        includesIdentifiers = false) shouldBe expectedAgent
    }
  }

  describe("Person") {
    val prefix = randomAlphanumeric(length = 5)
    val numeration = randomAlphanumeric(length = 3)

    val person = Person(
      label = label,
      prefix = Some(prefix),
      numeration = Some(numeration)
    )

    val unidentifiedPerson = Unidentifiable(person)

    val identifiedAgent = Identified(
      canonicalId = canonicalId,
      sourceIdentifier = sourceIdentifier,
      otherIdentifiers = otherIdentifiers,
      agent = person
    )

    val expectedUnidentifiedPerson: DisplayPersonV2 = DisplayPersonV2(
      id = None,
      identifiers = None,
      label = label,
      prefix = Some(prefix),
      numeration = Some(numeration)
    )

    it("converts an Unidentifiable Person to a DisplayPersonV2 (includesIdentifiers = true)") {
      DisplayAbstractAgentV2(
        unidentifiedPerson,
        includesIdentifiers = true) shouldBe expectedUnidentifiedPerson
    }

    it("converts an Unidentifiable Agent to a DisplayPersonV2 (includesIdentifiers = false)") {
      DisplayAbstractAgentV2(
        unidentifiedPerson,
        includesIdentifiers = false) shouldBe expectedUnidentifiedPerson
    }

    it("converts an Identified Agent to a DisplayPersonV2 (includesIdentifiers = true)") {
      val expectedPerson = DisplayPersonV2(
        id = Some(canonicalId),
        identifiers = Some((List(sourceIdentifier) ++ otherIdentifiers).map { DisplayIdentifierV2(_) }),
        label = label,
        prefix = Some(prefix),
        numeration = Some(numeration)
      )

      DisplayAbstractAgentV2(
        identifiedAgent,
        includesIdentifiers = true) shouldBe expectedPerson
    }

    it("converts an Identified Agent to a DisplayPersonV2 (includesIdentifiers = false)") {
      val expectedPerson = DisplayPersonV2(
        id = Some(canonicalId),
        identifiers = None,
        label = label,
        prefix = Some(prefix),
        numeration = Some(numeration)
      )

      DisplayAbstractAgentV2(
        identifiedAgent,
        includesIdentifiers = false) shouldBe expectedPerson
    }
  }

  describe("Organisation") {
    val organisation = Organisation(label = label)

    val unidentifiedAgent = Unidentifiable(organisation)

    val identifiedAgent = Identified(
      canonicalId = canonicalId,
      sourceIdentifier = sourceIdentifier,
      otherIdentifiers = otherIdentifiers,
      agent = organisation<commit_msg>Fix test labels<commit_after>package uk.ac.wellcome.display.models.v2

import org.scalatest.{FunSpec, Matchers}
import uk.ac.wellcome.models.work.internal._
import uk.ac.wellcome.models.work.test.util.IdentifiersUtil

class DisplayAbstractAgentV2Test extends FunSpec with Matchers with IdentifiersUtil {

  val label: String = randomAlphanumeric(length = 25)
  val sourceIdentifier: SourceIdentifier = createSourceIdentifier
  val otherIdentifiers: List[SourceIdentifier] = (1 to 3).map { _ => createSourceIdentifier }.toList
  val canonicalId: String = createCanonicalId

  describe("Agent") {
    val agent = Agent(label = label)

    val unidentifiedAgent = Unidentifiable(agent)

    val identifiedAgent = Identified(
      canonicalId = canonicalId,
      sourceIdentifier = sourceIdentifier,
      otherIdentifiers = otherIdentifiers,
      agent = agent
    )

    val expectedUnidentifiedAgent: DisplayAgentV2 = DisplayAgentV2(
      id = None,
      identifiers = None,
      label = label
    )

    it("converts an Unidentifiable Agent to a DisplayAgentV2 (includesIdentifiers = true)") {
      DisplayAbstractAgentV2(
        unidentifiedAgent,
        includesIdentifiers = true) shouldBe expectedUnidentifiedAgent
    }

    it("converts an Unidentifiable Agent to a DisplayAgentV2 (includesIdentifiers = false)") {
      DisplayAbstractAgentV2(
        unidentifiedAgent,
        includesIdentifiers = false) shouldBe expectedUnidentifiedAgent
    }

    it("converts an Identified Agent to a DisplayAgentV2 (includesIdentifiers = true)") {
      val expectedAgent = DisplayAgentV2(
        id = Some(canonicalId),
        identifiers = Some((List(sourceIdentifier) ++ otherIdentifiers).map { DisplayIdentifierV2(_) }),
        label = label
      )

      DisplayAbstractAgentV2(
        identifiedAgent,
        includesIdentifiers = true) shouldBe expectedAgent
    }

    it("converts an Identified Agent to a DisplayAgentV2 (includesIdentifiers = false)") {
      val expectedAgent = DisplayAgentV2(
        id = Some(canonicalId),
        identifiers = None,
        label = label
      )

      DisplayAbstractAgentV2(
        identifiedAgent,
        includesIdentifiers = false) shouldBe expectedAgent
    }
  }

  describe("Person") {
    val prefix = randomAlphanumeric(length = 5)
    val numeration = randomAlphanumeric(length = 3)

    val person = Person(
      label = label,
      prefix = Some(prefix),
      numeration = Some(numeration)
    )

    val unidentifiedPerson = Unidentifiable(person)

    val identifiedAgent = Identified(
      canonicalId = canonicalId,
      sourceIdentifier = sourceIdentifier,
      otherIdentifiers = otherIdentifiers,
      agent = person
    )

    val expectedUnidentifiedPerson: DisplayPersonV2 = DisplayPersonV2(
      id = None,
      identifiers = None,
      label = label,
      prefix = Some(prefix),
      numeration = Some(numeration)
    )

    it("converts an Unidentifiable Person to a DisplayPersonV2 (includesIdentifiers = true)") {
      DisplayAbstractAgentV2(
        unidentifiedPerson,
        includesIdentifiers = true) shouldBe expectedUnidentifiedPerson
    }

    it("converts an Unidentifiable Person to a DisplayPersonV2 (includesIdentifiers = false)") {
      DisplayAbstractAgentV2(
        unidentifiedPerson,
        includesIdentifiers = false) shouldBe expectedUnidentifiedPerson
    }

    it("converts an Identified Person to a DisplayPersonV2 (includesIdentifiers = true)") {
      val expectedPerson = DisplayPersonV2(
        id = Some(canonicalId),
        identifiers = Some((List(sourceIdentifier) ++ otherIdentifiers).map { DisplayIdentifierV2(_) }),
        label = label,
        prefix = Some(prefix),
        numeration = Some(numeration)
      )

      DisplayAbstractAgentV2(
        identifiedAgent,
        includesIdentifiers = true) shouldBe expectedPerson
    }

    it("converts an Identified Person to a DisplayPersonV2 (includesIdentifiers = false)") {
      val expectedPerson = DisplayPersonV2(
        id = Some(canonicalId),
        identifiers = None,
        label = label,
        prefix = Some(prefix),
        numeration = Some(numeration)
      )

      DisplayAbstractAgentV2(
        identifiedAgent,
        includesIdentifiers = false) shouldBe expectedPerson
    }
  }

  describe("Organisation") {
    val organisation = Organisation(label = label)

    val unidentifiedAgent = Unidentifiable(organisation)

    val identifiedAgent = Identified(
      canonicalId = canonicalId,
      sourceIdentifier = sourceIdentifier,
      otherIdentifiers = otherIdentifiers,
      agent = organisation
{'fraction_non_alphanumeric': 0.07404209390178089, 'fraction_numerical': 0.007339449541284404, 'mean_word_length': 3.1495745633676666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2282655', 'n_tokens_mistral': 2487, 'n_tokens_neox': 2394, 'n_words': 601}