Search in sources :

Example 61 with ObservablePath

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

the class KieMultipleDocumentEditorTest method testConcurrentDeleteCommandIgnore.

@Test
@SuppressWarnings("unchecked")
public void testConcurrentDeleteCommandIgnore() {
    final TestDocument document = createTestDocument();
    final ObservablePath path = document.getLatestPath();
    concurrentDeleteCommand = editor.getConcurrentDeleteOnIgnoreCommand();
    editor.setupMenuBar();
    registerDocument(document);
    final ArgumentCaptor<ParameterizedCommand> deleteCommandCaptor = ArgumentCaptor.forClass(ParameterizedCommand.class);
    verify(path, times(1)).onConcurrentDelete(deleteCommandCaptor.capture());
    final ParameterizedCommand deleteCommand = deleteCommandCaptor.getValue();
    assertNotNull(deleteCommand);
    final ObservablePath.OnConcurrentDelete info = mock(ObservablePath.OnConcurrentDelete.class);
    deleteCommand.execute(info);
    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));
}
Also used : MenuItems(org.uberfire.ext.editor.commons.client.menu.MenuItems) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 62 with ObservablePath

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

the class KieMultipleDocumentEditorTest method testRenameCommand.

@Test
public void testRenameCommand() {
    final TestDocument document = createTestDocument();
    final ObservablePath path = document.getLatestPath();
    registerDocument(document);
    final ArgumentCaptor<Command> renameCommandCaptor = ArgumentCaptor.forClass(Command.class);
    verify(path, times(1)).onRename(renameCommandCaptor.capture());
    final Command renameCommand = renameCommandCaptor.getValue();
    assertNotNull(renameCommand);
    renameCommand.execute();
    verify(editorView, times(2)).refreshTitle(Mockito.<String>any());
    verify(editorView, times(1)).showBusyIndicator(Mockito.<String>any());
    verify(editor, times(2)).getDocumentTitle(eq(document));
    verify(editor, times(1)).refreshDocument(eq(document));
    verify(changeTitleEvent, times(1)).fire(any(ChangeTitleWidgetEvent.class));
}
Also used : ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ObservablePath(org.uberfire.backend.vfs.ObservablePath) ChangeTitleWidgetEvent(org.uberfire.client.workbench.events.ChangeTitleWidgetEvent) Test(org.junit.Test)

Example 63 with ObservablePath

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

the class KieMultipleDocumentEditorTest method testRegisterDocument.

@Test
@SuppressWarnings("unchecked")
public void testRegisterDocument() {
    final TestDocument document = createTestDocument();
    final ObservablePath path = document.getLatestPath();
    registerDocument(document);
    verify(path, times(1)).onRename(any(Command.class));
    verify(path, times(1)).onConcurrentRename(any(ParameterizedCommand.class));
    verify(path, times(1)).onDelete(any(Command.class));
    verify(path, times(1)).onConcurrentDelete(any(ParameterizedCommand.class));
    verify(path, times(1)).onConcurrentUpdate(any(ParameterizedCommand.class));
    verify(registeredDocumentsMenuBuilder, times(1)).registerDocument(document);
}
Also used : ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 64 with ObservablePath

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

the class KieMultipleDocumentEditorTest method testVersionRecordManagerSelectionChange.

@Test
@SuppressWarnings("unchecked")
public void testVersionRecordManagerSelectionChange() {
    final TestDocument document = createTestDocument();
    final ObservablePath path = document.getLatestPath();
    registerDocument(document);
    activateDocument(document);
    final ArgumentCaptor<Callback> callbackArgumentCaptor = ArgumentCaptor.forClass(Callback.class);
    verify(versionRecordManager, times(1)).init(eq(null), eq(path), callbackArgumentCaptor.capture());
    final Callback<VersionRecord> callback = callbackArgumentCaptor.getValue();
    assertNotNull(callback);
    final VersionRecord versionRecord = mock(VersionRecord.class);
    final ObservablePath newPath = mock(ObservablePath.class);
    when(versionRecord.id()).thenReturn("id");
    when(versionRecordManager.getCurrentPath()).thenReturn(newPath);
    when(versionRecordManager.isLatest(versionRecord)).thenReturn(false);
    callback.callback(versionRecord);
    verify(versionRecordManager, times(1)).setVersion(eq("id"));
    verify(document, times(1)).setVersion(eq("id"));
    verify(document, times(1)).setCurrentPath(eq(newPath));
    verify(document, times(1)).setReadOnly(eq(true));
    verify(editor, times(1)).refreshDocument(document);
}
Also used : RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) Callback(org.uberfire.client.callbacks.Callback) VersionRecord(org.uberfire.java.nio.base.version.VersionRecord) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 65 with ObservablePath

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

the class KieMultipleDocumentEditorTest method testActivateDocument.

@Test
@SuppressWarnings("unchecked")
public void testActivateDocument() {
    final TestDocument document = createTestDocument();
    final ObservablePath path = document.getLatestPath();
    final Overview overview = mock(Overview.class);
    final AsyncPackageDataModelOracle dmo = mock(AsyncPackageDataModelOracle.class);
    final Imports imports = mock(Imports.class);
    final boolean isReadOnly = false;
    registerDocument(document);
    editor.activateDocument(document, overview, dmo, imports, isReadOnly);
    assertEquals(document, editor.getActiveDocument());
    verify(versionRecordManager, times(1)).init(eq(null), eq(path), any(Callback.class));
    verify(kieEditorWrapperView, times(1)).clear();
    verify(kieEditorWrapperView, times(1)).addMainEditorPage(eq(editorView));
    verify(kieEditorWrapperView, times(1)).addOverviewPage(eq(overviewWidget), any(com.google.gwt.user.client.Command.class));
    verify(kieEditorWrapperView, times(1)).addSourcePage(eq(editor.sourceWidget));
    verify(kieEditorWrapperView, times(1)).addImportsTab(eq(importsWidget));
    verify(overviewWidget, times(1)).setContent(eq(overview), eq(path));
    verify(importsWidget, times(1)).setContent(eq(dmo), eq(imports), eq(isReadOnly));
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) Callback(org.uberfire.client.callbacks.Callback) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) Overview(org.guvnor.common.services.shared.metadata.model.Overview) Imports(org.kie.soup.project.datamodel.imports.Imports) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Aggregations

ObservablePath (org.uberfire.backend.vfs.ObservablePath)97 Test (org.junit.Test)70 PlaceRequest (org.uberfire.mvp.PlaceRequest)38 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)32 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)29 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 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)9 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)8 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)7 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)7 List (java.util.List)6 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)6 Command (org.uberfire.mvp.Command)6 ArrayList (java.util.ArrayList)5