Search in sources :

Example 21 with PlaceRequest

use of org.uberfire.mvp.PlaceRequest in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorPresenterTest method startUpSelectsDecisionTable.

@Test
public void startUpSelectsDecisionTable() {
    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);
    presenter.onStartup(path, placeRequest);
    verify(decisionTableSelectedEvent, times(1)).fire(dtSelectedEventCaptor.capture());
    final DecisionTableSelectedEvent dtSelectedEvent = dtSelectedEventCaptor.getValue();
    assertNotNull(dtSelectedEvent);
    assertTrue(dtSelectedEvent.getPresenter().isPresent());
    assertEquals(dtPresenter, dtSelectedEvent.getPresenter().get());
    verify(modellerGridPanel).setFocus(eq(true));
}
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 22 with PlaceRequest

use of org.uberfire.mvp.PlaceRequest in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorPresenterTest method checkRemoveDocumentClosesEditor.

@Test
public void checkRemoveDocumentClosesEditor() {
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class);
    presenter.editorPlaceRequest = placeRequest;
    presenter.removeDocument(dtPresenter);
    final ArgumentCaptor<Scheduler.ScheduledCommand> commandCaptor = ArgumentCaptor.forClass(Scheduler.ScheduledCommand.class);
    verify(presenter, times(1)).scheduleClosure(commandCaptor.capture());
    final Scheduler.ScheduledCommand command = commandCaptor.getValue();
    assertNotNull(command);
    command.execute();
    verify(placeManager, times(1)).forceClosePlace(eq(placeRequest));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) Scheduler(com.google.gwt.core.client.Scheduler) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) Test(org.junit.Test)

Example 23 with PlaceRequest

use of org.uberfire.mvp.PlaceRequest in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenterTest method checkMayCloseWithDirtyDecisionTable.

@Test
public void checkMayCloseWithDirtyDecisionTable() {
    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(10);
    when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {

        {
            add(dtPresenter);
        }
    });
    assertFalse(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 24 with PlaceRequest

use of org.uberfire.mvp.PlaceRequest in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenterTest method checkOnValidateWithoutErrors.

@Test
public void checkOnValidateWithoutErrors() {
    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.validate(any(Path.class), any(GuidedDecisionTable52.class))).thenReturn(Collections.emptyList());
    presenter.onValidate(dtPresenter);
    final ArgumentCaptor<GuidedDecisionTable52> modelCaptor = ArgumentCaptor.forClass(GuidedDecisionTable52.class);
    verify(dtService, times(1)).validate(eq(path), modelCaptor.capture());
    assertNotNull(modelCaptor.getValue());
    assertEquals(dtPresenter.getModel(), modelCaptor.getValue());
    verify(notification, times(1)).fire(any(NotificationEvent.class));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 25 with PlaceRequest

use of org.uberfire.mvp.PlaceRequest in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenterTest method checkRefreshDocument.

@Test
public void checkRefreshDocument() {
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent content = makeDecisionTableContent();
    final MultiPageEditor pageEditor = mock(MultiPageEditor.class);
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(path, path, placeRequest, content);
    presenter.onStartup(path, placeRequest);
    verify(view, times(1)).showLoading();
    verify(dtService, times(1)).loadContent(eq(path));
    verify(decisionTableSelectedEvent, times(1)).fire(dtSelectedEventCaptor.capture());
    verify(view, times(1)).hideBusyIndicator();
    final DecisionTableSelectedEvent dtSelectedEvent = dtSelectedEventCaptor.getValue();
    assertNotNull(dtSelectedEvent);
    assertTrue(dtSelectedEvent.getPresenter().isPresent());
    assertEquals(dtPresenter, dtSelectedEvent.getPresenter().get());
    when(dtPresenter.getCurrentPath()).thenReturn(path);
    when(presenter.getKieEditorWrapperMultiPage()).thenReturn(pageEditor);
    presenter.refreshDocument(dtPresenter);
    verify(view, times(2)).showLoading();
    verify(dtService, times(2)).loadContent(eq(path));
    verify(modeller, times(1)).refreshDecisionTable(eq(dtPresenter), eq(path), eq(placeRequest), eq(content), any(Boolean.class));
    verify(presenter, times(1)).activateDocument(eq(dtPresenter));
    verify(view, times(2)).hideBusyIndicator();
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) MultiPageEditor(org.uberfire.client.workbench.widgets.multipage.MultiPageEditor) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) Matchers.anyBoolean(org.mockito.Matchers.anyBoolean) ObservablePath(org.uberfire.backend.vfs.ObservablePath) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent) Test(org.junit.Test)

Aggregations

PlaceRequest (org.uberfire.mvp.PlaceRequest)36 ObservablePath (org.uberfire.backend.vfs.ObservablePath)33 Test (org.junit.Test)29 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)26 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)25 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)13 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 GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)10 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)7 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)6 Path (org.uberfire.backend.vfs.Path)6 GuidedDecisionTableGraphEntry (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry)5 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)4 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)4 MultiPageEditor (org.uberfire.client.workbench.widgets.multipage.MultiPageEditor)3 Scheduler (com.google.gwt.core.client.Scheduler)2 Command (com.google.gwt.user.client.Command)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2