Search in sources :

Example 1 with GuidedDecisionTableEditorGraphContent

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

the class GuidedDecisionTableGraphEditorPresenterTest method testLoadDocumentGraphEmptyModel.

@Test
public void testLoadDocumentGraphEmptyModel() throws Exception {
    final ObservablePath documentPath = mock(ObservablePath.class);
    final Overview overview = mock(Overview.class);
    final GuidedDecisionTableEditorGraphModel graphModel = mock(GuidedDecisionTableEditorGraphModel.class);
    final GuidedDecisionTableEditorGraphContent graphContent = mock(GuidedDecisionTableEditorGraphContent.class);
    when(documentPath.getFileName()).thenReturn("GDT");
    when(versionRecordManager.getCurrentPath()).thenReturn(documentPath);
    when(dtGraphService.loadContent(documentPath)).thenReturn(graphContent);
    when(versionRecordManager.getPathToLatest()).thenReturn(documentPath);
    when(graphContent.getOverview()).thenReturn(overview);
    when(graphContent.getModel()).thenReturn(graphModel);
    presenter.loadDocumentGraph(documentPath);
    verify(view).showLoading();
    verify(view).hideBusyIndicator();
    verify(view).refreshTitle(startsWith("GDT"));
    // initialise when no documents
    verify(editMenuItem).setEnabled(false);
    verify(viewMenuItem).setEnabled(false);
    verify(insertMenuItem).setEnabled(false);
    verify(radarMenuItem).setEnabled(false);
    verify(kieEditorWrapperView).clear();
    verify(kieEditorWrapperView).addMainEditorPage(view);
    verify(kieEditorWrapperView).addOverviewPage(eq(overviewWidget), any(com.google.gwt.user.client.Command.class));
    verify(overviewWidget).setContent(overview, documentPath);
}
Also used : GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) Overview(org.guvnor.common.services.shared.metadata.model.Overview) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 2 with GuidedDecisionTableEditorGraphContent

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

the class GuidedDecisionTableGraphEditorPresenterTest method checkOnStartupBasicInitialisation.

@Test
public void checkOnStartupBasicInitialisation() {
    final ObservablePath dtGraphPath = mock(ObservablePath.class);
    final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent(INITIAL_HASH_CODE);
    when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
    when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
    when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
    when(dtGraphPath.getFileName()).thenReturn("filename");
    presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
    assertEquals(dtGraphPath, presenter.editorPath);
    assertEquals(dtGraphPlaceRequest, presenter.editorPlaceRequest);
    assertEquals(INITIAL_HASH_CODE, (int) presenter.originalGraphHash);
    verify(presenter, times(1)).initialiseEditor(eq(dtGraphPath), eq(dtGraphPlaceRequest));
    verify(presenter, times(1)).initialiseVersionManager();
    verify(presenter, times(1)).addFileChangeListeners(eq(dtGraphPath));
    verify(lockManager, times(1)).init(lockTargetCaptor.capture());
    final LockTarget lockTarget = lockTargetCaptor.getValue();
    assertNotNull(lockTarget);
    assertEquals(dtGraphPath, lockTarget.getPath());
    assertEquals(dtGraphPlaceRequest, lockTarget.getPlace());
    assertNotNull(lockTarget.getTitle());
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) LockTarget(org.uberfire.client.mvp.LockTarget) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 3 with GuidedDecisionTableEditorGraphContent

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

the class GuidedDecisionTableGraphEditorPresenterTest method checkReload.

@Test
public void checkReload() {
    final ObservablePath dtGraphPath = mock(ObservablePath.class);
    final PathPlaceRequest dtGraphPlaceRequest = mock(PathPlaceRequest.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(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);
    verify(presenter, times(1)).loadDocumentGraph(dtGraphPath);
    presenter.reload();
    verify(presenter, times(1)).deregisterDocument(eq(dtPresenter));
    verify(presenter, times(2)).loadDocumentGraph(dtGraphPath);
    verify(modeller, times(1)).releaseDecisionTables();
    verify(modellerView, times(1)).clear();
}
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) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) 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) Test(org.junit.Test)

Example 4 with GuidedDecisionTableEditorGraphContent

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

the class GuidedDecisionTableGraphEditorPresenterTest method checkOnDecisionTableSelected.

private void checkOnDecisionTableSelected(final ParameterizedCommand<PlaceRequest> setup, 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(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);
        }
    });
    setup.execute(dtGraphPlaceRequest);
    presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
    final DecisionTableSelectedEvent event = new DecisionTableSelectedEvent(dtPresenter);
    presenter.onDecisionTableSelected(event);
    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) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)

Example 5 with GuidedDecisionTableEditorGraphContent

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

the class GuidedDecisionTableGraphEditorServiceImpl method constructContent.

@Override
protected GuidedDecisionTableEditorGraphContent constructContent(final Path path, final Overview overview) {
    final GuidedDecisionTableEditorGraphModel model = load(path);
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new GuidedDecisionTableEditorGraphContent(model, overview);
}
Also used : GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent)

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