@Test
public void should_report_proper_error_when_repository_is_available_but_manifest_is_invalid() {

    KeyPair childKeyPair = KEY_PAIR_FACTORY.generate();
    final ValidityPeriod mftValidityPeriod = new ValidityPeriod(
        Instant.now().minus(Duration.standardDays(2)),
        Instant.now().minus(Duration.standardDays(1))
    );
    TrustAnchor ta = wtx(tx -> {
        TrustAnchor ta1 = factory.createTrustAnchor(tx, x -> {
            CertificateAuthority child = CertificateAuthority.builder()
                    .dn("CN=child-ca")
                    .keyPair(childKeyPair)
                    .certificateLocation("rsync://rpki.test/CN=child-ca.cer")
                    .resources(IpResourceSet.parse("192.168.128.0/17"))
                    .notifyURI(TA_RRDP_NOTIFY_URI)
                    .manifestURI("rsync://rpki.test/CN=child-ca/child-ca.mft")
                    .repositoryURI("rsync://rpki.test/CN=child-ca/")
                    .crlDistributionPoint("rsync://rpki.test/CN=child-ca/child-ca.crl")
                    .build();
            x.children(Collections.singletonList(child));
        }, mftValidityPeriod);
        this.getTrustAnchors().add(tx, ta1);
        return ta1;
    });
    RpkiRepository repository = wtx(tx -> {
        final Ref<TrustAnchor> trustAnchorRef = this.getTrustAnchors().makeRef(tx, ta.key());
        RpkiRepository r = this.getRpkiRepositories().register(tx, trustAnchorRef, TA_RRDP_NOTIFY_URI, RpkiRepository.Type.RRDP);
        r.setFailed();
        this.getRpkiRepositories().update(tx, r);
        return r;
    });
    subject.validate(ta.key().asLong());
    rtx0(tx -> {
        List<CertificateTreeValidationRun> completed = this.getValidationRuns().findAll(tx, CertificateTreeValidationRun.class);
        assertThat(completed).hasSize(1);
        final List<ValidationCheck> checks = completed.get(0).getValidationChecks();
        assertThat(checks.get(0).getKey()).isEqualTo(ValidationString.VALIDATOR_OLD_LOCAL_MANIFEST_REPOSITORY_FAILED);
        assertThat(checks.get(0).getParameters()).isEqualTo(Collections.singletonList(repository.getRrdpNotifyUri()));
    });
}