Search in sources :

Example 6 with GuidedDecisionTableEditorGraphContent

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

the class GuidedDecisionTableGraphEditorServiceImplTest method checkConstructContent.

@Test
public void checkConstructContent() {
    final Path path = mock(Path.class);
    final Overview overview = mock(Overview.class);
    when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix());
    final GuidedDecisionTableEditorGraphContent content = service.constructContent(path, overview);
    verify(resourceOpenedEvent, times(1)).fire(any(ResourceOpenedEvent.class));
    assertNotNull(content.getModel());
    assertEquals(overview, content.getOverview());
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) Overview(org.guvnor.common.services.shared.metadata.model.Overview) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) Test(org.junit.Test)

Example 7 with GuidedDecisionTableEditorGraphContent

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

the class GuidedDecisionTableGraphEditorPresenterTest method checkMayCloseWithDecisionTableGraphEntries.

private void checkMayCloseWithDecisionTableGraphEntries(final int uiModelHashCode, 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(dtPresenter.getOriginalHashCode()).thenReturn(uiModelHashCode);
    doReturn(makeDecisionTableGraphContent(uiModelHashCode).getModel()).when(presenter).buildModelFromEditor();
    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);
    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)

Example 8 with GuidedDecisionTableEditorGraphContent

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

the class GuidedDecisionTableGraphEditorPresenterTest method checkDoSave.

private void checkDoSave(final ParameterizedCommand<OnSaveSetupDataHolder> setup, final Command assertion) {
    final ObservablePath dtGraphPath = mock(ObservablePath.class);
    final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
    when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
    when(dtGraphPath.getFileName()).thenReturn("filename");
    when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
    when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
    setup.execute(new OnSaveSetupDataHolder(dtGraphPath, dtGraphPlaceRequest));
    presenter.doSave();
    assertion.execute();
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) ObservablePath(org.uberfire.backend.vfs.ObservablePath)

Example 9 with GuidedDecisionTableEditorGraphContent

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

the class GuidedDecisionTableGraphEditorPresenterTest method checkSaveDocumentGraphEntries.

@Test
public void checkSaveDocumentGraphEntries() {
    final ObservablePath dtGraphPath = mock(ObservablePath.class);
    final PathPlaceRequest dtGraphPlaceRequest = mock(PathPlaceRequest.class);
    final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
    final ObservablePath dtPath1 = mock(ObservablePath.class);
    final PlaceRequest dtPlaceRequest1 = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent dtContent1 = makeDecisionTableContent();
    final GuidedDecisionTableView.Presenter dtPresenter1 = makeDecisionTable(dtPath1, dtPath1, dtPlaceRequest1, dtContent1);
    final ObservablePath dtPath2 = mock(ObservablePath.class);
    final PlaceRequest dtPlaceRequest2 = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent dtContent2 = makeDecisionTableContent();
    final GuidedDecisionTableView.Presenter dtPresenter2 = makeDecisionTable(dtPath2, dtPath2, dtPlaceRequest2, dtContent2);
    when(dtPath1.toURI()).thenReturn("dtPath1");
    when(dtPath2.toURI()).thenReturn("dtPath2");
    when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
    when(dtGraphPath.getFileName()).thenReturn("filename");
    when(dtService.loadContent(eq(dtPath1))).thenReturn(dtContent1);
    when(dtService.loadContent(eq(dtPath2))).thenReturn(dtContent2);
    when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
    when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
    when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), eq(dtContent1), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter1);
    when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), eq(dtContent2), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter2);
    when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {

        {
            add(dtPresenter1);
            add(dtPresenter2);
        }
    });
    presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
    presenter.saveDocumentGraphEntries();
    verify(savePopUpPresenter, times(1)).show(any(Path.class), commitMessageCommandCaptor.capture());
    final ParameterizedCommand<String> commitMessageCommand = commitMessageCommandCaptor.getValue();
    assertNotNull(commitMessageCommand);
    commitMessageCommand.execute("message");
    verify(view, times(1)).showSaving();
    verify(saveInProgressEvent, times(2)).fire(any(SaveInProgressEvent.class));
    verify(dtGraphService, times(1)).save(eq(dtGraphPath), any(GuidedDecisionTableEditorGraphModel.class), any(Metadata.class), eq("message"));
    verify(dtService, times(1)).save(eq(dtPath2), any(GuidedDecisionTable52.class), any(Metadata.class), eq("message"));
    verify(dtService, times(1)).save(eq(dtPath2), any(GuidedDecisionTable52.class), any(Metadata.class), eq("message"));
    verify(notificationEvent, times(1)).fire(any(NotificationEvent.class));
    verify(dtPresenter1, times(1)).setConcurrentUpdateSessionInfo(eq(null));
    verify(dtPresenter2, times(1)).setConcurrentUpdateSessionInfo(eq(null));
    assertNull(presenter.concurrentUpdateSessionInfo);
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) 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) SaveInProgressEvent(org.uberfire.client.mvp.SaveInProgressEvent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 10 with GuidedDecisionTableEditorGraphContent

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

the class GuidedDecisionTableGraphEditorPresenterTest method checkInitialiseKieEditorTabs.

@Test
public void checkInitialiseKieEditorTabs() {
    final ObservablePath dtGraphPath = mock(ObservablePath.class);
    final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent(0);
    when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
    when(dtGraphPath.getFileName()).thenReturn("filename");
    when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
    when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
    when(versionRecordManager.getVersion()).thenReturn("version");
    presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
    verify(kieEditorWrapperView, times(1)).clear();
    final GuidedDecisionTableView.Presenter document = mock(GuidedDecisionTableView.Presenter.class);
    final AsyncPackageDataModelOracle dmo = mock(AsyncPackageDataModelOracle.class);
    final Imports imports = mock(Imports.class);
    final boolean isReadOnly = true;
    final ArgumentCaptor<com.google.gwt.user.client.Command> onFocusCommandCaptor = ArgumentCaptor.forClass(com.google.gwt.user.client.Command.class);
    presenter.initialiseKieEditorTabs(document, dtGraphContent.getOverview(), dmo, imports, isReadOnly);
    verify(kieEditorWrapperView, times(2)).clear();
    verify(kieEditorWrapperView, times(2)).addMainEditorPage(view);
    verify(kieEditorWrapperView, times(2)).addOverviewPage(eq(overviewWidget), onFocusCommandCaptor.capture());
    verify(overviewWidget, times(2)).setContent(eq(dtGraphContent.getOverview()), any(ObservablePath.class));
    verify(kieEditorWrapperView, times(1)).addSourcePage(any(ViewDRLSourceWidget.class));
    verify(kieEditorWrapperView, times(1)).addImportsTab(eq(importsWidget));
    verify(importsWidget, times(1)).setContent(eq(dmo), eq(imports), eq(isReadOnly));
    final com.google.gwt.user.client.Command onFocusCommand = onFocusCommandCaptor.getValue();
    assertNotNull(onFocusCommand);
    onFocusCommand.execute();
    verify(overviewWidget, times(1)).refresh(eq("version"));
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) Imports(org.kie.soup.project.datamodel.imports.Imports) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ViewDRLSourceWidget(org.kie.workbench.common.widgets.client.source.ViewDRLSourceWidget) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Aggregations

GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)15 ObservablePath (org.uberfire.backend.vfs.ObservablePath)13 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)12 PlaceRequest (org.uberfire.mvp.PlaceRequest)10 Test (org.junit.Test)9 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)7 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)6 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)5 GuidedDecisionTableGraphEntry (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry)5 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)5 GuidedDecisionTableEditorGraphModel (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)4 Path (org.uberfire.backend.vfs.Path)4 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)3 DecisionTableSelectedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)2 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)2 Overview (org.guvnor.common.services.shared.metadata.model.Overview)2 SaveInProgressEvent (org.uberfire.client.mvp.SaveInProgressEvent)2 Command (org.uberfire.mvp.Command)2 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)2 ResourceOpenedEvent (org.uberfire.workbench.events.ResourceOpenedEvent)2