Search in sources :

Example 16 with ObservablePath

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

the class BaseGuidedDecisionTableEditorPresenterTest method checkOnValidateWithErrors.

@Test
@SuppressWarnings("unchecked")
public void checkOnValidateWithErrors() {
    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 List<ValidationMessage> validationMessages = new ArrayList<ValidationMessage>() {

        {
            add(new ValidationMessage());
        }
    };
    when(dtService.validate(any(Path.class), any(GuidedDecisionTable52.class))).thenReturn(validationMessages);
    doNothing().when(presenter).showValidationPopup(any(List.class));
    presenter.onValidate(dtPresenter);
    final ArgumentCaptor<GuidedDecisionTable52> modelCaptor = ArgumentCaptor.forClass(GuidedDecisionTable52.class);
    verify(dtService, times(1)).validate(eq(path), modelCaptor.capture());
    assertNotNull(modelCaptor.getValue());
    assertEquals(dtPresenter.getModel(), modelCaptor.getValue());
    verify(notification, never()).fire(any(NotificationEvent.class));
    verify(presenter, times(1)).showValidationPopup(eq(validationMessages));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) ArrayList(java.util.ArrayList) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) List(java.util.List) ArrayList(java.util.ArrayList) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 17 with ObservablePath

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

the class GuidedDecisionTableGraphEditorPresenterTest method testOnDecisionTableSelectedWhenPresenterIsNotNull.

@Test
public void testOnDecisionTableSelectedWhenPresenterIsNotNull() {
    final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class);
    final Overview overview = mock(Overview.class);
    final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
    final GuidedDecisionTable52 model = new GuidedDecisionTable52();
    final GuidedDecisionTablePresenter.Access access = new GuidedDecisionTablePresenter.Access();
    final DecisionTableSelectedEvent event = new DecisionTableSelectedEvent(dtPresenter);
    final ObservablePath path = mock(ObservablePath.class);
    doNothing().when(presenter).initialiseKieEditorTabs(dtPresenter, overview, oracle, model.getImports(), false);
    doNothing().when(presenter).initialiseEditorTabsWhenNoDocuments();
    doReturn(true).when(modeller).isDecisionTableAvailable(dtPresenter);
    doReturn(Optional.of(dtPresenter)).when(modeller).getActiveDecisionTable();
    doReturn(overview).when(dtPresenter).getOverview();
    doReturn(oracle).when(dtPresenter).getDataModelOracle();
    doReturn(model).when(dtPresenter).getModel();
    doReturn(access).when(dtPresenter).getAccess();
    doReturn(path).when(dtPresenter).getLatestPath();
    presenter.registerDocument(dtPresenter);
    presenter.onDecisionTableSelected(event);
    verify(presenter, never()).initialiseEditorTabsWhenNoDocuments();
    verify(presenter).addColumnsTab();
    verify(presenter).enableColumnsTab(dtPresenter);
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) 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) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent) Test(org.junit.Test)

Example 18 with ObservablePath

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

the class GuidedDecisionTableGraphEditorPresenterTest method checkBuildModelFromEditor.

@Test
public void checkBuildModelFromEditor() {
    final ObservablePath dtPath1 = mock(ObservablePath.class);
    final PlaceRequest dtPlaceRequest1 = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent dtContent1 = makeDecisionTableContent(0);
    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(0);
    final GuidedDecisionTableView.Presenter dtPresenter2 = makeDecisionTable(dtPath2, dtPath2, dtPlaceRequest2, dtContent2);
    when(dtPresenter1.getView().getX()).thenReturn(100.0);
    when(dtPresenter1.getView().getY()).thenReturn(110.0);
    when(dtPresenter2.getView().getX()).thenReturn(200.0);
    when(dtPresenter2.getView().getY()).thenReturn(220.0);
    when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {

        {
            add(dtPresenter1);
            add(dtPresenter2);
        }
    });
    final GuidedDecisionTableEditorGraphModel model = presenter.buildModelFromEditor();
    assertNotNull(model);
    assertNotNull(model.getEntries());
    assertEquals(2, model.getEntries().size());
    assertContains(model.getEntries(), dtPath1, 100.0, 110.0);
    assertContains(model.getEntries(), dtPath2, 200.0, 220.0);
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) 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) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 19 with ObservablePath

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

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

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