@Test
public void should_validate_minimal_trust_anchor() {

    TrustAnchor ta = wtx(tx -> {
        TrustAnchor trustAnchor = factory.createTrustAnchor(tx, x -> {
            x.notifyURI(TA_RRDP_NOTIFY_URI);
            x.repositoryURI(TA_CA_REPOSITORY_URI);
        });
        this.getTrustAnchors().add(tx, trustAnchor);
        final Ref<TrustAnchor> trustAnchorRef = this.getTrustAnchors().makeRef(tx, trustAnchor.key());
        RpkiRepository repository = this.getRpkiRepositories().register(tx, trustAnchorRef, TA_RRDP_NOTIFY_URI, RpkiRepository.Type.RRDP);
        repository.setDownloaded();
        this.getRpkiRepositories().update(tx, repository);
        this.getTrustAnchors().add(tx, trustAnchor);
        return trustAnchor;
    });
    subject.validate(ta.key().asLong());
    List<CertificateTreeValidationRun> completed = rtx(tx -> this.getValidationRuns().findAll(tx, CertificateTreeValidationRun.class));
    assertThat(completed).hasSize(1);
    CertificateTreeValidationRun result = completed.get(0);
    assertThat(result.getValidationChecks()).isEmpty();
    assertThat(result.getStatus()).isEqualTo(SUCCEEDED);
    Set<RpkiObject> validatedObjects = rtx(tx ->
            this.getValidationRuns().findAssociatedPks(tx, result)
                    .stream()
                    .map(pk -> this.getRpkiObjects().get(tx, pk))
                    .filter(Optional::isPresent)
                    .map(Optional::get)
                    .collect(Collectors.toSet()));
    rtx0(tx ->
            assertEquals(
                    Sets.newHashSet(
                            "rsync://rpki.test/repository/test-trust-anchor.mft",
                            "rsync://rpki.test/repository/test-trust-anchor.crl"
                    ),
                    validatedObjects.stream()
                            .flatMap(ro -> this.getRpkiObjects().getLocations(tx, ro.key()).stream())
                            .collect(Collectors.toSet())));
    rtx0(tx -> {
        TrustAnchor trustAnchor = this.getTrustAnchors().get(tx, ta.key()).get();
        assertThat(trustAnchor.isInitialCertificateTreeValidationRunCompleted()).as("trust anchor initial validation run completed").isTrue();
        assertThat(this.getSettings().isInitialValidationRunCompleted(tx)).as("validator initial validation run completed").isFalse();
    });
}