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

import hmda.model.fi.lar.LoanApplicationRegister
import hmda.validation.dsl.{ Failure, Success }
import hmda.validation.rules.EditCheck
import hmda.validation.rules.lar.LarEditCheckSpec
import org.scalacheck.Gen

class V335Spec extends LarEditCheckSpec {
  property("Succeeds when property type is not 3") {
    forAll(larGen) { lar =>
      whenever(lar.loan.propertyType != 3) {
        V335(lar) mustBe Success()
      }
    }
  }

  property("Succeeds when property type is 3 and income is 'NA'") {
    forAll(larGen) { (lar: LoanApplicationRegister) =>
      val loan = lar.loan.copy(propertyType = 3)
      val applicant = lar.applicant.copy(income = "NA")
      val validLar = lar.copy(applicant = applicant, loan = loan)
      V335(validLar) mustBe Success()
    }
  }

  val incomeNumberGen: Gen[Int] = Gen.choose(Integer.MIN_VALUE, Integer.MAX_VALUE)

  property("Fails when property type is 3 and income is not 'NA'") {
    forAll(larGen, incomeNumberGen) { (lar: LoanApplicationRegister, x: Int) =>
      val loan = lar.loan.copy(propertyType = 3)
      val invalidApplicant = lar.applicant.copy(income = x.toString)
      val invalidLar = lar.copy(applicant = invalidApplicant, loan = loan)
      V335(invalidLar) mustBe a[Failure]
    }
  }
  override def check: EditCheck[LoanApplicationRegister] = V335
}<commit_msg>Now using new testing methods<commit_after>package hmda.validation.rules.lar.validity

import hmda.model.fi.lar.LoanApplicationRegister
import hmda.validation.dsl.{ Failure, Success }
import hmda.validation.rules.EditCheck
import hmda.validation.rules.lar.LarEditCheckSpec
import org.scalacheck.Gen

class V335Spec extends LarEditCheckSpec {
  property("Succeeds when property type is not 3") {
    forAll(larGen) { lar =>
      whenever(lar.loan.propertyType != 3) {
        lar.mustPass
      }
    }
  }

  property("Succeeds when property type is 3 and income is 'NA'") {
    forAll(larGen) { (lar: LoanApplicationRegister) =>
      val loan = lar.loan.copy(propertyType = 3)
      val applicant = lar.applicant.copy(income = "NA")
      val validLar = lar.copy(applicant = applicant, loan = loan)
      validLar.mustPass
    }
  }

  val incomeNumberGen: Gen[Int] = Gen.choose(Integer.MIN_VALUE, Integer.MAX_VALUE)

  property("Fails when property type is 3 and income is not 'NA'") {
    forAll(larGen, incomeNumberGen) { (lar: LoanApplicationRegister, x: Int) =>
      val loan = lar.loan.copy(propertyType = 3)
      val invalidApplicant = lar.applicant.copy(income = x.toString)
      val invalidLar = lar.copy(applicant = invalidApplicant, loan = loan)
      invalidLar.mustFail
    }
  }
  override def check: EditCheck[LoanApplicationRegister] = V335
}
{'fraction_non_alphanumeric': 0.10707803992740472, 'fraction_numerical': 0.011978221415607986, 'mean_word_length': 3.719178082191781, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6002357', 'n_tokens_mistral': 961, 'n_tokens_neox': 874, 'n_words': 210}