Search in sources :

Example 21 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method checkOnOpenDocumentsInEditor.

@Test
public void checkOnOpenDocumentsInEditor() {
    final Path dtPath1 = PathFactory.newPath("file1", "file1Url");
    final Path dtPath2 = PathFactory.newPath("file2", "file2Url");
    final List<Path> dtPaths = new ArrayList<Path>() {

        {
            add(dtPath1);
            add(dtPath2);
        }
    };
    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);
    when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), any(GuidedDecisionTableEditorContent.class), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter);
    presenter.onOpenDocumentsInEditor(dtPaths);
    verify(dtService, times(2)).loadContent(dtPathCaptor.capture());
    final List<Path> dtLoadedPaths = dtPathCaptor.getAllValues();
    assertNotNull(dtLoadedPaths);
    assertEquals(2, dtLoadedPaths.size());
    assertContains(dtLoadedPaths, dtPath1);
    assertContains(dtLoadedPaths, dtPath2);
}
Also used : ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) ArrayList(java.util.ArrayList) 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 22 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method testGetContentSupplier.

@Test
public void testGetContentSupplier() {
    final GuidedDecisionTableView.Presenter presenter = mock(GuidedDecisionTableView.Presenter.class);
    final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
    final Overview overview = mock(Overview.class);
    final ObservablePath currentPath = mock(ObservablePath.class);
    final ObservablePath latestPath = mock(ObservablePath.class);
    doReturn(model).when(presenter).getModel();
    doReturn(overview).when(presenter).getOverview();
    doReturn(currentPath).when(presenter).getCurrentPath();
    doReturn(latestPath).when(presenter).getLatestPath();
    doReturn(asSet(presenter)).when(this.presenter).getAvailableDecisionTables();
    final List<GuidedDecisionTableEditorContent> content = this.presenter.getContentSupplier().get();
    final GuidedDecisionTableEditorContent firstContent = content.get(0);
    assertEquals(1, content.size());
    assertEquals(model, firstContent.getModel());
    assertEquals(overview, firstContent.getOverview());
    assertEquals(currentPath, firstContent.getCurrentPath());
    assertEquals(latestPath, firstContent.getLatestPath());
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) Overview(org.guvnor.common.services.shared.metadata.model.Overview) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 23 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath 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 24 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method getPresenter.

@Override
protected GuidedDecisionTableGraphEditorPresenter getPresenter() {
    return new GuidedDecisionTableGraphEditorPresenter(view, dtServiceCaller, dtGraphServiceCaller, moduleServiceCaller, graphSaveAndRenameServiceCaller, notification, saveInProgressEvent, decisionTableSelectedEvent, validationPopup, dtGraphResourceType, editMenuBuilder, viewMenuBuilder, insertMenuBuilder, radarMenuBuilder, modeller, helper, beanManager, placeManager, lockManager, columnsPage, saveAndRenameCommandBuilder, alertsButtonMenuItemBuilder) {

        {
            workbenchContext = GuidedDecisionTableGraphEditorPresenterTest.this.workbenchContext;
            projectController = GuidedDecisionTableGraphEditorPresenterTest.this.projectController;
        }

        @Override
        protected Command getSaveAndRenameCommand() {
            return mock(Command.class);
        }

        @Override
        PathPlaceRequest getPathPlaceRequest(final Path path) {
            // Avoid use of IOC.getBeanManager().lookupBean(..) in PathPlaceRequest for Unit Tests
            final PathPlaceRequest pathPlaceRequest = new PathPlaceRequest(path) {

                @Override
                protected ObservablePath createObservablePath(final Path path) {
                    final ObservablePath op = new ObservablePathImpl().wrap(path);
                    return op;
                }
            };
            return pathPlaceRequest;
        }
    };
}
Also used : ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) ObservablePathImpl(org.uberfire.backend.vfs.impl.ObservablePathImpl) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) ObservablePath(org.uberfire.backend.vfs.ObservablePath)

Example 25 with ObservablePath

use of org.uberfire.backend.vfs.ObservablePath 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)

Aggregations

ObservablePath (org.uberfire.backend.vfs.ObservablePath)51 Test (org.junit.Test)38 PlaceRequest (org.uberfire.mvp.PlaceRequest)33 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)29 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)27 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)15 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)13 GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)13 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)11 DecisionTableSelectedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)11 Path (org.uberfire.backend.vfs.Path)9 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)7 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)7 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)6 GuidedDecisionTableGraphEntry (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry)5 GuidedDecisionTableEditorGraphModel (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)4 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)4 List (java.util.List)3 Overview (org.guvnor.common.services.shared.metadata.model.Overview)3 ValidationMessage (org.guvnor.common.services.shared.validation.model.ValidationMessage)3