diff --git a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-client/src/main/java/org/drools/workbench/screens/scenariosimulation/client/editor/ScenarioSimulationEditorPresenter.java b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-client/src/main/java/org/drools/workbench/screens/scenariosimulation/client/editor/ScenarioSimulationEditorPresenter.java index 1a8ae1db389..0e50c61f931 100644 --- a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-client/src/main/java/org/drools/workbench/screens/scenariosimulation/client/editor/ScenarioSimulationEditorPresenter.java +++ b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-client/src/main/java/org/drools/workbench/screens/scenariosimulation/client/editor/ScenarioSimulationEditorPresenter.java @@ -156,13 +156,12 @@ public void onClose() { scenarioBackgroundGridWidget.unregister(); } - public void showDocks() { + public void initializeDocks() { abstractScenarioSimulationDocksHandler.addDocks(); abstractScenarioSimulationDocksHandler.setScesimEditorId(String.valueOf(scenarioPresenterId)); expandToolsDock(); registerTestToolsCallback(); resetDocks(); - populateRightDocks(TestToolsPresenter.IDENTIFIER); } public void hideDocks() { @@ -519,6 +518,7 @@ public void getModelSuccessCallbackMethod(DataManagementStrategy dataManagementS scenarioMainGridWidget.setContent(model.getSimulation(), model.getSettings().getType()); scenarioBackgroundGridWidget.setContent(model.getBackground(), model.getSettings().getType()); // NOTE: keep here initialization of docks related with model + initializeDocks(); populateRightDocks(TestToolsPresenter.IDENTIFIER); populateRightDocks(SettingsPresenter.IDENTIFIER); CustomBusyPopup.close(); diff --git a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-client/src/main/resources/org/drools/workbench/screens/scenariosimulation/client/resources/i18n/ScenarioSimulationEditorConstants.properties b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-client/src/main/resources/org/drools/workbench/screens/scenariosimulation/client/resources/i18n/ScenarioSimulationEditorConstants.properties index 22c94438881..f3ddd773d19 100644 --- a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-client/src/main/resources/org/drools/workbench/screens/scenariosimulation/client/resources/i18n/ScenarioSimulationEditorConstants.properties +++ b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-client/src/main/resources/org/drools/workbench/screens/scenariosimulation/client/resources/i18n/ScenarioSimulationEditorConstants.properties @@ -145,7 +145,7 @@ settings=Settings name=Name type=Type dmnPathErrorLabel=Impossible to find ''{0}'' file. Please select one. -dmnPathErrorDetailedLabel=Referred DMN file ''{0}'' is invalid or not present. Please provide a valid DMN file and update Settings dock in the right. Message: ''{1}'' +dmnPathErrorDetailedLabel=ACTION REQUIRED: Referred DMN file ''{0}'' is no longer valid. Please provide a valid DMN file and update the DMN model in the Settings dock. Message: ''{1}'' missingSelectedType=Missing selected type missingDmnPath=Missing DMN path coverageReport=Coverage Report diff --git a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-client/src/test/java/org/drools/workbench/screens/scenariosimulation/client/editor/ScenarioSimulationEditorPresenterTest.java b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-client/src/test/java/org/drools/workbench/screens/scenariosimulation/client/editor/ScenarioSimulationEditorPresenterTest.java index 37918b4892a..615409dbe14 100644 --- a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-client/src/test/java/org/drools/workbench/screens/scenariosimulation/client/editor/ScenarioSimulationEditorPresenterTest.java +++ b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-client/src/test/java/org/drools/workbench/screens/scenariosimulation/client/editor/ScenarioSimulationEditorPresenterTest.java @@ -192,24 +192,22 @@ public void onClose() { } @Test - public void showDocks_PlaceStatusOpen() { - presenterSpy.showDocks(); + public void initializeDocks_PlaceStatusOpen() { + presenterSpy.initializeDocks(); verify(abstractScenarioSimulationDocksHandlerMock, times(1)).addDocks(); verify(abstractScenarioSimulationDocksHandlerMock, times(1)).setScesimEditorId(String.valueOf(presenterSpy.scenarioPresenterId)); verify(presenterSpy, times(1)).registerTestToolsCallback(); verify(presenterSpy, times(1)).resetDocks(); - verify(presenterSpy, times(1)).populateRightDocks(TestToolsPresenter.IDENTIFIER); } @Test - public void showDocks_PlaceStatusClose() { - presenterSpy.showDocks(); + public void initializeDocks_PlaceStatusClose() { + presenterSpy.initializeDocks(); verify(abstractScenarioSimulationDocksHandlerMock, times(1)).addDocks(); verify(abstractScenarioSimulationDocksHandlerMock, times(1)).setScesimEditorId(String.valueOf(presenterSpy.scenarioPresenterId)); verify(presenterSpy, times(1)).expandToolsDock(); verify(presenterSpy, times(1)).registerTestToolsCallback(); verify(presenterSpy, times(1)).resetDocks(); - verify(presenterSpy, times(1)).populateRightDocks(TestToolsPresenter.IDENTIFIER); } @Test @@ -536,6 +534,7 @@ public void populateRightDocksEmptyDataStrategy() { public void getModelSuccessCallbackMethod() { scenarioGridWidgetSpy.selectAndFocus(); presenterSpy.getModelSuccessCallbackMethod(dataManagementStrategyMock, modelLocal); + verify(presenterSpy, times(1)).initializeDocks(); verify(presenterSpy, times(1)).populateRightDocks(TestToolsPresenter.IDENTIFIER); verify(presenterSpy, times(1)).populateRightDocks(SettingsPresenter.IDENTIFIER); verify(scenarioGridWidgetSpy, times(1)).setContent(modelLocal.getSimulation(), settingsLocal.getType()); diff --git a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/main/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/ScenarioSimulationEditorKogitoWrapper.java b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/main/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/ScenarioSimulationEditorKogitoWrapper.java index 207795e9b64..6e8d7e77e6a 100644 --- a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/main/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/ScenarioSimulationEditorKogitoWrapper.java +++ b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/main/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/ScenarioSimulationEditorKogitoWrapper.java @@ -215,7 +215,6 @@ private void setErrorPage(final String errorMessage) { private void ensureScenarioGridIsSet() { scenarioSimulationEditorPresenter.getView().setScenarioGridWidgetAsContent(); - scenarioSimulationEditorPresenter.showDocks(); scenarioSimulationEditorPresenter.getView().setScenarioTabBarVisibility(true); } @@ -418,9 +417,9 @@ protected void onModelSuccessCallbackMethod(ScenarioSimulationModel model) { false); dataManagementStrategy = new KogitoDMODataManagementStrategy(kogitoOracle); } else { - dataManagementStrategy = new KogitoDMNDataManagementStrategy(scenarioSimulationEditorPresenter.getEventBus(), - dmnDataManager, - scenarioSimulationKogitoDMNMarshallerService); + dataManagementStrategy = new KogitoDMNDataManagementStrategy(dmnDataManager, + scenarioSimulationKogitoDMNMarshallerService, + scenarioSimulationEditorPresenter); } dataManagementStrategy.setModel(model); scenarioSimulationEditorPresenter.getModelSuccessCallbackMethod(dataManagementStrategy, model); diff --git a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/main/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/strategies/KogitoDMNDataManagementStrategy.java b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/main/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/strategies/KogitoDMNDataManagementStrategy.java index 9e7c8d64304..12013294cfd 100644 --- a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/main/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/strategies/KogitoDMNDataManagementStrategy.java +++ b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/main/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/strategies/KogitoDMNDataManagementStrategy.java @@ -19,11 +19,10 @@ package org.drools.workbench.screens.scenariosimulation.kogito.client.editor.strategies; -import com.google.gwt.event.shared.EventBus; import org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext; +import org.drools.workbench.screens.scenariosimulation.client.editor.ScenarioSimulationEditorPresenter; import org.drools.workbench.screens.scenariosimulation.client.editor.strategies.AbstractDMNDataManagementStrategy; import org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget; -import org.drools.workbench.screens.scenariosimulation.client.events.ScenarioNotificationEvent; import org.drools.workbench.screens.scenariosimulation.client.resources.i18n.ScenarioSimulationEditorConstants; import org.drools.workbench.screens.scenariosimulation.client.rightpanel.TestToolsView; import org.drools.workbench.screens.scenariosimulation.kogito.client.dmn.ScenarioSimulationKogitoDMNDataManager; @@ -38,15 +37,18 @@ public class KogitoDMNDataManagementStrategy extends AbstractDMNDataManagementStrategy { - private ScenarioSimulationKogitoDMNDataManager dmnDataManager; - private ScenarioSimulationKogitoDMNMarshallerService dmnMarshallerService; + private final ScenarioSimulationKogitoDMNDataManager dmnDataManager; + private final ScenarioSimulationKogitoDMNMarshallerService dmnMarshallerService; + private final ScenarioSimulationEditorPresenter scenarioSimulationEditorPresenter; - public KogitoDMNDataManagementStrategy(EventBus eventBus, - ScenarioSimulationKogitoDMNDataManager dmnDataManager, - ScenarioSimulationKogitoDMNMarshallerService dmnMarshallerService) { - super(eventBus); + + public KogitoDMNDataManagementStrategy(ScenarioSimulationKogitoDMNDataManager dmnDataManager, + ScenarioSimulationKogitoDMNMarshallerService scenarioSimulationKogitoDMNMarshallerService, + ScenarioSimulationEditorPresenter scenarioSimulationEditorPresenter) { + super(scenarioSimulationEditorPresenter.getEventBus()); this.dmnDataManager = dmnDataManager; - this.dmnMarshallerService = dmnMarshallerService; + this.dmnMarshallerService = scenarioSimulationKogitoDMNMarshallerService; + this.scenarioSimulationEditorPresenter = scenarioSimulationEditorPresenter; } @Override @@ -71,10 +73,11 @@ private Callback getDMNContentCallback(final TestToolsView.Prese private ErrorCallback getDMNContentErrorCallback(String dmnFilePath) { return (message, throwable) -> { - eventBus.fireEvent(new ScenarioNotificationEvent(ScenarioSimulationEditorConstants.INSTANCE.dmnPathErrorDetailedLabel(dmnFilePath, - message.toString()), - NotificationEvent.NotificationType.ERROR, - false)); + scenarioSimulationEditorPresenter.sendNotification( + ScenarioSimulationEditorConstants.INSTANCE.dmnPathErrorDetailedLabel(dmnFilePath, message.toString()), + NotificationEvent.NotificationType.ERROR, + false); + scenarioSimulationEditorPresenter.expandSettingsDock(); return false; }; } diff --git a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/test/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/ScenarioSimulationEditorKogitoWrapperTest.java b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/test/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/ScenarioSimulationEditorKogitoWrapperTest.java index 3707cd7a4f3..c3637537054 100644 --- a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/test/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/ScenarioSimulationEditorKogitoWrapperTest.java +++ b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/test/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/ScenarioSimulationEditorKogitoWrapperTest.java @@ -348,7 +348,6 @@ public void getModelSuccessCallbackMethodRule() { verify(scenarioSimulationEditorPresenterMock, times(1)).getModelSuccessCallbackMethod(dataManagementStrategyCaptor.capture(), eq(scenarioSimulationModelMock)); assertTrue(dataManagementStrategyCaptor.getValue() instanceof KogitoDMODataManagementStrategy); verify(scenarioSimulationViewMock, times(1)).setScenarioGridWidgetAsContent(); - verify(scenarioSimulationEditorPresenterMock, times(1)).showDocks(); verify(scenarioSimulationViewMock, times(1)).setScenarioTabBarVisibility(true); } @@ -362,7 +361,6 @@ public void getModelSuccessCallbackMethodDMN() { verify(scenarioSimulationEditorPresenterMock, times(1)).getModelSuccessCallbackMethod(dataManagementStrategyCaptor.capture(), eq(scenarioSimulationModelMock)); assertTrue(dataManagementStrategyCaptor.getValue() instanceof KogitoDMNDataManagementStrategy); verify(scenarioSimulationViewMock, times(1)).setScenarioGridWidgetAsContent(); - verify(scenarioSimulationEditorPresenterMock, times(1)).showDocks(); verify(scenarioSimulationViewMock, times(1)).setScenarioTabBarVisibility(true); } diff --git a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/test/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/strategies/KogitoDMNDataManagementStrategyTest.java b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/test/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/strategies/KogitoDMNDataManagementStrategyTest.java index 28b67f2481a..5da30f77dd2 100644 --- a/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/test/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/strategies/KogitoDMNDataManagementStrategyTest.java +++ b/packages/stunner-editors/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-client/src/test/java/org/drools/workbench/screens/scenariosimulation/kogito/client/editor/strategies/KogitoDMNDataManagementStrategyTest.java @@ -25,8 +25,8 @@ import com.google.gwt.event.shared.EventBus; import com.google.gwtmockito.GwtMockitoTestRunner; import org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext; +import org.drools.workbench.screens.scenariosimulation.client.editor.ScenarioSimulationEditorPresenter; import org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget; -import org.drools.workbench.screens.scenariosimulation.client.events.ScenarioNotificationEvent; import org.drools.workbench.screens.scenariosimulation.client.rightpanel.TestToolsPresenter; import org.drools.workbench.screens.scenariosimulation.kogito.client.dmn.ScenarioSimulationKogitoDMNDataManager; import org.drools.workbench.screens.scenariosimulation.kogito.client.dmn.model.KogitoDMNModel; @@ -46,8 +46,7 @@ import org.uberfire.client.callbacks.Callback; import org.uberfire.workbench.events.NotificationEvent; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; @@ -60,6 +59,8 @@ public class KogitoDMNDataManagementStrategyTest { @Mock private EventBus eventBusMock; @Mock + private ScenarioSimulationEditorPresenter scenarioSimulationEditorPresenterMock; + @Mock private ScenarioSimulationKogitoDMNDataManager kogitoDMNDataManagerMock; @Mock private ScenarioSimulationKogitoDMNMarshallerService dmnMarshallerServiceMock; @@ -79,8 +80,6 @@ public class KogitoDMNDataManagementStrategyTest { private ArgumentCaptor> callbackArgumentCaptor; @Captor private ArgumentCaptor> errorCallbackArgumentCaptor; - @Captor - private ArgumentCaptor scenarioNotificationEventArgumentCaptor; private KogitoDMNModel kogitoDMNModel; private KogitoDMNDataManagementStrategy kogitoDMNDataManagementStrategySpy; @@ -88,13 +87,14 @@ public class KogitoDMNDataManagementStrategyTest { @Before public void setup() { kogitoDMNModel = new KogitoDMNModel(jsitDefinitionsMock, Collections.emptyMap()); - kogitoDMNDataManagementStrategySpy = spy(new KogitoDMNDataManagementStrategy(eventBusMock, kogitoDMNDataManagerMock, dmnMarshallerServiceMock) { + kogitoDMNDataManagementStrategySpy = spy(new KogitoDMNDataManagementStrategy(kogitoDMNDataManagerMock, dmnMarshallerServiceMock, scenarioSimulationEditorPresenterMock) { { this.dmnFilePath = "path/dmnFile.dmn"; } }); when(kogitoDMNDataManagementStrategySpy.getSuccessCallback(testToolsPresenterMock, scenarioSimulationContextMock, gridWidgetMock)).thenReturn(factModelTupleRemoteCallbackMock); when(kogitoDMNDataManagerMock.getFactModelTuple(kogitoDMNModel)).thenReturn(factModelTupleMock); + when(scenarioSimulationEditorPresenterMock.getEventBus()).thenReturn(eventBusMock); } @Test @@ -109,9 +109,8 @@ public void retrieveFactModelTuple() { verify(factModelTupleRemoteCallbackMock, times(1)).callback(factModelTupleMock); errorCallbackArgumentCaptor.getValue().error("Error Message", new Exception()); - verify(eventBusMock, times(1)).fireEvent(scenarioNotificationEventArgumentCaptor.capture()); - assertEquals(NotificationEvent.NotificationType.ERROR, scenarioNotificationEventArgumentCaptor.getValue().getNotificationType()); - assertTrue(scenarioNotificationEventArgumentCaptor.getValue().getMessage().contains("Error Message")); + verify(scenarioSimulationEditorPresenterMock, times(1)).sendNotification(anyString(), eq(NotificationEvent.NotificationType.ERROR), eq(false)); + verify(scenarioSimulationEditorPresenterMock, times(1)).expandSettingsDock(); } }