use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkOnStartupLoadGraphEntries.
@Test
public void checkOnStartupLoadGraphEntries() {
final ObservablePath dtGraphPath = mock(ObservablePath.class);
final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent(INITIAL_HASH_CODE);
final Path dtPath = mock(Path.class);
final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent();
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(dtPath, dtGraphPath, dtGraphPlaceRequest, 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);
// Fake building of Graph Model from Editor to control hashCode
doReturn(makeDecisionTableGraphContent(EDITOR_HASH_CODE).getModel()).when(presenter).buildModelFromEditor();
when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), any(GuidedDecisionTableEditorContent.class), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter);
presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
verify(view, times(1)).showLoading();
verify(presenter, times(1)).loadDocumentGraph(eq(dtGraphPath));
verify(dtService, times(1)).loadContent(eq(dtPath));
verify(modeller, times(1)).addDecisionTable(dtObservablePathCaptor.capture(), dtPathPlaceRequestCaptor.capture(), eq(dtContent), any(Boolean.class), eq(null), eq(null));
final ObservablePath dtObservablePath = dtObservablePathCaptor.getValue();
final PathPlaceRequest dtPathPlaceRequest = dtPathPlaceRequestCaptor.getValue();
assertNotNull(dtObservablePath);
assertNotNull(dtPathPlaceRequest);
assertEquals(dtPath.toURI(), dtObservablePath.toURI());
assertEquals(dtPath.toURI(), dtPathPlaceRequest.getPath().toURI());
assertEquals(EDITOR_HASH_CODE, (int) presenter.originalGraphHash);
verify(presenter, times(1)).registerDocument(eq(dtPresenter));
verify(view, times(1)).hideBusyIndicator();
verify(decisionTableSelectedEvent, times(1)).fire(dtSelectedEventCaptor.capture());
final DecisionTableSelectedEvent dtSelectedEvent = dtSelectedEventCaptor.getValue();
assertNotNull(dtSelectedEvent);
assertTrue(dtSelectedEvent.getPresenter().isPresent());
assertEquals(dtPresenter, dtSelectedEvent.getPresenter().get());
verify(modellerGridPanel).setFocus(eq(true));
verify(lockManager, never()).acquireLock();
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkSaveDocumentGraphEntriesEmptyGraph.
@Test
public void checkSaveDocumentGraphEntriesEmptyGraph() {
final ObservablePath dtGraphPath = mock(ObservablePath.class);
final PathPlaceRequest dtGraphPlaceRequest = mock(PathPlaceRequest.class);
final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
when(dtGraphPath.getFileName()).thenReturn("filename");
when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<>());
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, never()).fire(any(SaveInProgressEvent.class));
verify(dtGraphService, times(1)).save(eq(dtGraphPath), any(GuidedDecisionTableEditorGraphModel.class), any(Metadata.class), eq("message"));
final ArgumentCaptor<NotificationEvent> notification = ArgumentCaptor.forClass(NotificationEvent.class);
verify(notificationEvent, times(1)).fire(notification.capture());
assertEquals(CommonConstants.INSTANCE.ItemSavedSuccessfully(), notification.getValue().getNotification());
assertNull(presenter.concurrentUpdateSessionInfo);
}
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 checkDoSaveWithGraphEntry.
private void checkDoSaveWithGraphEntry(final ParameterizedCommand<OnSaveSetupDataHolder> setup, final Command assertion) {
final ObservablePath dtGraphPath = mock(ObservablePath.class);
final PathPlaceRequest dtGraphPlaceRequest = mock(PathPlaceRequest.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(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), any(GuidedDecisionTableEditorContent.class), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter);
when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter);
}
});
setup.execute(new OnSaveSetupDataHolder(dtGraphPath, dtGraphPlaceRequest, dtPresenter));
presenter.doSave();
assertion.execute();
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class ScenarioEditorPresenterTest method testRunAllScenarios.
@Test
public void testRunAllScenarios() throws Exception {
final ObservablePath path = mock(ObservablePath.class);
when(versionRecordManager.getCurrentPath()).thenReturn(path);
editor.onRunAllScenarios();
InOrder inOrder = inOrder(view);
inOrder.verify(view).showBusyIndicator(TestScenarioConstants.INSTANCE.BuildingAndRunningScenarios());
inOrder.verify(view).hideBusyIndicator();
}
Aggregations