RepositoryService { @Transactional public void deleteRepository(Repository repository) { logger.debug("Delete a repository with name: {}", repository.getName()); String name = "deleted__" + System.currentTimeMillis() + "__" + repository.getName(); repository.setName(StringUtils.abbreviate(name, Repository.NAME_MAX_LENGTH)); repository.setDeleted(true); repositoryRepository.save(repository); logger.debug("Deleted repository with name: {}", repository.getName()); }  List<Repository> findRepositoriesIsNotDeletedOrderByName(String repositoryName); @Transactional Repository createRepository(String name, String description, Locale sourceLocale, Boolean checkSLA); Repository addManualScreenshotRun(Repository repository); Repository createRepository(String name); @Transactional Repository createRepository(
            String name,
            String description,
            Locale sourceLocale,
            Boolean checkSLA,
            Set<AssetIntegrityChecker> assetIntegrityCheckers,
            Set<RepositoryLocale> repositoryLocales); @Transactional void updateAssetIntegrityCheckers(Repository repository, Set<AssetIntegrityChecker> assetIntegrityCheckers); @Transactional void updateRepositoryLocales(Set<RepositoryLocale> repositoryLocales); @Transactional void updateRepositoryLocales(Repository repository, Set<RepositoryLocale> repositoryLocales); Map<String, RepositoryLocale> getMapAndCheckConflictAndAssertSameRepository(Set<RepositoryLocale> repositoryLocales); RepositoryLocale addRepositoryLocale(Repository repository, String bcp47Tag); @Transactional RepositoryLocale addRepositoryLocale(
            Repository repository,
            String bcp47Tag,
            String parentLocaleBcp47Tag,
            boolean toBeFullyTranslated); Set<RepositoryLocale> getRepositoryLocalesWithoutRootLocale(Repository repository); boolean isRootRepositoryLocale(RepositoryLocale repositoryLocale); @Transactional void deleteRepository(Repository repository); @Transactional void updateRepository(Repository repository, String newName, String description, Boolean checkSLA, Set<RepositoryLocale> repositoryLocales, Set<AssetIntegrityChecker> assetIntegrityCheckers);  }
@Test public void testDeleteRepository() throws Exception { String repositoryName = testIdWatcher.getEntityName("repository"); Repository repositoryToDelete = repositoryService.createRepository(repositoryName); assertEquals("The repository should be found because it is not deleted yet", 1, repositoryRepository.findAll( where(ifParamNotNull(nameEquals(repositoryName))).and(deletedEquals(false))).size() ); Long repositoryId = repositoryToDelete.getId(); long numberOfRepositories = repositoryRepository.findByDeletedFalseOrderByNameAsc().size(); repositoryService.deleteRepository(repositoryToDelete); assertEquals("The deleted repository is found", 0, repositoryRepository.findAll( where(ifParamNotNull(nameEquals(repositoryName))).and(deletedEquals(false))).size() ); assertEquals(numberOfRepositories - 1, repositoryRepository.findByDeletedFalseOrderByNameAsc().size()); assertNull("Found the deleted repository", repositoryRepository.findByName(repositoryName)); Repository deletedRepository = repositoryRepository.findById(repositoryId).orElse(null); assertTrue("The repository is not deleted", deletedRepository.getDeleted()); assertTrue("The deleted repository is not renamed properly", deletedRepository.getName().startsWith("deleted__")); Repository repositoryToCreateAgain = repositoryService.createRepository(repositoryName); assertEquals("The repository should be found when it is added again", 1, repositoryRepository.findAll( where(ifParamNotNull(nameEquals(repositoryName))).and(deletedEquals(false))).size() ); assertEquals(numberOfRepositories, repositoryRepository.findByDeletedFalseOrderByNameAsc().size()); assertEquals("The repository is created with unexpected name", repositoryName, repositoryToCreateAgain.getName()); assertNotEquals("The repository is created with existing id", repositoryId, repositoryToCreateAgain.getId()); assertFalse("The repository is deleted", repositoryToCreateAgain.getDeleted()); }