@Test
public void shouldCleanUpOrphanedAssociationWithRepo() {

    RsyncRepositoryValidationRun orphanValidationRun = wtx(tx -> new RsyncRepositoryValidationRun());
    wtx0(tx -> getValidationRuns().add(tx, orphanValidationRun));
    // Prepare the repo that will be associated and then deleted.
    RpkiRepository associatedAndThenDeletedRepo = new RpkiRepository(testTARef1, testTA1.getLocations().get(0), RpkiRepository.Type.RSYNC);
    wtx0(tx -> associatedAndThenDeletedRepo.setId(Key.of(getSequences().next(tx, ":pk"))));
    wtx0(tx -> getRpkiRepositories().register(tx, testTARef1, associatedAndThenDeletedRepo.getLocationUri(), associatedAndThenDeletedRepo.getType()));
    // Associate and remove the object, validation will be orphan.
    wtx0(tx -> getValidationRuns().associate(tx, orphanValidationRun, associatedAndThenDeletedRepo));
    wtx0(tx -> getRpkiRepositories().remove(tx, associatedAndThenDeletedRepo.key()));
    AtomicInteger orphanCount = subject.cleanupValidationRuns().getRight();
    assertThat(orphanCount.get()).isEqualTo(1);
}