Search in sources :

Example 1 with ObservablePath

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

the class KieMultipleDocumentEditor method initialiseVersionManager.

protected void initialiseVersionManager(final D document) {
    final String version = document.getVersion();
    final ObservablePath path = document.getLatestPath();
    versionRecordManager.init(version, path, (versionRecord) -> {
        versionRecordManager.setVersion(versionRecord.id());
        document.setVersion(versionRecord.id());
        document.setCurrentPath(versionRecordManager.getCurrentPath());
        document.setReadOnly(!versionRecordManager.isLatest(versionRecord));
        refreshDocument(document);
    });
}
Also used : ObservablePath(org.uberfire.backend.vfs.ObservablePath)

Example 2 with ObservablePath

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

the class KieEditorTest method testAddDelete.

@Test
public void testAddDelete() {
    final ObservablePath observablePath = mock(ObservablePath.class);
    doReturn(observablePath).when(versionRecordManager).getPathToLatest();
    presenter.addDelete(fileMenuBuilder);
    verify(fileMenuBuilder).addDelete(observablePath, assetUpdateValidator);
}
Also used : ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 3 with ObservablePath

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

the class KieMultipleDocumentEditorRestoreTest method testOnRestore.

@Test
public void testOnRestore() {
    final TestDocument document = createTestDocument();
    final ObservablePath currentPath = document.getCurrentPath();
    final ObservablePath latestPath = mock(ObservablePath.class);
    registerDocument(document);
    activateDocument(document);
    when(versionRecordManager.getCurrentPath()).thenReturn(currentPath);
    when(versionRecordManager.getPathToLatest()).thenReturn(latestPath);
    editor.onRestore(new RestoreEvent(currentPath));
    verify(document, times(1)).setVersion(eq(null));
    verify(document, times(1)).setLatestPath(latestPath);
    verify(document, times(1)).setCurrentPath(latestPath);
    verify(editor, times(2)).initialiseVersionManager(eq(document));
    verify(editor, times(1)).refreshDocument(eq(document));
    verify(notificationEvent, times(1)).fire(any(NotificationEvent.class));
}
Also used : 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 4 with ObservablePath

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

the class KieMultipleDocumentEditorTest method testConcurrentUpdate.

@Test
@SuppressWarnings("unchecked")
public void testConcurrentUpdate() {
    final TestDocument document = createTestDocument();
    final ObservablePath path = document.getLatestPath();
    registerDocument(document);
    final ArgumentCaptor<ParameterizedCommand> updateCommandCaptor = ArgumentCaptor.forClass(ParameterizedCommand.class);
    verify(path, times(1)).onConcurrentUpdate(updateCommandCaptor.capture());
    final ParameterizedCommand updateCommand = updateCommandCaptor.getValue();
    assertNotNull(updateCommand);
    final ObservablePath.OnConcurrentUpdateEvent info = mock(ObservablePath.OnConcurrentUpdateEvent.class);
    updateCommand.execute(info);
    verify(document, times(1)).setConcurrentUpdateSessionInfo(eq(info));
}
Also used : ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 5 with ObservablePath

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

the class KieMultipleDocumentEditorTest method testDeleteCommand.

@Test
public void testDeleteCommand() {
    final TestDocument document = createTestDocument();
    final ObservablePath path = document.getLatestPath();
    editor.setupMenuBar();
    registerDocument(document);
    final ArgumentCaptor<Command> deleteCommandCaptor = ArgumentCaptor.forClass(Command.class);
    verify(path, times(1)).onDelete(deleteCommandCaptor.capture());
    final Command deleteCommand = deleteCommandCaptor.getValue();
    assertNotNull(deleteCommand);
    deleteCommand.execute();
    verify(editor, times(1)).enableMenus(eq(false));
    verify(editor, times(4)).enableMenuItem(eq(false), any(MenuItems.class));
    verify(saveMenuItem, times(1)).setEnabled(eq(false));
    verify(versionManagerMenuItem, times(1)).setEnabled(eq(false));
    verify(editor, times(1)).removeDocument(eq(document));
    verify(registeredDocumentsMenuBuilder, times(1)).deregisterDocument(document);
}
Also used : ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) MenuItems(org.uberfire.ext.editor.commons.client.menu.MenuItems) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Aggregations

ObservablePath (org.uberfire.backend.vfs.ObservablePath)85 Test (org.junit.Test)64 PlaceRequest (org.uberfire.mvp.PlaceRequest)35 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)19 Path (org.uberfire.backend.vfs.Path)14 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 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)11 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)9 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)9 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)8 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)7 Command (org.uberfire.mvp.Command)6 List (java.util.List)5 GuidedDecisionTableGraphEntry (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry)5 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)5