VirtualAssetService { @Transactional void addTextUnit( long assetId, String name, String content, String comment, String pluralForm, String pluralFormOther, boolean doNotTranslate) throws VirtualAssetRequiredException { Asset asset = getVirtualAsset(assetId); addTextUnit(asset, name, content, comment, pluralForm, pluralFormOther, doNotTranslate); }  @Transactional VirtualAsset createOrUpdateVirtualAsset(VirtualAsset virtualAsset); List<VirtualAssetTextUnit> getTextUnits(long assetId, Boolean doNotTranslateFilter); @Transactional List<VirtualAssetTextUnit> getLocalizedTextUnits(
            long assetId,
            long localeId,
            InheritanceMode inheritanceMode); PollableFuture<Void> addTextUnits(long assetId, List<VirtualAssetTextUnit> virtualAssetTextUnits); PollableFuture<Void> replaceTextUnits(long assetId, List<VirtualAssetTextUnit> virtualAssetTextUnits); PollableFuture<Void> importLocalizedTextUnits(
            long assetId,
            long localeId,
            List<VirtualAssetTextUnit> textUnitForVirtualAssets); @Transactional void deleteTextUnit(Long assetId, String name); void deleteTextUnits(Asset asset, List<String> names); TMTextUnitVariant addTextUnitVariant(long assetId, long localeId, String name, String content, String comment);  }
@Test public void testAddTextUnit() throws Exception { Repository repository = repositoryService.createRepository(testIdWatcher.getEntityName("testAddTextUnit")); VirtualAsset virtualAsset = new VirtualAsset(); virtualAsset.setRepositoryId(repository.getId()); virtualAsset.setPath("default"); virtualAsset = virtualAssetService.createOrUpdateVirtualAsset(virtualAsset); virtualAssetService.addTextUnit( virtualAsset.getId(), "name_plural_other", "content plural", "comment plural", "other", "name_plural_other", false); virtualAssetService.addTextUnit( virtualAsset.getId(), "name", "content", "comment", null, null, true); List<VirtualAssetTextUnit> textUnits = virtualAssetService.getTextUnits(virtualAsset.getId(), null); assertEquals(2, textUnits.size()); int i = 0; assertEquals("name", textUnits.get(i).getName()); assertEquals("content", textUnits.get(i).getContent()); assertEquals("comment", textUnits.get(i).getComment()); assertNull(textUnits.get(i).getPluralForm()); assertNull(textUnits.get(i).getPluralFormOther()); assertTrue(textUnits.get(i).getDoNotTranslate()); i++; assertEquals("name_plural_other", textUnits.get(i).getName()); assertEquals("content plural", textUnits.get(i).getContent()); assertEquals("comment plural", textUnits.get(i).getComment()); assertEquals("other", textUnits.get(i).getPluralForm()); assertEquals("name_plural_other", textUnits.get(i).getPluralFormOther()); assertFalse(textUnits.get(i).getDoNotTranslate()); }
@Test(expected = VirtualAssetRequiredException.class) public void testCantAddTextUnitToNoVirtual() throws Exception { Repository repository = repositoryService.createRepository(testIdWatcher.getEntityName("testCantAddTextUnitToNoVirtual")); Asset asset = assetService.createAssetWithContent(repository.getId(), "default", ""); virtualAssetService.addTextUnit( asset.getId(), "name_plural_other", "content plural", "comment plural", "other", "name_plural_other", false); }