RepositoryService { @Transactional public void updateRepositoryLocales(Set<RepositoryLocale> repositoryLocales) throws RepositoryLocaleCreationException { updateRepositoryLocales(null, repositoryLocales); }  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 testUpdateRepositoryLocales() throws Exception { String repositoryName = testIdWatcher.getEntityName("repository"); Repository repository = repositoryService.createRepository(repositoryName); Repository controlledRepository = repositoryService.createRepository(repositoryName + "_2"); HashSet<RepositoryLocale> repositoryLocales = new HashSet<>(); repositoryLocales.add(new RepositoryLocale(repository, localeService.findByBcp47Tag("fr-FR"), true, null)); logger.debug("Updating RepositoryLocale with a Set that only contains 'fr-FR'"); repositoryService.updateRepositoryLocales(repository, repositoryLocales); assertEquals("This number includes the root locale", 2, repositoryRepository.findByName(repository.getName()).getRepositoryLocales().size()); assertEquals("Repository is not expected to be changed", 1, repositoryRepository.findByName(controlledRepository.getName()).getRepositoryLocales().size()); repositoryLocales.clear(); RepositoryLocale zhTW = new RepositoryLocale(repository, localeService.findByBcp47Tag("zh-TW"), true, null); repositoryLocales.add(zhTW); repositoryLocales.add(new RepositoryLocale(repository, localeService.findByBcp47Tag("zh-HK"), true, zhTW)); logger.debug("Updating RepositoryLocale again with a new Set that does not contain 'fr-FR'"); repositoryService.updateRepositoryLocales(repository, repositoryLocales); Repository repository1 = repositoryRepository.findByName(repository.getName()); assertEquals("This number includes the root locale", 3, repository1.getRepositoryLocales().size()); for (RepositoryLocale repositoryLocale : repository1.getRepositoryLocales()) { assertNotEquals("fr-FR should have been removed", "fr-FR", repositoryLocale.getLocale().getBcp47Tag()); } assertEquals("Repository is not expected to be changed", 1, repositoryRepository.findByName(controlledRepository.getName()).getRepositoryLocales().size()); }