@Test
public void encounteringSameUrlInVariousMd() throws Exception {

    Element mdAsXml = getMdAsXml();
    AbstractMetadata mdOne = insertMetadataInDb(mdAsXml);
    AbstractMetadata mdTwo = insertMetadataInDb(mdAsXml);
    UrlAnalyzer toTest = createToTest();
    toTest.processMetadata(mdAsXml, mdOne);
    toTest.processMetadata(mdAsXml, mdTwo);
    Set<String> urlFromDb = linkRepository.findAll().stream().map(Link::getUrl).collect(Collectors.toSet());
    assertEquals(6, urlFromDb.size());
    SimpleJpaRepository metadataLinkRepository = new SimpleJpaRepository<MetadataLink, Integer>(MetadataLink.class, entityManager);
    List<MetadataLink> metadataLinkList = metadataLinkRepository.findAll();
    assertEquals(
            metadataLinkList.stream().map(x -> x.getLink().getId()).collect(Collectors.toSet()),
            linkRepository.findAll().stream().map(Link::getId).collect(Collectors.toSet()));
    assertEquals(
            metadataLinkList.stream().map(x -> x.getMetadataId()).collect(Collectors.toSet()),
            Stream.of(mdOne.getId(), mdTwo.getId()).collect(Collectors.toSet()));
    assertEquals(12, metadataLinkList.size());
}