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));
}
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));
}
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);
}
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);
}
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));
}
Aggregations