Search in sources :

Example 16 with GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method checkReload.

@Test
public void checkReload() {
    final ObservablePath dtGraphPath = mock(ObservablePath.class);
    final PathPlaceRequest dtGraphPlaceRequest = mock(PathPlaceRequest.class);
    final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
    final ObservablePath dtPath = mock(ObservablePath.class);
    final PlaceRequest dtPlaceRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent(0);
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(dtPath, dtPath, dtPlaceRequest, dtContent);
    final GuidedDecisionTableGraphEntry dtGraphEntry = new GuidedDecisionTableGraphEntry(dtPath, dtPath);
    dtGraphContent.getModel().getEntries().add(dtGraphEntry);
    when(dtPath.toURI()).thenReturn("dtPath");
    when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
    when(dtGraphPath.getFileName()).thenReturn("filename");
    when(dtService.loadContent(eq(dtPath))).thenReturn(dtContent);
    when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
    when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
    when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), any(GuidedDecisionTableEditorContent.class), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter);
    when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {

        {
            add(dtPresenter);
        }
    });
    presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
    verify(presenter, times(1)).loadDocumentGraph(dtGraphPath);
    presenter.reload();
    verify(presenter, times(1)).deregisterDocument(eq(dtPresenter));
    verify(presenter, times(2)).loadDocumentGraph(dtGraphPath);
    verify(modeller, times(1)).releaseDecisionTables();
    verify(modellerView, times(1)).clear();
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) OverviewWidgetPresenter(org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) GuidedDecisionTableGraphEntry(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 17 with GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method checkOnDecisionTableSelected.

private void checkOnDecisionTableSelected(final ParameterizedCommand<PlaceRequest> setup, final Command assertion) {
    final ObservablePath dtGraphPath = mock(ObservablePath.class);
    final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
    final ObservablePath dtPath = mock(ObservablePath.class);
    final PlaceRequest dtPlaceRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent(0);
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(dtPath, dtPath, dtPlaceRequest, dtContent);
    final GuidedDecisionTableGraphEntry dtGraphEntry = new GuidedDecisionTableGraphEntry(dtPath, dtPath);
    dtGraphContent.getModel().getEntries().add(dtGraphEntry);
    when(dtPath.toURI()).thenReturn("dtPath");
    when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
    when(dtGraphPath.getFileName()).thenReturn("filename");
    when(dtService.loadContent(eq(dtPath))).thenReturn(dtContent);
    when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
    when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
    when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), any(GuidedDecisionTableEditorContent.class), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter);
    when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {

        {
            add(dtPresenter);
        }
    });
    setup.execute(dtGraphPlaceRequest);
    presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
    final DecisionTableSelectedEvent event = new DecisionTableSelectedEvent(dtPresenter);
    presenter.onDecisionTableSelected(event);
    assertion.execute();
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) OverviewWidgetPresenter(org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) GuidedDecisionTableGraphEntry(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry) ObservablePath(org.uberfire.backend.vfs.ObservablePath) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)

Example 18 with GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerPresenterTest method refreshDecisionTable.

@Test
public void refreshDecisionTable() {
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable();
    final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent();
    final GuidedDecisionTableView dtView = dtPresenter.getView();
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    final ArgumentCaptor<Command> afterRemovalCommandCaptor = ArgumentCaptor.forClass(Command.class);
    presenter.refreshDecisionTable(dtPresenter, path, placeRequest, dtContent, false);
    verify(view, times(1)).removeDecisionTable(eq(dtView), afterRemovalCommandCaptor.capture());
    final Command afterRemovalCommand = afterRemovalCommandCaptor.getValue();
    assertNotNull(afterRemovalCommand);
    afterRemovalCommand.execute();
    verify(view, times(1)).addDecisionTable(eq(dtView));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) Command(com.google.gwt.user.client.Command) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 19 with GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerPresenterTest method addDecisionTable.

@Test
public void addDecisionTable() {
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent();
    presenter.addDecisionTable(path, placeRequest, dtContent, false, null, null);
    verify(presenter, times(1)).updateLinks();
    verify(gridLayer, times(1)).refreshGridWidgetConnectors();
    verify(view, times(1)).addDecisionTable(eq(dtableView));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 20 with GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenter method getRefreshContentSuccessCallback.

private RemoteCallback<GuidedDecisionTableEditorContent> getRefreshContentSuccessCallback(final GuidedDecisionTableView.Presenter dtPresenter) {
    final ObservablePath path = dtPresenter.getLatestPath();
    final PlaceRequest place = dtPresenter.getPlaceRequest();
    final boolean isReadOnly = dtPresenter.isReadOnly();
    return (content) -> {
        // Refresh Decision Table in modeller
        modeller.refreshDecisionTable(dtPresenter, path, place, content, isReadOnly);
        activateDocument(dtPresenter);
        view.hideBusyIndicator();
    };
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTableEditorService(org.drools.workbench.screens.guided.dtable.service.GuidedDecisionTableEditorService) AlertsButtonMenuItemBuilder(org.guvnor.messageconsole.client.console.widget.button.AlertsButtonMenuItemBuilder) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) GuidedDecisionTableModellerView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableModellerView) ChangeTitleWidgetEvent(org.uberfire.client.workbench.events.ChangeTitleWidgetEvent) ClientResourceType(org.uberfire.client.workbench.type.ClientResourceType) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) KieEditorView(org.kie.workbench.common.widgets.metadata.client.KieEditorView) UpdatedLockStatusEvent(org.uberfire.client.mvp.UpdatedLockStatusEvent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) IsWidget(com.google.gwt.user.client.ui.IsWidget) Set(java.util.Set) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) MultiPageEditor(org.uberfire.client.workbench.widgets.multipage.MultiPageEditor) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) RegisteredDocumentsMenuBuilder(org.kie.workbench.common.widgets.metadata.client.menu.RegisteredDocumentsMenuBuilder) PlaceRequest(org.uberfire.mvp.PlaceRequest) List(java.util.List) RadarMenuBuilder(org.drools.workbench.screens.guided.dtable.client.editor.menu.RadarMenuBuilder) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Caller(org.jboss.errai.common.client.api.Caller) Optional(java.util.Optional) AssetUpdateValidator(org.kie.workbench.common.widgets.metadata.client.validation.AssetUpdateValidator) ProvidesResize(com.google.gwt.user.client.ui.ProvidesResize) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) SavePopUpPresenter(org.uberfire.ext.editor.commons.client.file.popups.SavePopUpPresenter) RequiresResize(com.google.gwt.user.client.ui.RequiresResize) PlaceManager(org.uberfire.client.mvp.PlaceManager) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) MenuItems(org.uberfire.ext.editor.commons.client.menu.MenuItems) ViewMenuBuilder(org.drools.workbench.screens.guided.dtable.client.editor.menu.ViewMenuBuilder) EditMenuBuilder(org.drools.workbench.screens.guided.dtable.client.editor.menu.EditMenuBuilder) MenuItem(org.uberfire.workbench.model.menu.MenuItem) Page(org.uberfire.client.workbench.widgets.multipage.Page) CommonConstants(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) Event(javax.enterprise.event.Event) ColumnsPage(org.drools.workbench.screens.guided.dtable.client.editor.page.ColumnsPage) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) OverviewWidgetPresenter(org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter) VersionRecordManager(org.uberfire.ext.editor.commons.client.history.VersionRecordManager) ValidationPopup(org.kie.workbench.common.widgets.client.popups.validation.ValidationPopup) KieMultipleDocumentEditorWrapperView(org.kie.workbench.common.widgets.metadata.client.KieMultipleDocumentEditorWrapperView) ImportsWidgetPresenter(org.kie.workbench.common.widgets.configresource.client.widget.bound.ImportsWidgetPresenter) FileMenuBuilder(org.kie.workbench.common.widgets.client.menu.FileMenuBuilder) KieMultipleDocumentEditor(org.kie.workbench.common.widgets.metadata.client.KieMultipleDocumentEditor) InsertMenuBuilder(org.drools.workbench.screens.guided.dtable.client.editor.menu.InsertMenuBuilder) SyncBeanManager(org.jboss.errai.ioc.client.container.SyncBeanManager) DefaultFileNameValidator(org.uberfire.ext.editor.commons.client.validation.DefaultFileNameValidator) ObservablePath(org.uberfire.backend.vfs.ObservablePath)

Aggregations

GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)33 ObservablePath (org.uberfire.backend.vfs.ObservablePath)28 PlaceRequest (org.uberfire.mvp.PlaceRequest)27 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)24 Test (org.junit.Test)24 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)12 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)12 DecisionTableSelectedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)10 Path (org.uberfire.backend.vfs.Path)9 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)8 Overview (org.guvnor.common.services.shared.metadata.model.Overview)7 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)7 GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)6 PortableWorkDefinition (org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition)5 GuidedDecisionTableGraphEntry (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry)5 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)4 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Set (java.util.Set)3