@Test
public void should_delete_repositories_not_referenced_during_validation() throws Exception {

    TrustAnchor trustAnchor = TestObjects.newTrustAnchor();
    wtx0(tx -> this.getTrustAnchors().add(tx, trustAnchor));
    final Ref<TrustAnchor> trustAnchorRef = rtx(tx -> this.getTrustAnchors().makeRef(tx, trustAnchor.key()));
    RpkiRepository repository = wtx(tx -> this.getRpkiRepositories().register(tx,
            trustAnchorRef, "rsync://some.rsync.repo", RpkiRepository.Type.RSYNC));
    assertThat(rtx(tx -> rpkiRepositories.findRsyncRepositories(tx).collect(Collectors.toList())), hasSize(1));
    assertThat(subject.cleanupRpkiRepositories(), is(0L));
    repository.getTrustAnchors().put(trustAnchorRef, InstantWithoutNanos.from(ZonedDateTime.now().minusDays(20).toInstant()));
    wtx0(tx -> rpkiRepositories.update(tx, repository));
    assertThat(subject.cleanupRpkiRepositories(), is(1L));
    assertThat(rtx(tx -> rpkiRepositories.findRsyncRepositories(tx).collect(Collectors.toList())), is(empty()));
}