Search in sources :

Example 11 with DecisionTableSelectedEvent

use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent in project drools-wb by kiegroup.

the class RowContextMenuTest method testOnDecisionTableSelectedEventWithSelectionsWithClipboardPopulated.

@Test
public void testOnDecisionTableSelectedEventWithSelectionsWithClipboardPopulated() {
    model.getMetadataCols().add(new MetadataCol52());
    model.getData().add(new ArrayList<DTCellValue52>() {

        {
            add(new DTCellValue52(1));
            add(new DTCellValue52("descr"));
            add(new DTCellValue52("md"));
        }
    });
    uiModel.selectCell(0, 2);
    clipboard.setData(new HashSet<Clipboard.ClipboardData>() {

        {
            add(new DefaultClipboard.ClipboardDataImpl(0, 2, model.getData().get(0).get(2)));
        }
    });
    menu.onDecisionTableSelectedEvent(new DecisionTableSelectedEvent(dtPresenter));
    verify(view, times(1)).enableCutMenuItem(eq(true));
    verify(view, times(1)).enableCopyMenuItem(eq(true));
    verify(view, times(1)).enablePasteMenuItem(eq(true));
    verify(view, times(1)).enableInsertRowAboveMenuItem(eq(true));
    verify(view, times(1)).enableInsertRowBelowMenuItem(eq(true));
    verify(view, times(1)).enableDeleteRowMenuItem(eq(true));
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent) Test(org.junit.Test)

Example 12 with DecisionTableSelectedEvent

use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent in project drools-wb by kiegroup.

the class RowContextMenuTest method testOnDecisionTableSelectedEventWithSelections.

@Test
public void testOnDecisionTableSelectedEventWithSelections() {
    model.getMetadataCols().add(new MetadataCol52());
    model.getData().add(new ArrayList<DTCellValue52>() {

        {
            add(new DTCellValue52(1));
            add(new DTCellValue52("descr"));
            add(new DTCellValue52("md"));
        }
    });
    uiModel.selectCell(0, 2);
    menu.onDecisionTableSelectedEvent(new DecisionTableSelectedEvent(dtPresenter));
    verify(view, times(1)).enableCutMenuItem(eq(true));
    verify(view, times(1)).enableCopyMenuItem(eq(true));
    verify(view, times(1)).enablePasteMenuItem(eq(false));
    verify(view, times(1)).enableInsertRowAboveMenuItem(eq(true));
    verify(view, times(1)).enableInsertRowBelowMenuItem(eq(true));
    verify(view, times(1)).enableDeleteRowMenuItem(eq(true));
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent) Test(org.junit.Test)

Example 13 with DecisionTableSelectedEvent

use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenterTest method checkOpenOtherDecisionTableIsLastDecisionTable.

@Test
public void checkOpenOtherDecisionTableIsLastDecisionTable() {
    when(modeller.getAvailableDecisionTables()).thenReturn(Collections.emptySet());
    presenter.openOtherDecisionTable();
    verify(presenter, never()).activateDocument(any(GuidedDecisionTableView.Presenter.class));
    verify(placeManager, never()).forceClosePlace(any(String.class));
    verify(placeManager, never()).forceClosePlace(any(PlaceRequest.class));
    verify(decisionTableSelectedEvent, times(1)).fire(dtSelectedEventCaptor.capture());
    final DecisionTableSelectedEvent dtSelectedEvent = dtSelectedEventCaptor.getValue();
    assertNotNull(dtSelectedEvent);
    assertFalse(dtSelectedEvent.getPresenter().isPresent());
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent) Test(org.junit.Test)

Example 14 with DecisionTableSelectedEvent

use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent 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 15 with DecisionTableSelectedEvent

use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenterTest method checkDecisionTableSelectedEventFiredWhenEditorReceivesFocusWithActiveDecisionTable.

@Test
public void checkDecisionTableSelectedEventFiredWhenEditorReceivesFocusWithActiveDecisionTable() {
    final GuidedDecisionTableView.Presenter activeDtable = mock(GuidedDecisionTableView.Presenter.class);
    when(modeller.getActiveDecisionTable()).thenReturn(Optional.of(activeDtable));
    presenter.onFocus();
    verify(activeDtable, times(1)).initialiseAnalysis();
    verify(decisionTableSelectedEvent, times(1)).fire(dtSelectedEventCaptor.capture());
    final DecisionTableSelectedEvent event = dtSelectedEventCaptor.getValue();
    assertNotNull(event);
    assertTrue(event.getPresenter().isPresent());
    assertEquals(activeDtable, event.getPresenter().get());
}
Also used : GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent) Test(org.junit.Test)

Aggregations

DecisionTableSelectedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)58 Test (org.junit.Test)54 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)14 ObservablePath (org.uberfire.backend.vfs.ObservablePath)10 PlaceRequest (org.uberfire.mvp.PlaceRequest)10 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)9 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)9 MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)7 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)5 GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)2 GuidedDecisionTableGraphEntry (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry)2 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)2 Matchers.anyBoolean (org.mockito.Matchers.anyBoolean)2 MultiPageEditor (org.uberfire.client.workbench.widgets.multipage.MultiPageEditor)2 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)2 PostConstruct (javax.annotation.PostConstruct)1 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)1 Overview (org.guvnor.common.services.shared.metadata.model.Overview)1 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)1 ImportsWidgetPresenter (org.kie.workbench.common.widgets.configresource.client.widget.bound.ImportsWidgetPresenter)1