@Test
public void synchronizeReferencesDoesNontRemoveExistantFileAndDoesNotRemoveUrls() throws Exception {

    ArtifactTemplateId artifactTemplateId = new ArtifactTemplateId("http://example.org", "test-artifact-template", false);

    // alternative test implementation: Use git-based repository
    // this test at hand is closer to the implementation, but easier to write

    IRepository repository = mock(IRepository.class);
    ArtifactTemplateFilesDirectoryId artifactTemplateFilesDirectoryId = new ArtifactTemplateFilesDirectoryId(artifactTemplateId);

    SortedSet<RepositoryFileReference> containedReferences = new TreeSet<>();
    RepositoryFileReference repositoryFileReference = new RepositoryFileReference(artifactTemplateId, "exists.txt");
    containedReferences.add(repositoryFileReference);

    when(repository.getContainedFiles(artifactTemplateFilesDirectoryId)).thenReturn(containedReferences);

    TArtifactTemplate artifactTemplate = createArtifactTemplateWithReferenceToAnUrlAndExistentFile();
    when(repository.getElement(artifactTemplateId)).thenReturn(artifactTemplate);
    TArtifactTemplate synchronizhedArtifactTemplate = BackendUtils.synchronizeReferences(repository, artifactTemplateId);

    assertEquals(createArtifactTemplateWithReferenceToAnUrlAndExistentFile(), synchronizhedArtifactTemplate);
}