@Test public void testUnused() throws InterruptedException, RepositoryNameAlreadyUsedException, RepositoryLocaleCreationException, VirtualAssetBadRequestException, ExecutionException { Repository repository = repositoryService.createRepository(testIdWatcher.getEntityName("testUnused")); RepositoryLocale repositoryLocaleFrFR = repositoryService.addRepositoryLocale(repository, "fr-FR"); VirtualAsset virtualAsset1 = new VirtualAsset(); virtualAsset1.setRepositoryId(repository.getId()); virtualAsset1.setPath("default"); virtualAsset1 = virtualAssetService.createOrUpdateVirtualAsset(virtualAsset1); VirtualAssetTextUnit virtualAssetTextUnit = new VirtualAssetTextUnit(); virtualAssetTextUnit.setName("name1"); virtualAssetTextUnit.setContent("content1"); virtualAssetTextUnit.setComment("comment1"); logger.debug("Create a first unused text unit for name1"); virtualAssetService.addTextUnits(virtualAsset1.getId(), Arrays.asList(virtualAssetTextUnit)).get(); virtualAssetService.replaceTextUnits(virtualAsset1.getId(), new ArrayList<VirtualAssetTextUnit>()).get(); TextUnitSearcherParameters textUnitSearcherParameters = new TextUnitSearcherParametersForTesting(); textUnitSearcherParameters.setRepositoryNames(Arrays.asList(repository.getName())); TextUnitDTO textUnitDTO = new TextUnitDTO(); textUnitDTO.setRepositoryName(repository.getName()); textUnitDTO.setAssetPath("default"); textUnitDTO.setName("name1"); textUnitDTO.setTargetLocale("fr-FR"); textUnitDTO.setTarget("v1"); textUnitBatchImporterService.asyncImportTextUnits(Arrays.asList(textUnitDTO), false, false).get(); List<TextUnitDTO> textUnitDTOs = textUnitSearcher.search(textUnitSearcherParameters); assertEquals(1, textUnitDTOs.size()); assertEquals("content1", textUnitDTOs.get(0).getSource()); assertEquals("Should import since there is a single unused text unit for name1", "v1", textUnitDTOs.get(0).getTarget()); virtualAssetTextUnit = new VirtualAssetTextUnit(); virtualAssetTextUnit.setName("name1"); virtualAssetTextUnit.setContent("content1 - v2"); virtualAssetTextUnit.setComment("comment1"); logger.debug("Create a second unused for text unit for name1"); virtualAssetService.addTextUnits(virtualAsset1.getId(), Arrays.asList(virtualAssetTextUnit)).get(); virtualAssetService.replaceTextUnits(virtualAsset1.getId(), new ArrayList<VirtualAssetTextUnit>()).get(); textUnitDTO = new TextUnitDTO(); textUnitDTO.setRepositoryName(repository.getName()); textUnitDTO.setAssetPath("default"); textUnitDTO.setName("name1"); textUnitDTO.setTargetLocale("fr-FR"); textUnitDTO.setTarget("v2"); textUnitBatchImporterService.asyncImportTextUnits(Arrays.asList(textUnitDTO), false, false).get(); textUnitDTOs = textUnitSearcher.search(textUnitSearcherParameters); assertEquals(2, textUnitDTOs.size()); assertEquals("content1", textUnitDTOs.get(0).getSource()); assertEquals("v1", textUnitDTOs.get(0).getTarget()); assertEquals("content1 - v2", textUnitDTOs.get(1).getSource()); assertNull("Should not import since there is 2 text unit for name1", textUnitDTOs.get(1).getTarget()); virtualAssetService.addTextUnits(virtualAsset1.getId(), Arrays.asList(virtualAssetTextUnit)).get(); textUnitBatchImporterService.asyncImportTextUnits(Arrays.asList(textUnitDTO), false, false).get(); textUnitDTOs = textUnitSearcher.search(textUnitSearcherParameters); assertEquals(2, textUnitDTOs.size()); assertEquals("content1", textUnitDTOs.get(0).getSource()); assertEquals("v1", textUnitDTOs.get(0).getTarget()); assertEquals("content1 - v2", textUnitDTOs.get(1).getSource()); assertEquals("v2", textUnitDTOs.get(1).getTarget()); }
public PollableFuture<Void> asyncImportTextUnits(List<TextUnitDTO> textUnitDTOs, boolean integrityCheckSkipped, boolean integrityCheckKeepStatusIfFailedAndSameTarget) { ImportTextUnitJobInput importTextUnitJobInput = new ImportTextUnitJobInput(); importTextUnitJobInput.setTextUnitDTOs(textUnitDTOs); importTextUnitJobInput.setIntegrityCheckSkipped(integrityCheckSkipped); importTextUnitJobInput.setIntegrityCheckKeepStatusIfFailedAndSameTarget(integrityCheckKeepStatusIfFailedAndSameTarget); return quartzPollableTaskScheduler.scheduleJob(ImportTextUnitJob.class, importTextUnitJobInput); }
TextUnitBatchImporterService { public PollableFuture<Void> asyncImportTextUnits(List<TextUnitDTO> textUnitDTOs, boolean integrityCheckSkipped, boolean integrityCheckKeepStatusIfFailedAndSameTarget) { ImportTextUnitJobInput importTextUnitJobInput = new ImportTextUnitJobInput(); importTextUnitJobInput.setTextUnitDTOs(textUnitDTOs); importTextUnitJobInput.setIntegrityCheckSkipped(integrityCheckSkipped); importTextUnitJobInput.setIntegrityCheckKeepStatusIfFailedAndSameTarget(integrityCheckKeepStatusIfFailedAndSameTarget); return quartzPollableTaskScheduler.scheduleJob(ImportTextUnitJob.class, importTextUnitJobInput); } }
TextUnitBatchImporterService { public PollableFuture<Void> asyncImportTextUnits(List<TextUnitDTO> textUnitDTOs, boolean integrityCheckSkipped, boolean integrityCheckKeepStatusIfFailedAndSameTarget) { ImportTextUnitJobInput importTextUnitJobInput = new ImportTextUnitJobInput(); importTextUnitJobInput.setTextUnitDTOs(textUnitDTOs); importTextUnitJobInput.setIntegrityCheckSkipped(integrityCheckSkipped); importTextUnitJobInput.setIntegrityCheckKeepStatusIfFailedAndSameTarget(integrityCheckKeepStatusIfFailedAndSameTarget); return quartzPollableTaskScheduler.scheduleJob(ImportTextUnitJob.class, importTextUnitJobInput); }  }
TextUnitBatchImporterService { public PollableFuture<Void> asyncImportTextUnits(List<TextUnitDTO> textUnitDTOs, boolean integrityCheckSkipped, boolean integrityCheckKeepStatusIfFailedAndSameTarget) { ImportTextUnitJobInput importTextUnitJobInput = new ImportTextUnitJobInput(); importTextUnitJobInput.setTextUnitDTOs(textUnitDTOs); importTextUnitJobInput.setIntegrityCheckSkipped(integrityCheckSkipped); importTextUnitJobInput.setIntegrityCheckKeepStatusIfFailedAndSameTarget(integrityCheckKeepStatusIfFailedAndSameTarget); return quartzPollableTaskScheduler.scheduleJob(ImportTextUnitJob.class, importTextUnitJobInput); }  PollableFuture<Void> asyncImportTextUnits(List<TextUnitDTO> textUnitDTOs,
                                               boolean integrityCheckSkipped,
                                               boolean integrityCheckKeepStatusIfFailedAndSameTarget); PollableFuture importTextUnits(List<TextUnitDTO> textUnitDTOs,
                                          boolean integrityCheckSkipped,
                                          boolean integrityCheckKeepStatusIfFailedAndSameTarget); }
TextUnitBatchImporterService { public PollableFuture<Void> asyncImportTextUnits(List<TextUnitDTO> textUnitDTOs, boolean integrityCheckSkipped, boolean integrityCheckKeepStatusIfFailedAndSameTarget) { ImportTextUnitJobInput importTextUnitJobInput = new ImportTextUnitJobInput(); importTextUnitJobInput.setTextUnitDTOs(textUnitDTOs); importTextUnitJobInput.setIntegrityCheckSkipped(integrityCheckSkipped); importTextUnitJobInput.setIntegrityCheckKeepStatusIfFailedAndSameTarget(integrityCheckKeepStatusIfFailedAndSameTarget); return quartzPollableTaskScheduler.scheduleJob(ImportTextUnitJob.class, importTextUnitJobInput); }  PollableFuture<Void> asyncImportTextUnits(List<TextUnitDTO> textUnitDTOs,
                                               boolean integrityCheckSkipped,
                                               boolean integrityCheckKeepStatusIfFailedAndSameTarget); PollableFuture importTextUnits(List<TextUnitDTO> textUnitDTOs,
                                          boolean integrityCheckSkipped,
                                          boolean integrityCheckKeepStatusIfFailedAndSameTarget);  }