Search in sources :

Example 21 with GuidedDecisionTableEditorContent

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

the class BaseGuidedDecisionTablePresenterTest method makeDecisionTableContent.

protected GuidedDecisionTableEditorContent makeDecisionTableContent(final int hashCode) {
    final GuidedDecisionTable52 model = new GuidedDecisionTable52() {

        @Override
        public int hashCode() {
            return hashCode;
        }

        @Override
        public boolean equals(Object o) {
            return super.equals(o);
        }
    };
    final Overview overview = mock(Overview.class);
    final Metadata metadata = mock(Metadata.class);
    when(overview.getMetadata()).thenReturn(metadata);
    return new GuidedDecisionTableEditorContent(model, Collections.<PortableWorkDefinition>emptySet(), overview, mock(PackageDataModelOracleBaselinePayload.class));
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) Overview(org.guvnor.common.services.shared.metadata.model.Overview)

Example 22 with GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent 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 23 with GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent 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 GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent 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 GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent 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

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