<commit_before>package hmda.validation.rules.lar.validity

import hmda.parser.fi.lar.LarGenerators
import hmda.validation.dsl.{ Failure, Success }
import org.scalacheck.Gen
import org.scalatest.prop.PropertyChecks
import org.scalatest.{ MustMatchers, PropSpec }

class V340Spec extends PropSpec with PropertyChecks with MustMatchers with LarGenerators {

  property("Succeeds when Type of Purchaser = 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9.") {
    forAll(larGen) { lar =>
      V340(lar) mustBe Success()
    }
  }

  property("Fails when purchaser type is not valid") {
    forAll(larGen, badPurchaserTypeGen) { (lar, pt) =>
      val invalidLAR = lar.copy(purchaserType = pt)
      V340(invalidLAR) mustBe Failure("is not contained in valid values domain")
    }
  }

  // I don't like having this logic split: this part here, the (complementary) happy path in LarGenerators. Ideas?
  val badPurchaserTypeGen: Gen[Int] = Gen.oneOf(Gen.negNum[Int], Gen.choose(10, Integer.MAX_VALUE))

}<commit_msg>remove comment, now in a separate issue<commit_after>package hmda.validation.rules.lar.validity

import hmda.parser.fi.lar.LarGenerators
import hmda.validation.dsl.{ Failure, Success }
import org.scalacheck.Gen
import org.scalatest.prop.PropertyChecks
import org.scalatest.{ MustMatchers, PropSpec }

class V340Spec extends PropSpec with PropertyChecks with MustMatchers with LarGenerators {

  property("Succeeds when Type of Purchaser = 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9.") {
    forAll(larGen) { lar =>
      V340(lar) mustBe Success()
    }
  }

  property("Fails when purchaser type is not valid") {
    forAll(larGen, badPurchaserTypeGen) { (lar, pt) =>
      val invalidLAR = lar.copy(purchaserType = pt)
      V340(invalidLAR) mustBe Failure("is not contained in valid values domain")
    }
  }

  val badPurchaserTypeGen: Gen[Int] = Gen.oneOf(Gen.negNum[Int], Gen.choose(10, Integer.MAX_VALUE))

}
{'fraction_non_alphanumeric': 0.10964681075382182, 'fraction_numerical': 0.02214022140221402, 'mean_word_length': 4.185792349726776, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4232723', 'n_tokens_mistral': 697, 'n_tokens_neox': 639, 'n_words': 177}