AssetIntegrityCheckerService { @Transactional public void addToRepository(Repository repository, String assetPath, IntegrityCheckerType integrityCheckerType) { AssetIntegrityChecker assetIntegrityChecker = new AssetIntegrityChecker(); assetIntegrityChecker.setRepository(repository); assetIntegrityChecker.setAssetExtension(FilenameUtils.getExtension(assetPath)); assetIntegrityChecker.setIntegrityCheckerType(integrityCheckerType); assetIntegrityCheckerRepository.save(assetIntegrityChecker); }  @Transactional void addToRepository(Repository repository, String assetPath, IntegrityCheckerType integrityCheckerType);  }
@Test public void testIntegrityCheckerIsUsedInTmServiceUpdate() throws RepositoryLocaleCreationException, ExecutionException, InterruptedException, RepositoryNameAlreadyUsedException, AssetUpdateException, UnsupportedAssetFilterTypeException { Repository repository = repositoryService.createRepository(testIdWatcher.getEntityName("repository")); String frFR = "fr-FR"; repositoryService.addRepositoryLocale(repository, "fr-FR"); assetIntegrityCheckerService.addToRepository(repository, ASSET_PATH, IntegrityCheckerType.MESSAGE_FORMAT); String sourceTextUnit = "{numFiles, plural, one{# There is one file} other{There are # files}}"; String sourceXliff = xliffDataFactory.generateSourceXliff(Arrays.asList( xliffDataFactory.createTextUnit(1L, "tu1", sourceTextUnit, null) )); PollableFuture<Asset> assetPollableFuture = assetService.addOrUpdateAssetAndProcessIfNeeded(repository.getId(), "source-asset-path.xliff", sourceXliff, false, null, null, null, null); pollableTaskService.waitForPollableTask(assetPollableFuture.getPollableTask().getId()); Long tmId = repository.getTm().getId(); List<TMTextUnit> tmTextUnits = tmTextUnitRepository.findByTm_id(tmId); assertEquals(1, tmTextUnits.size()); Long tmTextUnitId = tmTextUnits.get(0).getId(); String targetXliff = xliffDataFactory.generateTargetXliff(Arrays.asList( xliffDataFactory.createTextUnit(tmTextUnitId, "tu1", sourceTextUnit, null, "{numFiles, plural, one{Il y a un fichier} other{Il y a # fichiers}", frFR, XliffState.TRANSLATED) ), frFR); Locale frFRLocale = localeService.findByBcp47Tag(frFR); tmService.updateTMWithXLIFFById(targetXliff, null); List<TMTextUnitVariant> textUnitVariants = tmTextUnitVariantRepository.findAllByLocale_IdAndTmTextUnit_Tm_id(frFRLocale.getId(), tmId); assertEquals(1, textUnitVariants.size()); assertFalse(textUnitVariants.get(0).isIncludedInLocalizedFile()); assertEquals(TMTextUnitVariant.Status.TRANSLATION_NEEDED, textUnitVariants.get(0).getStatus()); }