@Test public void testAddOrUpdateAssetAndProcessIfNeededReAddingAsset() throws Exception { String content = "content"; String path = "path/to/asset.csv"; Repository repository = repositoryService.createRepository(testIdWatcher.getEntityName("repository")); Asset asset = addAssetAndWaitUntilDoneProcessing(repository.getId(), content, path, null); List<AssetExtraction> assetExtractions = assetExtractionRepository.findByAsset(asset); assertEquals("There should be one assetExtraction created when the adding an asset with initial content", 1, assetExtractions.size()); Long assetId = asset.getId(); assetService.deleteAsset(asset); assertTrue("The asset should have been deleted", assetRepository.findById(assetId).orElse(null).getDeleted()); addAssetAndWaitUntilDoneProcessing(repository.getId(), content, path, null); assetExtractions = assetExtractionRepository.findByAsset(asset); assertEquals("When re-adding an asset (same content as previously deleted), it will get processed as normal", 2, assetExtractions.size()); assertFalse("The asset extraction process should un-delete the deleted asset", assetRepository.findById(assetId).orElse(null).getDeleted()); }
@Transactional public void deleteAsset(Asset asset) { logger.debug("Delete an asset with path: {}", asset.getPath()); asset.setDeleted(true); assetRepository.save(asset); int numberOfAssetExtractionByBranchUpdated = assetExtractionByBranchRepository.setDeletedTrue(asset); logger.debug("Deleted asset with path: {} (Number of AssetExtractionByBranchUpdated: {})", asset.getPath(), numberOfAssetExtractionByBranchUpdated); }
AssetService { @Transactional public void deleteAsset(Asset asset) { logger.debug("Delete an asset with path: {}", asset.getPath()); asset.setDeleted(true); assetRepository.save(asset); int numberOfAssetExtractionByBranchUpdated = assetExtractionByBranchRepository.setDeletedTrue(asset); logger.debug("Deleted asset with path: {} (Number of AssetExtractionByBranchUpdated: {})", asset.getPath(), numberOfAssetExtractionByBranchUpdated); } }
AssetService { @Transactional public void deleteAsset(Asset asset) { logger.debug("Delete an asset with path: {}", asset.getPath()); asset.setDeleted(true); assetRepository.save(asset); int numberOfAssetExtractionByBranchUpdated = assetExtractionByBranchRepository.setDeletedTrue(asset); logger.debug("Deleted asset with path: {} (Number of AssetExtractionByBranchUpdated: {})", asset.getPath(), numberOfAssetExtractionByBranchUpdated); }  }
AssetService { @Transactional public void deleteAsset(Asset asset) { logger.debug("Delete an asset with path: {}", asset.getPath()); asset.setDeleted(true); assetRepository.save(asset); int numberOfAssetExtractionByBranchUpdated = assetExtractionByBranchRepository.setDeletedTrue(asset); logger.debug("Deleted asset with path: {} (Number of AssetExtractionByBranchUpdated: {})", asset.getPath(), numberOfAssetExtractionByBranchUpdated); }  PollableFuture<Asset> addOrUpdateAssetAndProcessIfNeeded(
            Long repositoryId,
            String assetPath,
            String assetContent,
            boolean extractedContent,
            String branch,
            String branchCreatedByUsername,
            FilterConfigIdOverride filterConfigIdOverride,
            List<String> filterOptions); Asset createAsset(Long repositoryId, String assetPath, boolean virtualContent); Asset createAssetWithContent(Long repositoryId, String assetPath, String assetContent); @Transactional void deleteAsset(Asset asset); @Transactional void deleteAssets(Set<Long> assetIds); PollableFuture<Void> asyncDeleteAssetsOfBranch(Set<Long> assetIds, Long branchId); void deleteAssetsOfBranch(Set<Long> assetIds, Long branchId); void deleteAssetOfBranch(Long assetId, Long branchId); List<Asset> findAll(Long repositoryId, String path, Boolean deleted, Boolean virtual, Long branchId); Set<Long> findAllAssetIds(Long repositoryId, String path, Boolean deleted, Boolean virtual, Long branchId); }
AssetService { @Transactional public void deleteAsset(Asset asset) { logger.debug("Delete an asset with path: {}", asset.getPath()); asset.setDeleted(true); assetRepository.save(asset); int numberOfAssetExtractionByBranchUpdated = assetExtractionByBranchRepository.setDeletedTrue(asset); logger.debug("Deleted asset with path: {} (Number of AssetExtractionByBranchUpdated: {})", asset.getPath(), numberOfAssetExtractionByBranchUpdated); }  PollableFuture<Asset> addOrUpdateAssetAndProcessIfNeeded(
            Long repositoryId,
            String assetPath,
            String assetContent,
            boolean extractedContent,
            String branch,
            String branchCreatedByUsername,
            FilterConfigIdOverride filterConfigIdOverride,
            List<String> filterOptions); Asset createAsset(Long repositoryId, String assetPath, boolean virtualContent); Asset createAssetWithContent(Long repositoryId, String assetPath, String assetContent); @Transactional void deleteAsset(Asset asset); @Transactional void deleteAssets(Set<Long> assetIds); PollableFuture<Void> asyncDeleteAssetsOfBranch(Set<Long> assetIds, Long branchId); void deleteAssetsOfBranch(Set<Long> assetIds, Long branchId); void deleteAssetOfBranch(Long assetId, Long branchId); List<Asset> findAll(Long repositoryId, String path, Boolean deleted, Boolean virtual, Long branchId); Set<Long> findAllAssetIds(Long repositoryId, String path, Boolean deleted, Boolean virtual, Long branchId);  }