Search in sources :

Example 11 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenterTest method checkMayCloseWithCleanDecisionTable.

@Test
public void checkMayCloseWithCleanDecisionTable() {
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent content = makeDecisionTableContent();
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(path, path, placeRequest, content);
    when(dtPresenter.getOriginalHashCode()).thenReturn(0);
    when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {

        {
            add(dtPresenter);
        }
    });
    assertTrue(presenter.mayClose());
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 12 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenterTest method checkOnDecisionTableSelectedWhenAvailableSelected.

@Test
public void checkOnDecisionTableSelectedWhenAvailableSelected() {
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent content = makeDecisionTableContent();
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(path, path, placeRequest, content);
    final DecisionTableSelectedEvent event = new DecisionTableSelectedEvent(dtPresenter);
    when(modeller.isDecisionTableAvailable(any(GuidedDecisionTableView.Presenter.class))).thenReturn(true);
    when(presenter.getActiveDocument()).thenReturn(dtPresenter);
    presenter.onDecisionTableSelected(event);
    verify(presenter, never()).activateDocument(any(GuidedDecisionTableView.Presenter.class));
    assertTrue(getMenuState(presenter.getMenus(), MenuItems.VALIDATE));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent) Test(org.junit.Test)

Example 13 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenterTest method checkOnDecisionTableSelectedWhenNotAvailable.

@Test
public void checkOnDecisionTableSelectedWhenNotAvailable() {
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent content = makeDecisionTableContent();
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(path, path, placeRequest, content);
    final DecisionTableSelectedEvent event = new DecisionTableSelectedEvent(dtPresenter);
    when(modeller.isDecisionTableAvailable(any(GuidedDecisionTableView.Presenter.class))).thenReturn(false);
    presenter.onDecisionTableSelected(event);
    verify(presenter, never()).activateDocument(any(GuidedDecisionTableView.Presenter.class));
    assertTrue(getMenuState(presenter.getMenus(), MenuItems.VALIDATE));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent) Test(org.junit.Test)

Example 14 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenterTest method checkOnDecisionTableSelectedEventReselection.

@Test
public void checkOnDecisionTableSelectedEventReselection() {
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent content = makeDecisionTableContent();
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(path, path, placeRequest, content);
    final DecisionTableSelectedEvent eventSelect = new DecisionTableSelectedEvent(dtPresenter);
    doReturn(true).when(modeller).isDecisionTableAvailable(dtPresenter);
    presenter.onStartup(path, placeRequest);
    presenter.onDecisionTableSelected(eventSelect);
    assertEquals(dtPresenter, presenter.getActiveDocument());
    final DecisionTableSelectedEvent eventDeselect = DecisionTableSelectedEvent.NONE;
    presenter.onDecisionTableSelected(eventDeselect);
    assertNull(presenter.getActiveDocument());
    presenter.onDecisionTableSelected(eventSelect);
    assertEquals(dtPresenter, presenter.getActiveDocument());
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent) Test(org.junit.Test)

Example 15 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenterTest method checkOnSourceTabSelected.

@Test
public void checkOnSourceTabSelected() {
    final String source = "source";
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent content = makeDecisionTableContent();
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(path, path, placeRequest, content);
    when(dtService.toSource(eq(path), any(GuidedDecisionTable52.class))).thenReturn(source);
    presenter.onSourceTabSelected(dtPresenter);
    final ArgumentCaptor<GuidedDecisionTable52> modelCaptor = ArgumentCaptor.forClass(GuidedDecisionTable52.class);
    verify(dtService, times(1)).toSource(eq(path), modelCaptor.capture());
    assertNotNull(modelCaptor.getValue());
    assertEquals(dtPresenter.getModel(), modelCaptor.getValue());
    verify(presenter, times(1)).updateSource(eq(source));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Aggregations

ObservablePath (org.uberfire.backend.vfs.ObservablePath)51 Test (org.junit.Test)38 PlaceRequest (org.uberfire.mvp.PlaceRequest)33 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)29 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)27 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)15 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)13 GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)13 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)11 DecisionTableSelectedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)11 Path (org.uberfire.backend.vfs.Path)9 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)7 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)7 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)6 GuidedDecisionTableGraphEntry (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry)5 GuidedDecisionTableEditorGraphModel (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)4 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)4 List (java.util.List)3 Overview (org.guvnor.common.services.shared.metadata.model.Overview)3 ValidationMessage (org.guvnor.common.services.shared.validation.model.ValidationMessage)3