From e151cad884471e0d961f7bb2f2af71fac3670e08 Mon Sep 17 00:00:00 2001 From: Paulo Martins Date: Tue, 17 Oct 2017 11:43:06 -0200 Subject: [PATCH] RHBPMS-5008: [Security management] Disabled assets can be edited (#658) --- .../DecisionTableXLSEditorPresenter.java | 7 ++++--- .../DecisionTableXLSEditorPresenterTest.java | 16 +++++++------- .../client/editor/GlobalsEditorPresenter.java | 19 +++++++++-------- .../editor/GlobalsEditorPresenterTest.java | 17 +++++++++------ ...aseGuidedDecisionTableEditorPresenter.java | 8 ++++++- .../GuidedDecisionTableEditorPresenter.java | 7 ++++--- ...idedDecisionTableGraphEditorPresenter.java | 10 ++++----- .../BaseGuidedDecisionTablePresenterTest.java | 5 +++++ ...uidedDecisionTableEditorPresenterTest.java | 14 +++++++------ ...DecisionTableGraphEditorPresenterTest.java | 21 ++++++++++--------- .../client/ScenarioEditorPresenter.java | 14 +++++-------- .../client/ScenarioEditorPresenterTest.java | 17 ++++++++------- 12 files changed, 88 insertions(+), 67 deletions(-) diff --git a/drools-wb-screens/drools-wb-dtable-xls-editor/drools-wb-dtable-xls-editor-client/src/main/java/org/drools/workbench/screens/dtablexls/client/editor/DecisionTableXLSEditorPresenter.java b/drools-wb-screens/drools-wb-dtable-xls-editor/drools-wb-dtable-xls-editor-client/src/main/java/org/drools/workbench/screens/dtablexls/client/editor/DecisionTableXLSEditorPresenter.java index 6ec4924525c..499da0955d7 100644 --- a/drools-wb-screens/drools-wb-dtable-xls-editor/drools-wb-dtable-xls-editor-client/src/main/java/org/drools/workbench/screens/dtablexls/client/editor/DecisionTableXLSEditorPresenter.java +++ b/drools-wb-screens/drools-wb-dtable-xls-editor/drools-wb-dtable-xls-editor-client/src/main/java/org/drools/workbench/screens/dtablexls/client/editor/DecisionTableXLSEditorPresenter.java @@ -220,10 +220,11 @@ protected void makeMenuBar() { if (canUpdateProject()) { fileMenuBuilder .addCopy(versionRecordManager.getCurrentPath(), - fileNameValidator) + assetUpdateValidator) .addRename(versionRecordManager.getPathToLatest(), - fileNameValidator) - .addDelete(versionRecordManager.getPathToLatest()); + assetUpdateValidator) + .addDelete(versionRecordManager.getPathToLatest(), + assetUpdateValidator); } fileMenuBuilder diff --git a/drools-wb-screens/drools-wb-dtable-xls-editor/drools-wb-dtable-xls-editor-client/src/test/java/org/drools/workbench/screens/dtablexls/client/editor/DecisionTableXLSEditorPresenterTest.java b/drools-wb-screens/drools-wb-dtable-xls-editor/drools-wb-dtable-xls-editor-client/src/test/java/org/drools/workbench/screens/dtablexls/client/editor/DecisionTableXLSEditorPresenterTest.java index df643aec7a9..513a0e73aba 100644 --- a/drools-wb-screens/drools-wb-dtable-xls-editor/drools-wb-dtable-xls-editor-client/src/test/java/org/drools/workbench/screens/dtablexls/client/editor/DecisionTableXLSEditorPresenterTest.java +++ b/drools-wb-screens/drools-wb-dtable-xls-editor/drools-wb-dtable-xls-editor-client/src/test/java/org/drools/workbench/screens/dtablexls/client/editor/DecisionTableXLSEditorPresenterTest.java @@ -42,6 +42,7 @@ import org.kie.workbench.common.widgets.client.menu.FileMenuBuilderImpl; import org.kie.workbench.common.widgets.client.popups.validation.ValidationPopup; import org.kie.workbench.common.widgets.metadata.client.KieEditorWrapperView; +import org.kie.workbench.common.widgets.metadata.client.validation.AssetUpdateValidator; import org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter; import org.mockito.InjectMocks; import org.mockito.Mock; @@ -50,7 +51,6 @@ import org.uberfire.backend.vfs.Path; import org.uberfire.ext.editor.commons.client.history.VersionRecordManager; import org.uberfire.ext.editor.commons.client.menu.BasicFileMenuBuilder; -import org.uberfire.ext.editor.commons.client.validation.DefaultFileNameValidator; import org.uberfire.ext.widgets.common.client.common.BusyIndicatorView; import org.uberfire.ext.widgets.common.client.common.ConcurrentChangePopup; import org.uberfire.mocks.EventSourceMock; @@ -219,10 +219,11 @@ public void testMakeMenuBar() { presenter.makeMenuBar(); verify(fileMenuBuilder).addCopy(any(Path.class), - any(DefaultFileNameValidator.class)); + any(AssetUpdateValidator.class)); verify(fileMenuBuilder).addRename(any(Path.class), - any(DefaultFileNameValidator.class)); - verify(fileMenuBuilder).addDelete(any(Path.class)); + any(AssetUpdateValidator.class)); + verify(fileMenuBuilder).addDelete(any(Path.class), + any(AssetUpdateValidator.class)); } @Test @@ -234,12 +235,13 @@ public void testMakeMenuBarWithoutUpdateProjectPermission() { verify(fileMenuBuilder, never()).addCopy(any(Path.class), - any(DefaultFileNameValidator.class)); + any(AssetUpdateValidator.class)); verify(fileMenuBuilder, never()).addRename(any(Path.class), - any(DefaultFileNameValidator.class)); + any(AssetUpdateValidator.class)); verify(fileMenuBuilder, - never()).addDelete(any(Path.class)); + never()).addDelete(any(Path.class), + any(AssetUpdateValidator.class)); } private class ServiceMock diff --git a/drools-wb-screens/drools-wb-globals-editor/drools-wb-globals-editor-client/src/main/java/org/drools/workbench/screens/globals/client/editor/GlobalsEditorPresenter.java b/drools-wb-screens/drools-wb-globals-editor/drools-wb-globals-editor-client/src/main/java/org/drools/workbench/screens/globals/client/editor/GlobalsEditorPresenter.java index 724365e2486..c42a39931a5 100644 --- a/drools-wb-screens/drools-wb-globals-editor/drools-wb-globals-editor-client/src/main/java/org/drools/workbench/screens/globals/client/editor/GlobalsEditorPresenter.java +++ b/drools-wb-screens/drools-wb-globals-editor/drools-wb-globals-editor-client/src/main/java/org/drools/workbench/screens/globals/client/editor/GlobalsEditorPresenter.java @@ -92,11 +92,11 @@ public void onStartup(final ObservablePath path, protected void makeMenuBar() { if (canUpdateProject()) { fileMenuBuilder - .addSave(versionRecordManager.newSaveMenuItem(this::onSave)) + .addSave(versionRecordManager.newSaveMenuItem(this::saveAction)) .addCopy(versionRecordManager.getCurrentPath(), - fileNameValidator) + assetUpdateValidator) .addRename(versionRecordManager.getPathToLatest(), - fileNameValidator) + assetUpdateValidator) .addDelete(this::onDelete); } @@ -206,12 +206,13 @@ protected void onDelete() { } private void showDeletePopup(final Path path) { - deletePopUpPresenter.show(comment -> { - view.showBusyIndicator(CommonConstants.INSTANCE.Deleting()); - globalsEditorService.call(getDeleteSuccessCallback(), - new HasBusyIndicatorDefaultErrorCallback(view)).delete(path, - "delete"); - }); + deletePopUpPresenter.show(assetUpdateValidator, + comment -> { + view.showBusyIndicator(CommonConstants.INSTANCE.Deleting()); + globalsEditorService.call(getDeleteSuccessCallback(), + new HasBusyIndicatorDefaultErrorCallback(view)).delete(path, + "delete"); + }); } private RemoteCallback getDeleteSuccessCallback() { diff --git a/drools-wb-screens/drools-wb-globals-editor/drools-wb-globals-editor-client/src/test/java/org/drools/workbench/screens/globals/client/editor/GlobalsEditorPresenterTest.java b/drools-wb-screens/drools-wb-globals-editor/drools-wb-globals-editor-client/src/test/java/org/drools/workbench/screens/globals/client/editor/GlobalsEditorPresenterTest.java index 4176fdb96e7..7d877e900d9 100644 --- a/drools-wb-screens/drools-wb-globals-editor/drools-wb-globals-editor-client/src/test/java/org/drools/workbench/screens/globals/client/editor/GlobalsEditorPresenterTest.java +++ b/drools-wb-screens/drools-wb-globals-editor/drools-wb-globals-editor-client/src/test/java/org/drools/workbench/screens/globals/client/editor/GlobalsEditorPresenterTest.java @@ -37,6 +37,7 @@ import org.kie.workbench.common.widgets.client.menu.FileMenuBuilderImpl; import org.kie.workbench.common.widgets.client.popups.validation.ValidationPopup; import org.kie.workbench.common.widgets.metadata.client.KieEditorWrapperView; +import org.kie.workbench.common.widgets.metadata.client.validation.AssetUpdateValidator; import org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter; import org.mockito.InjectMocks; import org.mockito.Mock; @@ -47,7 +48,6 @@ import org.uberfire.ext.editor.commons.client.file.popups.SavePopUpPresenter; import org.uberfire.ext.editor.commons.client.history.VersionRecordManager; import org.uberfire.ext.editor.commons.client.menu.BasicFileMenuBuilder; -import org.uberfire.ext.editor.commons.client.validation.DefaultFileNameValidator; import org.uberfire.mocks.CallerMock; import org.uberfire.mvp.Command; import org.uberfire.mvp.ParameterizedCommand; @@ -99,6 +99,9 @@ public class GlobalsEditorPresenterTest { @Mock private ProjectContext workbenchContext; + @Mock + private AssetUpdateValidator assetUpdateValidator; + private GlobalsEditorPresenter presenter; @Before @@ -117,6 +120,7 @@ public void setUp() { projectController = GlobalsEditorPresenterTest.this.projectController; workbenchContext = GlobalsEditorPresenterTest.this.workbenchContext; versionRecordManager = GlobalsEditorPresenterTest.this.versionRecordManager; + assetUpdateValidator = GlobalsEditorPresenterTest.this.assetUpdateValidator; } }; } @@ -190,7 +194,8 @@ public void deleteNoValidationErrors() { verify(validationService, times(1)).validateForDelete(any(Path.class)); verify(deletePopUpPresenter, - times(1)).show(any(ParameterizedCommand.class)); + times(1)).show(eq(assetUpdateValidator), + any(ParameterizedCommand.class)); } @Test @@ -216,9 +221,9 @@ public void testMakeMenuBar() { verify(fileMenuBuilder).addSave(any(MenuItem.class)); verify(fileMenuBuilder).addCopy(any(Path.class), - any(DefaultFileNameValidator.class)); + any(AssetUpdateValidator.class)); verify(fileMenuBuilder).addRename(any(Path.class), - any(DefaultFileNameValidator.class)); + any(AssetUpdateValidator.class)); verify(fileMenuBuilder).addDelete(any(Command.class)); } @@ -233,10 +238,10 @@ public void testMakeMenuBarWithoutUpdateProjectPermission() { never()).addSave(any(MenuItem.class)); verify(fileMenuBuilder, never()).addCopy(any(Path.class), - any(DefaultFileNameValidator.class)); + any(AssetUpdateValidator.class)); verify(fileMenuBuilder, never()).addRename(any(Path.class), - any(DefaultFileNameValidator.class)); + any(AssetUpdateValidator.class)); verify(fileMenuBuilder, never()).addDelete(any(Command.class)); } diff --git a/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/editor/BaseGuidedDecisionTableEditorPresenter.java b/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/editor/BaseGuidedDecisionTableEditorPresenter.java index bbc42e886dd..99299474e11 100644 --- a/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/editor/BaseGuidedDecisionTableEditorPresenter.java +++ b/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/editor/BaseGuidedDecisionTableEditorPresenter.java @@ -49,6 +49,7 @@ import org.kie.workbench.common.widgets.metadata.client.KieMultipleDocumentEditor; import org.kie.workbench.common.widgets.metadata.client.KieMultipleDocumentEditorWrapperView; import org.kie.workbench.common.widgets.metadata.client.menu.RegisteredDocumentsMenuBuilder; +import org.kie.workbench.common.widgets.metadata.client.validation.AssetUpdateValidator; import org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter; import org.uberfire.backend.vfs.ObservablePath; import org.uberfire.client.mvp.PlaceManager; @@ -78,7 +79,6 @@ public interface View extends RequiresResize, protected View view; protected Caller service; - protected Event notification; protected Event decisionTableSelectedEvent; protected ValidationPopup validationPopup; protected ClientResourceType resourceType; @@ -200,6 +200,12 @@ protected void setFileNameValidator(final DefaultFileNameValidator fileNameValid super.setFileNameValidator(fileNameValidator); } + @Override + //Delegated to expose package-protected setter for Unit Tests + protected void setAssetUpdateValidator(final AssetUpdateValidator assetUpdateValidator) { + super.setAssetUpdateValidator(assetUpdateValidator); + } + protected void init() { viewMenuBuilder.setModeller(modeller); insertMenuBuilder.setModeller(modeller); diff --git a/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableEditorPresenter.java b/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableEditorPresenter.java index 0db059ed5a3..887f352edc5 100644 --- a/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableEditorPresenter.java +++ b/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableEditorPresenter.java @@ -193,10 +193,11 @@ public void makeMenuBar() { fileMenuBuilder .addSave(getSaveMenuItem()) .addCopy(() -> getActiveDocument().getCurrentPath(), - fileNameValidator) + assetUpdateValidator) .addRename(() -> getActiveDocument().getLatestPath(), - fileNameValidator) - .addDelete(() -> getActiveDocument().getLatestPath()); + assetUpdateValidator) + .addDelete(() -> getActiveDocument().getLatestPath(), + assetUpdateValidator); } this.menus = fileMenuBuilder diff --git a/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableGraphEditorPresenter.java b/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableGraphEditorPresenter.java index d577f075172..f92aa29ab88 100644 --- a/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableGraphEditorPresenter.java +++ b/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableGraphEditorPresenter.java @@ -21,7 +21,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; - import javax.annotation.PostConstruct; import javax.enterprise.context.Dependent; import javax.enterprise.event.Event; @@ -37,8 +36,8 @@ import org.drools.workbench.screens.guided.dtable.client.editor.menu.ViewMenuBuilder; import org.drools.workbench.screens.guided.dtable.client.type.GuidedDTableGraphResourceType; import org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableModellerView; -import org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter.Access; import org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter; +import org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter.Access; import org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView; import org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent; import org.drools.workbench.screens.guided.dtable.client.wizard.NewGuidedDecisionTableWizardHelper; @@ -367,10 +366,11 @@ public void makeMenuBar() { fileMenuBuilder .addSave(getSaveMenuItem()) .addCopy(versionRecordManager::getCurrentPath, - fileNameValidator) + assetUpdateValidator) .addRename(versionRecordManager::getPathToLatest, - fileNameValidator) - .addDelete(versionRecordManager::getPathToLatest); + assetUpdateValidator) + .addDelete(versionRecordManager::getPathToLatest, + assetUpdateValidator); } this.menus = fileMenuBuilder diff --git a/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/test/java/org/drools/workbench/screens/guided/dtable/client/editor/BaseGuidedDecisionTablePresenterTest.java b/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/test/java/org/drools/workbench/screens/guided/dtable/client/editor/BaseGuidedDecisionTablePresenterTest.java index da67556dfa4..ed5f34a3ecc 100644 --- a/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/test/java/org/drools/workbench/screens/guided/dtable/client/editor/BaseGuidedDecisionTablePresenterTest.java +++ b/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/test/java/org/drools/workbench/screens/guided/dtable/client/editor/BaseGuidedDecisionTablePresenterTest.java @@ -49,6 +49,7 @@ import org.kie.workbench.common.widgets.configresource.client.widget.bound.ImportsWidgetPresenter; import org.kie.workbench.common.widgets.metadata.client.KieMultipleDocumentEditorWrapperView; import org.kie.workbench.common.widgets.metadata.client.menu.RegisteredDocumentsMenuBuilder; +import org.kie.workbench.common.widgets.metadata.client.validation.AssetUpdateValidator; import org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter; import org.mockito.ArgumentCaptor; import org.mockito.Captor; @@ -208,6 +209,9 @@ public void fire(final DecisionTableSelectedEvent event) { @Mock protected DefaultFileNameValidator fileNameValidator; + @Mock + protected AssetUpdateValidator assetUpdateValidator; + @Mock protected SyncBeanManager beanManager; @@ -243,6 +247,7 @@ public void setup() { wrapped.setRegisteredDocumentsMenuBuilder(registeredDocumentsMenuBuilder); wrapped.setFileMenuBuilder(fileMenuBuilder); wrapped.setFileNameValidator(fileNameValidator); + wrapped.setAssetUpdateValidator(assetUpdateValidator); this.presenter = spy(wrapped); diff --git a/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/test/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableEditorPresenterTest.java b/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/test/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableEditorPresenterTest.java index 56585a23520..0b14bc359d7 100644 --- a/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/test/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableEditorPresenterTest.java +++ b/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/test/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableEditorPresenterTest.java @@ -71,12 +71,13 @@ public void testSetupMenuBar() { times(1)).addSave(any(MenuItem.class)); verify(fileMenuBuilder, times(1)).addCopy(any(BasicFileMenuBuilder.PathProvider.class), - eq(fileNameValidator)); + eq(assetUpdateValidator)); verify(fileMenuBuilder, times(1)).addRename(any(BasicFileMenuBuilder.PathProvider.class), - eq(fileNameValidator)); + eq(assetUpdateValidator)); verify(fileMenuBuilder, - times(1)).addDelete(any(BasicFileMenuBuilder.PathProvider.class)); + times(1)).addDelete(any(BasicFileMenuBuilder.PathProvider.class), + eq(assetUpdateValidator)); verify(fileMenuBuilder, times(1)).addValidate(any(Command.class)); verify(fileMenuBuilder, @@ -103,12 +104,13 @@ public void testMakeMenuBarWithoutUpdateProjectPermission() { never()).addSave(any(MenuItem.class)); verify(fileMenuBuilder, never()).addCopy(any(BasicFileMenuBuilder.PathProvider.class), - eq(fileNameValidator)); + eq(assetUpdateValidator)); verify(fileMenuBuilder, never()).addRename(any(BasicFileMenuBuilder.PathProvider.class), - eq(fileNameValidator)); + eq(assetUpdateValidator)); verify(fileMenuBuilder, - never()).addDelete(any(BasicFileMenuBuilder.PathProvider.class)); + never()).addDelete(any(BasicFileMenuBuilder.PathProvider.class), + eq(assetUpdateValidator)); } @Test diff --git a/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/test/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableGraphEditorPresenterTest.java b/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/test/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableGraphEditorPresenterTest.java index 0a3ecea7335..8a33fc86971 100644 --- a/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/test/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableGraphEditorPresenterTest.java +++ b/drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/test/java/org/drools/workbench/screens/guided/dtable/client/editor/GuidedDecisionTableGraphEditorPresenterTest.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; - import javax.enterprise.event.Event; import com.google.gwt.core.client.Scheduler; @@ -30,15 +29,15 @@ import com.google.gwtmockito.GwtMockitoTestRunner; import org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52; import org.drools.workbench.screens.guided.dtable.client.type.GuidedDTableGraphResourceType; -import org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter.Access.LockedBy; import org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter; +import org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter.Access.LockedBy; import org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView; import org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent; import org.drools.workbench.screens.guided.dtable.client.wizard.NewGuidedDecisionTableWizardHelper; import org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent; import org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent; -import org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry; import org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel; +import org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry; import org.drools.workbench.screens.guided.dtable.service.GuidedDecisionTableGraphEditorService; import org.guvnor.common.services.project.model.Project; import org.guvnor.common.services.shared.metadata.model.Metadata; @@ -56,8 +55,8 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.uberfire.backend.vfs.ObservablePath.OnConcurrentUpdateEvent; import org.uberfire.backend.vfs.ObservablePath; +import org.uberfire.backend.vfs.ObservablePath.OnConcurrentUpdateEvent; import org.uberfire.backend.vfs.Path; import org.uberfire.backend.vfs.PathFactory; import org.uberfire.backend.vfs.impl.ObservablePathImpl; @@ -308,12 +307,13 @@ public void testSetupMenuBar() { times(1)).addSave(any(MenuItem.class)); verify(fileMenuBuilder, times(1)).addCopy(any(BasicFileMenuBuilder.PathProvider.class), - eq(fileNameValidator)); + eq(assetUpdateValidator)); verify(fileMenuBuilder, times(1)).addRename(any(BasicFileMenuBuilder.PathProvider.class), - eq(fileNameValidator)); + eq(assetUpdateValidator)); verify(fileMenuBuilder, - times(1)).addDelete(any(BasicFileMenuBuilder.PathProvider.class)); + times(1)).addDelete(any(BasicFileMenuBuilder.PathProvider.class), + eq(assetUpdateValidator)); verify(fileMenuBuilder, times(1)).addValidate(any(Command.class)); verify(fileMenuBuilder, @@ -342,12 +342,13 @@ public void testMakeMenuBarWithoutUpdateProjectPermission() { never()).addSave(any(MenuItem.class)); verify(fileMenuBuilder, never()).addCopy(any(BasicFileMenuBuilder.PathProvider.class), - eq(fileNameValidator)); + eq(assetUpdateValidator)); verify(fileMenuBuilder, never()).addRename(any(BasicFileMenuBuilder.PathProvider.class), - eq(fileNameValidator)); + eq(assetUpdateValidator)); verify(fileMenuBuilder, - never()).addDelete(any(BasicFileMenuBuilder.PathProvider.class)); + never()).addDelete(any(BasicFileMenuBuilder.PathProvider.class), + eq(assetUpdateValidator)); } @Test diff --git a/drools-wb-screens/drools-wb-test-scenario-editor/drools-wb-test-scenario-editor-client/src/main/java/org/drools/workbench/screens/testscenario/client/ScenarioEditorPresenter.java b/drools-wb-screens/drools-wb-test-scenario-editor/drools-wb-test-scenario-editor-client/src/main/java/org/drools/workbench/screens/testscenario/client/ScenarioEditorPresenter.java index ffab2b98fdb..a0a96a4f15c 100644 --- a/drools-wb-screens/drools-wb-test-scenario-editor/drools-wb-test-scenario-editor-client/src/main/java/org/drools/workbench/screens/testscenario/client/ScenarioEditorPresenter.java +++ b/drools-wb-screens/drools-wb-test-scenario-editor/drools-wb-test-scenario-editor-client/src/main/java/org/drools/workbench/screens/testscenario/client/ScenarioEditorPresenter.java @@ -223,17 +223,13 @@ public Menus getMenus() { protected void makeMenuBar() { if (canUpdateProject()) { fileMenuBuilder - .addSave(new Command() { - @Override - public void execute() { - onSave(); - } - }) + .addSave(this::saveAction) .addCopy(versionRecordManager.getCurrentPath(), - fileNameValidator) + assetUpdateValidator) .addRename(versionRecordManager.getPathToLatest(), - fileNameValidator) - .addDelete(versionRecordManager.getPathToLatest()); + assetUpdateValidator) + .addDelete(versionRecordManager.getPathToLatest(), + assetUpdateValidator); } fileMenuBuilder diff --git a/drools-wb-screens/drools-wb-test-scenario-editor/drools-wb-test-scenario-editor-client/src/test/java/org/drools/workbench/screens/testscenario/client/ScenarioEditorPresenterTest.java b/drools-wb-screens/drools-wb-test-scenario-editor/drools-wb-test-scenario-editor-client/src/test/java/org/drools/workbench/screens/testscenario/client/ScenarioEditorPresenterTest.java index 2c972fd1c7d..f76c2c863e6 100644 --- a/drools-wb-screens/drools-wb-test-scenario-editor/drools-wb-test-scenario-editor-client/src/test/java/org/drools/workbench/screens/testscenario/client/ScenarioEditorPresenterTest.java +++ b/drools-wb-screens/drools-wb-test-scenario-editor/drools-wb-test-scenario-editor-client/src/test/java/org/drools/workbench/screens/testscenario/client/ScenarioEditorPresenterTest.java @@ -18,7 +18,6 @@ import java.lang.annotation.Annotation; import java.util.Collections; - import javax.enterprise.event.Event; import com.google.gwtmockito.GwtMockitoTestRunner; @@ -46,6 +45,7 @@ import org.kie.workbench.common.widgets.client.menu.FileMenuBuilderImpl; import org.kie.workbench.common.widgets.configresource.client.widget.bound.ImportsWidgetPresenter; import org.kie.workbench.common.widgets.metadata.client.KieEditorWrapperView; +import org.kie.workbench.common.widgets.metadata.client.validation.AssetUpdateValidator; import org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter; import org.mockito.ArgumentCaptor; import org.mockito.Captor; @@ -59,7 +59,6 @@ import org.uberfire.ext.editor.commons.client.history.VersionRecordManager; import org.uberfire.ext.editor.commons.client.menu.BasicFileMenuBuilder; import org.uberfire.ext.editor.commons.client.resources.i18n.CommonConstants; -import org.uberfire.ext.editor.commons.client.validation.DefaultFileNameValidator; import org.uberfire.mocks.CallerMock; import org.uberfire.mvp.Command; import org.uberfire.mvp.PlaceRequest; @@ -312,10 +311,11 @@ public void testMakeMenuBar() { verify(fileMenuBuilder).addSave(any(Command.class)); verify(fileMenuBuilder).addCopy(any(Path.class), - any(DefaultFileNameValidator.class)); + any(AssetUpdateValidator.class)); verify(fileMenuBuilder).addRename(any(Path.class), - any(DefaultFileNameValidator.class)); - verify(fileMenuBuilder).addDelete(any(Path.class)); + any(AssetUpdateValidator.class)); + verify(fileMenuBuilder).addDelete(any(Path.class), + any(AssetUpdateValidator.class)); } @Test @@ -329,12 +329,13 @@ public void testMakeMenuBarWithoutUpdateProjectPermission() { never()).addSave(any(Command.class)); verify(fileMenuBuilder, never()).addCopy(any(Path.class), - any(DefaultFileNameValidator.class)); + any(AssetUpdateValidator.class)); verify(fileMenuBuilder, never()).addRename(any(Path.class), - any(DefaultFileNameValidator.class)); + any(AssetUpdateValidator.class)); verify(fileMenuBuilder, - never()).addDelete(any(Path.class)); + never()).addDelete(any(Path.class), + any(AssetUpdateValidator.class)); } private Event makeNotificationEvent() {