use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkOnRestore.
@Test
public void checkOnRestore() {
final ObservablePath dtGraphPath = mock(ObservablePath.class);
final PathPlaceRequest dtGraphPlaceRequest = mock(PathPlaceRequest.class);
final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
final RestoreEvent event = new RestoreEvent(dtGraphPath);
when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
when(dtGraphPath.getFileName()).thenReturn("filename");
when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
when(versionRecordManager.getPathToLatest()).thenReturn(dtGraphPath);
presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
verify(presenter, times(1)).initialiseEditor(eq(dtGraphPath), eq(dtGraphPlaceRequest));
presenter.onRestore(event);
verify(presenter, times(2)).initialiseEditor(eq(dtGraphPath), eq(dtGraphPlaceRequest));
verify(notification, times(1)).fire(any(NotificationEvent.class));
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkMayClose.
private void checkMayClose(final int uiModelHashCode, final Command assertion) {
final ObservablePath dtGraphPath = mock(ObservablePath.class);
final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent(0);
when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
when(dtGraphPath.getFileName()).thenReturn("filename");
when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
doReturn(makeDecisionTableGraphContent(uiModelHashCode).getModel()).when(presenter).buildModelFromEditor();
presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
assertion.execute();
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkSaveDocumentGraphEntries.
@Test
public void checkSaveDocumentGraphEntries() {
final ObservablePath dtGraphPath = mock(ObservablePath.class);
final PathPlaceRequest dtGraphPlaceRequest = mock(PathPlaceRequest.class);
final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
final ObservablePath dtPath1 = mock(ObservablePath.class);
final PlaceRequest dtPlaceRequest1 = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent dtContent1 = makeDecisionTableContent();
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();
final GuidedDecisionTableView.Presenter dtPresenter2 = makeDecisionTable(dtPath2, dtPath2, dtPlaceRequest2, dtContent2);
when(dtPath1.toURI()).thenReturn("dtPath1");
when(dtPath2.toURI()).thenReturn("dtPath2");
when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
when(dtGraphPath.getFileName()).thenReturn("filename");
when(dtService.loadContent(eq(dtPath1))).thenReturn(dtContent1);
when(dtService.loadContent(eq(dtPath2))).thenReturn(dtContent2);
when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), eq(dtContent1), any(Boolean.class), any(), any())).thenReturn(dtPresenter1);
when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), eq(dtContent2), any(Boolean.class), any(), any())).thenReturn(dtPresenter2);
when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter1);
add(dtPresenter2);
}
});
presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
presenter.saveDocumentGraphEntries();
verify(savePopUpPresenter, times(1)).show(any(Path.class), commitMessageCommandCaptor.capture());
final ParameterizedCommand<String> commitMessageCommand = commitMessageCommandCaptor.getValue();
assertNotNull(commitMessageCommand);
commitMessageCommand.execute("message");
verify(view, times(1)).showSaving();
verify(saveInProgressEvent, times(2)).fire(any(SaveInProgressEvent.class));
verify(dtGraphService, times(1)).save(eq(dtGraphPath), any(GuidedDecisionTableEditorGraphModel.class), any(), eq("message"));
verify(dtService, times(1)).save(eq(dtPath2), any(GuidedDecisionTable52.class), any(Metadata.class), eq("message"));
verify(dtService, times(1)).save(eq(dtPath2), any(GuidedDecisionTable52.class), any(), eq("message"));
verify(notificationEvent, times(1)).fire(any(NotificationEvent.class));
verify(dtPresenter1, times(1)).setConcurrentUpdateSessionInfo(eq(null));
verify(dtPresenter2, times(1)).setConcurrentUpdateSessionInfo(eq(null));
assertNull(presenter.concurrentUpdateSessionInfo);
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkMayCloseWithDecisionTableGraphEntries.
private void checkMayCloseWithDecisionTableGraphEntries(final int uiModelHashCode, final Command assertion) {
final ObservablePath dtGraphPath = mock(ObservablePath.class);
final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
final ObservablePath dtPath = mock(ObservablePath.class);
final PlaceRequest dtPlaceRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent(0);
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(dtPath, dtPath, dtPlaceRequest, dtContent);
final GuidedDecisionTableGraphEntry dtGraphEntry = new GuidedDecisionTableGraphEntry(dtPath, dtPath);
dtGraphContent.getModel().getEntries().add(dtGraphEntry);
when(dtPath.toURI()).thenReturn("dtPath");
when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
when(dtGraphPath.getFileName()).thenReturn("filename");
when(dtService.loadContent(eq(dtPath))).thenReturn(dtContent);
when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
when(dtPresenter.getOriginalHashCode()).thenReturn(uiModelHashCode);
doReturn(makeDecisionTableGraphContent(uiModelHashCode).getModel()).when(presenter).buildModelFromEditor();
when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), any(GuidedDecisionTableEditorContent.class), any(Boolean.class), any(), any())).thenReturn(dtPresenter);
when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter);
}
});
presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
assertion.execute();
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class ColumnsPagePresenterTest method testOnUpdatedLockStatusEventWhenActiveDecisionTableHasAnInvalidPath.
@Test
public void testOnUpdatedLockStatusEventWhenActiveDecisionTableHasAnInvalidPath() {
final UpdatedLockStatusEvent event = mock(UpdatedLockStatusEvent.class);
final GuidedDecisionTableView.Presenter activeDecisionTable = mock(GuidedDecisionTableView.Presenter.class);
final ObservablePath path = mock(ObservablePath.class);
doReturn(true).when(presenter).hasActiveDecisionTable();
doReturn(Optional.of(activeDecisionTable)).when(modeller).getActiveDecisionTable();
doReturn(path).when(activeDecisionTable).getCurrentPath();
doReturn(null).when(event).getFile();
presenter.onUpdatedLockStatusEvent(event);
verify(presenter, never()).refresh();
}
Aggregations