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