AssetWS { @RequestMapping(value = "/api/assets/ids", method = RequestMethod.GET) public Set<Long> getAssetIds(@RequestParam(value = "repositoryId", required = true) Long repositoryId, @RequestParam(value = "deleted", required = false) Boolean deleted, @RequestParam(value = "virtual", required = false) Boolean virtual, @RequestParam(value = "branchId", required = false) Long branchId) { return assetService.findAllAssetIds(repositoryId, null, deleted, virtual, branchId); }  @JsonView(View.AssetSummary.class) @RequestMapping(value = "/api/assets", method = RequestMethod.GET) List<Asset> getAssets(@RequestParam(value = "repositoryId") Long repositoryId,
                                 @RequestParam(value = "path", required = false) String path,
                                 @RequestParam(value = "deleted", required = false) Boolean deleted,
                                 @RequestParam(value = "virtual", required = false) Boolean virtual,
                                 @RequestParam(value = "branchId", required = false) Long branchId); @RequestMapping(value = "/api/assets", method = RequestMethod.POST) SourceAsset importSourceAsset(@RequestBody SourceAsset sourceAsset); @RequestMapping(value = "/api/assets/{assetId}/localized/{localeId}", method = RequestMethod.POST) LocalizedAssetBody getLocalizedAssetForContent(
            @PathVariable("assetId") long assetId,
            @PathVariable("localeId") long localeId,
            @RequestBody LocalizedAssetBody localizedAssetBody); @RequestMapping(value = "/api/assets/{assetId}/localized", method = RequestMethod.POST) PollableTask getLocalizedAssetForContentAsync(
            @PathVariable("assetId") long assetId,
            @RequestBody LocalizedAssetBody localizedAssetBody); @RequestMapping(value = "/api/assets/{assetId}/pseudo", method = RequestMethod.POST) LocalizedAssetBody getPseudoLocalizedAssetForContent(
            @PathVariable("assetId") long assetId,
            @RequestBody LocalizedAssetBody localizedAssetBody); @RequestMapping(value = "/api/assets/{assetId}/localized/{localeId}/import", method = RequestMethod.POST) ImportLocalizedAssetBody importLocalizedAsset(
            @PathVariable("assetId") long assetId,
            @PathVariable("localeId") long localeId,
            @RequestBody ImportLocalizedAssetBody importLocalizedAssetBody); @RequestMapping(method = RequestMethod.GET, value = "/api/assets/{assetId}/xliffExport/{tmXliffId}") @ResponseStatus(HttpStatus.OK) XliffExportBody xliffExport(@PathVariable("assetId") long assetId, @PathVariable("tmXliffId") long tmXliffId); @RequestMapping(method = RequestMethod.POST, value = "/api/assets/{assetId}/xliffExport") XliffExportBody xliffExportAsync(@PathVariable("assetId") long assetId,
                                            @RequestParam("bcp47tag") String bcp47tag,
                                            @RequestBody XliffExportBody xliffExportBody); @RequestMapping(value = "/api/assets/{assetId}", method = RequestMethod.DELETE) void deleteAssetById(@PathVariable Long assetId); @RequestMapping(value = "/api/assets", method = RequestMethod.DELETE) PollableTask deleteAssetsOfBranches(@RequestParam(value = "branchId", required = false) Long branchId,
                                               @RequestBody Set<Long> ids); @RequestMapping(value = "/api/assets/ids", method = RequestMethod.GET) Set<Long> getAssetIds(@RequestParam(value = "repositoryId", required = true) Long repositoryId,
                                 @RequestParam(value = "deleted", required = false) Boolean deleted,
                                 @RequestParam(value = "virtual", required = false) Boolean virtual,
                                 @RequestParam(value = "branchId", required = false) Long branchId);  }
@Test public void testDeleteUnusedAssets() throws RepositoryNotFoundException, RepositoryNameAlreadyUsedException { Repository repository = testDataFactory.createRepository(testIdWatcher); List<com.box.l10n.mojito.rest.entity.Asset> assets = assetClient.getAssetsByRepositoryId(repository.getId()); assertEquals("There should be no asset for this repository yet", 0, assets.size()); String path1 = "/path/to/fake/file1.xliff"; String path2 = "/path/to/fake/file2.xliff"; String path3 = "/path/to/fake/file3.xliff"; com.box.l10n.mojito.rest.entity.SourceAsset sourceAsset1 = createSourceAsset(repository); sourceAsset1.setPath(path1); com.box.l10n.mojito.rest.entity.SourceAsset sourceAssetAfterPost1 = assetClient.sendSourceAsset(sourceAsset1); pollableTaskClient.waitForPollableTask(sourceAssetAfterPost1.getPollableTask().getId(), 5000L); com.box.l10n.mojito.rest.entity.SourceAsset sourceAsset2 = createSourceAsset(repository); sourceAsset2.setPath(path2); com.box.l10n.mojito.rest.entity.SourceAsset sourceAssetAfterPost2 = assetClient.sendSourceAsset(sourceAsset2); pollableTaskClient.waitForPollableTask(sourceAssetAfterPost2.getPollableTask().getId(), 5000L); com.box.l10n.mojito.rest.entity.SourceAsset sourceAsset3 = createSourceAsset(repository); sourceAsset2.setPath(path3); com.box.l10n.mojito.rest.entity.SourceAsset sourceAssetAfterPost3 = assetClient.sendSourceAsset(sourceAsset2); pollableTaskClient.waitForPollableTask(sourceAssetAfterPost3.getPollableTask().getId(), 5000L); assets = assetClient.getAssetsByRepositoryId(repository.getId()); assertEquals("There should be three assets for this repository", 3, assets.size()); Branch branch = branchRepository.findByNameAndRepository(null, repository); PollableTask pollableTask = assetClient.deleteAssetsInBranch(Sets.newHashSet(sourceAssetAfterPost2.getAddedAssetId(), sourceAssetAfterPost3.getAddedAssetId()), branch.getId()); pollableTaskClient.waitForPollableTask(pollableTask.getId()); assets = assetClient.getAssetsByRepositoryId(repository.getId()); assertEquals("There should be three assets for this repository", 3, assets.size()); assets = assetClient.getAssetsByRepositoryId(repository.getId(), false); assertEquals("There should be one undeleted asset for this repository", 1, assets.size()); assertEquals("Asset with path1 should not be deleted", path1, assets.get(0).getPath()); assets = assetClient.getAssetsByRepositoryId(repository.getId(), true); assertEquals("There should be two deleted assets for this repository", 2, assets.size()); assertTrue(assets.get(0).getPath().equals(path2) || assets.get(0).getPath().equals(path3)); assertTrue(assets.get(1).getPath().equals(path2) || assets.get(1).getPath().equals(path3)); List<Long> assetIds = assetClient.getAssetIds(repository.getId(), null, null, null); assertEquals("There should be three asset ids for this repository", 3, assetIds.size()); assetIds = assetClient.getAssetIds(repository.getId(), false, null, null); assertEquals("There should be one undeleted asset id for this repository", 1, assetIds.size()); assertEquals(sourceAssetAfterPost1.getAddedAssetId(), assetIds.iterator().next()); assetIds = assetClient.getAssetIds(repository.getId(), true, null, null); assertEquals("There should be two deleted asset ids for this repository", 2, assetIds.size()); assertTrue(assetIds.iterator().next().equals(sourceAssetAfterPost2.getAddedAssetId()) || assetIds.iterator().next().equals(sourceAssetAfterPost3.getAddedAssetId())); assertTrue(assetIds.iterator().next().equals(sourceAssetAfterPost2.getAddedAssetId()) || assetIds.iterator().next().equals(sourceAssetAfterPost3.getAddedAssetId())); }