public void savePackage(PackageConfigData data) throws SerializationException { log.info("USER:"******" SAVING package [" + data.getName() + "]"); PackageItem item = rulesRepository.loadPackage(data.getName()); // If package is being unarchived. boolean unarchived = (!data.isArchived() && item.isArchived()); Calendar packageLastModified = item.getLastModified(); DroolsHeader.updateDroolsHeader(data.getHeader(), item); updateCategoryRules(data, item); item.updateExternalURI(data.getExternalURI()); item.updateDescription(data.getDescription()); item.archiveItem(data.isArchived()); item.updateBinaryUpToDate(false); if (!data.getFormat().equals("")) { item.updateFormat(data.getFormat()); } RuleBaseCache.getInstance().remove(data.getUuid()); item.checkin(data.getDescription()); // If package is archived, archive all the assets under it if (data.isArchived()) { handleArchivedForSavePackage(data, item); } else if (unarchived) { handleUnarchivedForSavePackage(data, item, packageLastModified); } }
@Test public void testSetRootItem() throws Exception { treeItem = mock(IsTreeItem.class); view = mock(ModuleTreeItemView.class); ClientFactory clientFactory = mock(ClientFactory.class); AssetEditorFactory assetEditorFactory = mock(AssetEditorFactory.class); when(clientFactory.getAssetEditorFactory()).thenReturn(assetEditorFactory); PerspectiveFactory perspectiveFactory = mock(PerspectiveFactory.class); when(perspectiveFactory.getRegisteredAssetEditorFormats("package")).thenReturn(new String[0]); NavigationViewFactory navigationViewFactory = mock(NavigationViewFactory.class); when(clientFactory.getNavigationViewFactory()).thenReturn(navigationViewFactory); when(navigationViewFactory.getModuleTreeItemView()).thenReturn(view); PackageConfigData packageConfigData = mock(PackageConfigData.class); when(packageConfigData.getUuid()).thenReturn("mockUuid"); new ModuleTreeSelectableItem(clientFactory, treeItem, packageConfigData); verify(view).setRootItem(treeItem); ArgumentCaptor<ModuleEditorPlace> moduleEditorPlaceArgumentCaptor = ArgumentCaptor.forClass(ModuleEditorPlace.class); verify(view).setRootUserObject(moduleEditorPlaceArgumentCaptor.capture()); ModuleEditorPlace assetViewerPlace = moduleEditorPlaceArgumentCaptor.getValue(); assertEquals("mockUuid", assetViewerPlace.getUuid()); }
public ValidatedResponse validatePackageConfiguration(PackageConfigData data) throws SerializationException { log.info( "USER:"******" validatePackageConfiguration package [" + data.getName() + "]"); RuleBaseCache.getInstance().remove(data.getUuid()); BRMSSuggestionCompletionLoader loader = createBRMSSuggestionCompletionLoader(); loader.getSuggestionEngine(rulesRepository.loadPackage(data.getName()), data.getHeader()); return validateBRMSSuggestionCompletionLoaderResponse(loader); }