/** Validates that validateSecurityCode returns false when an invalid security is set. */
  public void testValidateSecurity_False() {
    EndowmentTargetTransactionSecurity targetTransactionSecurity =
        new EndowmentTargetTransactionSecurity();
    targetTransactionSecurity.setSecurityID(EndowTestConstants.INVALID_SECURITY_ID);

    document.setTargetTransactionSecurity(targetTransactionSecurity);

    assertFalse(rule.validateSecurityCode(document, false));
  }
  /**
   * Validates that validateRegistrationCode returns false when a valid registration code is set.
   */
  public void testValidateRegistration_False() {

    EndowmentTargetTransactionSecurity targetTransactionSecurity =
        new EndowmentTargetTransactionSecurity();
    targetTransactionSecurity.setRegistrationCode(EndowTestConstants.INVALID_REGISTRATION_CODE);

    document.setTargetTransactionSecurity(targetTransactionSecurity);

    assertFalse(rule.validateRegistrationCode(document, true));
  }
  /** Validates that validateRegistrationCode returns true when a valid registration code is set. */
  public void testValidateRegistration_True() {

    // add security details
    RegistrationCode registrationCode =
        RegistrationCodeFixture.REGISTRATION_CODE_RECORD.createRegistrationCode();

    EndowmentTargetTransactionSecurity targetTransactionSecurity =
        new EndowmentTargetTransactionSecurity();
    targetTransactionSecurity.setRegistrationCode(registrationCode.getCode());
    targetTransactionSecurity.setRegistrationCodeObj(registrationCode);

    document.setTargetTransactionSecurity(targetTransactionSecurity);

    assertTrue(rule.validateRegistrationCode(document, false));
  }
  /** Validates that isSecurityActive returns false when an inactive security is added. */
  public void testActiveSecurity_False() {
    // add security details
    SecurityReportingGroup reportingGroup =
        SecurityReportingGroupFixture.REPORTING_GROUP.createSecurityReportingGroup();
    EndowmentTransactionCode endowmentTransactionCode =
        EndowmentTransactionCodeFixture.INCOME_TRANSACTION_CODE.createEndowmentTransactionCode();
    ClassCode classCode = ClassCodeFixture.LIABILITY_CLASS_CODE.createClassCodeRecord();
    Security security = SecurityFixture.INACTIVE_SECURITY.createSecurityRecord();
    EndowmentTargetTransactionSecurity targetTransactionSecurity =
        new EndowmentTargetTransactionSecurity();
    targetTransactionSecurity.setSecurityID(security.getId());
    targetTransactionSecurity.setSecurity(security);

    document.setTargetTransactionSecurity(targetTransactionSecurity);

    assertFalse(rule.isSecurityActive(document, false));
  }
  /**
   * Validates that validateSecurityClassCodeTypeNotLiability returns true when a security with a
   * class code other that Liability is added.
   */
  public void testLiabilityClassCode_True() {
    // add security details
    SecurityReportingGroup reportingGroup =
        SecurityReportingGroupFixture.REPORTING_GROUP.createSecurityReportingGroup();
    EndowmentTransactionCode endowmentTransactionCode =
        EndowmentTransactionCodeFixture.INCOME_TRANSACTION_CODE.createEndowmentTransactionCode();
    ClassCode classCode = ClassCodeFixture.NOT_LIABILITY_CLASS_CODE.createClassCodeRecord();
    Security security = SecurityFixture.ACTIVE_SECURITY.createSecurityRecord();

    security.setClassCode(classCode);
    security.setSecurityClassCode(classCode.getCode());

    EndowmentTargetTransactionSecurity targetTransactionSecurity =
        new EndowmentTargetTransactionSecurity();
    targetTransactionSecurity.setSecurityID(security.getId());
    targetTransactionSecurity.setSecurity(security);

    document.getTargetTransactionSecurities().add(targetTransactionSecurity);

    assertTrue(rule.validateSecurityClassCodeTypeNotLiability(document, false));
  }