Search in sources :

Example 16 with PathPlaceRequest

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

the class GuidedDecisionTableGraphEditorPresenterTest method checkDoSaveWithGraphEntry.

private void checkDoSaveWithGraphEntry(final ParameterizedCommand<OnSaveSetupDataHolder> setup, final Command assertion) {
    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(), any())).thenReturn(dtPresenter);
    when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {

        {
            add(dtPresenter);
        }
    });
    setup.execute(new OnSaveSetupDataHolder(dtGraphPath, dtGraphPlaceRequest, dtPresenter));
    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) 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)

Example 17 with PathPlaceRequest

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

the class GuidedDecisionTableGraphEditorPresenterTest method checkSaveDocumentGraphEntriesEmptyGraph.

@Test
public void checkSaveDocumentGraphEntriesEmptyGraph() {
    final ObservablePath dtGraphPath = mock(ObservablePath.class);
    final PathPlaceRequest dtGraphPlaceRequest = mock(PathPlaceRequest.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);
    when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<>());
    presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
    presenter.saveDocumentGraphEntries();
    verify(savePopUpPresenter, times(1)).show(any(ObservablePath.class), commitMessageCommandCaptor.capture());
    final ParameterizedCommand<String> commitMessageCommand = commitMessageCommandCaptor.getValue();
    assertNotNull(commitMessageCommand);
    commitMessageCommand.execute("message");
    verify(view, times(1)).showSaving();
    verify(saveInProgressEvent, never()).fire(any(SaveInProgressEvent.class));
    verify(dtGraphService, times(1)).save(eq(dtGraphPath), any(GuidedDecisionTableEditorGraphModel.class), any(), eq("message"));
    final ArgumentCaptor<NotificationEvent> notification = ArgumentCaptor.forClass(NotificationEvent.class);
    verify(notificationEvent, times(1)).fire(notification.capture());
    assertEquals(CommonConstants.INSTANCE.ItemSavedSuccessfully(), notification.getValue().getNotification());
    assertNull(presenter.concurrentUpdateSessionInfo);
}
Also used : GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) SaveInProgressEvent(org.uberfire.client.mvp.SaveInProgressEvent) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 18 with PathPlaceRequest

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

the class GuidedDecisionTableGraphEditorPresenterTest method checkOnStartupLoadGraphEntries.

@Test
public void checkOnStartupLoadGraphEntries() {
    final ObservablePath dtGraphPath = mock(ObservablePath.class);
    final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent(INITIAL_HASH_CODE);
    final Path dtPath = mock(Path.class);
    final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent();
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(dtPath, dtGraphPath, dtGraphPlaceRequest, 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);
    // Fake building of Graph Model from Editor to control hashCode
    doReturn(makeDecisionTableGraphContent(EDITOR_HASH_CODE).getModel()).when(presenter).buildModelFromEditor();
    when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), any(GuidedDecisionTableEditorContent.class), any(Boolean.class), any(), any())).thenReturn(dtPresenter);
    presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
    verify(view, times(1)).showLoading();
    verify(presenter, times(1)).loadDocumentGraph(eq(dtGraphPath));
    verify(dtService, times(1)).loadContent(eq(dtPath));
    verify(modeller, times(1)).addDecisionTable(dtObservablePathCaptor.capture(), dtPathPlaceRequestCaptor.capture(), eq(dtContent), any(Boolean.class), eq(null), eq(null));
    final ObservablePath dtObservablePath = dtObservablePathCaptor.getValue();
    final PathPlaceRequest dtPathPlaceRequest = dtPathPlaceRequestCaptor.getValue();
    assertNotNull(dtObservablePath);
    assertNotNull(dtPathPlaceRequest);
    assertEquals(dtPath.toURI(), dtObservablePath.toURI());
    assertEquals(dtPath.toURI(), dtPathPlaceRequest.getPath().toURI());
    assertEquals(EDITOR_HASH_CODE, (int) presenter.originalGraphHash);
    verify(presenter, times(1)).registerDocument(eq(dtPresenter));
    verify(view, times(1)).hideBusyIndicator();
    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));
    verify(lockManager, never()).acquireLock();
}
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) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) 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) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent) Test(org.junit.Test)

Example 19 with PathPlaceRequest

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

the class GuidedDecisionTableGraphEditorPresenterTest method checkOnRestore.

@Test
public void checkOnRestore() {
    final ObservablePath dtGraphPath = mock(ObservablePath.class);
    final PathPlaceRequest dtGraphPlaceRequest = mock(PathPlaceRequest.class);
    final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
    final RestoreEvent event = new RestoreEvent(dtGraphPath);
    when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
    when(dtGraphPath.getFileName()).thenReturn("filename");
    when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
    when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
    when(versionRecordManager.getPathToLatest()).thenReturn(dtGraphPath);
    presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
    verify(presenter, times(1)).initialiseEditor(eq(dtGraphPath), eq(dtGraphPlaceRequest));
    presenter.onRestore(event);
    verify(presenter, times(2)).initialiseEditor(eq(dtGraphPath), eq(dtGraphPlaceRequest));
    verify(notification, times(1)).fire(any(NotificationEvent.class));
}
Also used : GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RestoreEvent(org.uberfire.ext.editor.commons.version.events.RestoreEvent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 20 with PathPlaceRequest

use of org.uberfire.mvp.impl.PathPlaceRequest 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(), any())).thenReturn(dtPresenter1);
    when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), eq(dtContent2), any(Boolean.class), any(), any())).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(), 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(), 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)

Aggregations

PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)20 ObservablePath (org.uberfire.backend.vfs.ObservablePath)12 Test (org.junit.Test)9 PlaceRequest (org.uberfire.mvp.PlaceRequest)9 Path (org.uberfire.backend.vfs.Path)8 GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)6 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)5 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)4 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)4 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)3 GuidedDecisionTableGraphEntry (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry)3 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)3 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)3 DefaultPlaceRequest (org.uberfire.mvp.impl.DefaultPlaceRequest)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 GuidedDecisionTableEditorGraphModel (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)2 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)2 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)2 SaveInProgressEvent (org.uberfire.client.mvp.SaveInProgressEvent)2