use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkRefreshDocument.
@Test
public void checkRefreshDocument() {
final ObservablePath path = mock(ObservablePath.class);
final PlaceRequest placeRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent content = makeDecisionTableContent();
final MultiPageEditor pageEditor = mock(MultiPageEditor.class);
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(path, path, placeRequest, content);
presenter.onStartup(path, placeRequest);
verify(view, times(1)).showLoading();
verify(dtService, times(1)).loadContent(eq(path));
verify(decisionTableSelectedEvent, times(1)).fire(dtSelectedEventCaptor.capture());
verify(view, times(1)).hideBusyIndicator();
final DecisionTableSelectedEvent dtSelectedEvent = dtSelectedEventCaptor.getValue();
assertNotNull(dtSelectedEvent);
assertTrue(dtSelectedEvent.getPresenter().isPresent());
assertEquals(dtPresenter, dtSelectedEvent.getPresenter().get());
when(dtPresenter.getCurrentPath()).thenReturn(path);
when(presenter.getKieEditorWrapperMultiPage()).thenReturn(pageEditor);
presenter.refreshDocument(dtPresenter);
verify(view, times(2)).showLoading();
verify(dtService, times(2)).loadContent(eq(path));
verify(modeller, times(1)).refreshDecisionTable(eq(dtPresenter), eq(path), eq(placeRequest), eq(content), any(Boolean.class));
verify(presenter, times(1)).activateDocument(eq(dtPresenter));
verify(view, times(2)).hideBusyIndicator();
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkOnDecisionTableSelectedWhenAvailableNotSelected.
@Test
public void checkOnDecisionTableSelectedWhenAvailableNotSelected() {
final ObservablePath path = mock(ObservablePath.class);
final PlaceRequest placeRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent content = makeDecisionTableContent();
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(path, path, placeRequest, content);
final DecisionTableSelectedEvent event = new DecisionTableSelectedEvent(dtPresenter);
final MultiPageEditor pageEditor = mock(MultiPageEditor.class);
when(modeller.isDecisionTableAvailable(any(GuidedDecisionTableView.Presenter.class))).thenReturn(true);
when(presenter.getActiveDocument()).thenReturn(null);
when(presenter.getKieEditorWrapperMultiPage()).thenReturn(pageEditor);
presenter.onStartup(path, placeRequest);
presenter.onDecisionTableSelected(event);
verify(presenter, times(1)).activateDocument(any(GuidedDecisionTableView.Presenter.class));
verify(radarMenuItem, atLeast(1)).setEnabled(eq(true));
assertTrue(getMenuState(presenter.getMenus(), MenuItems.VALIDATE));
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkRemoveDocument.
@Test
public void checkRemoveDocument() {
final ObservablePath path = mock(ObservablePath.class);
final PlaceRequest placeRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent content = makeDecisionTableContent();
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(path, path, placeRequest, content);
presenter.onStartup(path, placeRequest);
presenter.removeDocument(dtPresenter);
verify(modeller, times(1)).removeDecisionTable(eq(dtPresenter));
verify(presenter, times(1)).deregisterDocument(eq(dtPresenter));
verify(presenter, times(1)).openOtherDecisionTable();
verify(dtPresenter, times(1)).onClose();
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkOnStartup.
@Test
public void checkOnStartup() {
final ObservablePath path = mock(ObservablePath.class);
final PlaceRequest placeRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent content = makeDecisionTableContent();
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(path, path, placeRequest, content);
presenter.onStartup(path, placeRequest);
assertEquals(path, presenter.editorPath);
assertEquals(placeRequest, presenter.editorPlaceRequest);
verify(view, times(1)).showLoading();
verify(presenter, times(1)).loadDocument(eq(path), eq(placeRequest));
verify(dtService, times(1)).loadContent(eq(path));
verify(modeller, times(1)).addDecisionTable(eq(path), eq(placeRequest), eq(content), any(Boolean.class), eq(null), eq(null));
verify(presenter, times(1)).registerDocument(eq(dtPresenter));
verify(decisionTableSelectedEvent, times(1)).fire(dtSelectedEventCaptor.capture());
verify(view, times(1)).hideBusyIndicator();
final DecisionTableSelectedEvent dtSelectedEvent = dtSelectedEventCaptor.getValue();
assertNotNull(dtSelectedEvent);
assertTrue(dtSelectedEvent.getPresenter().isPresent());
assertEquals(dtPresenter, dtSelectedEvent.getPresenter().get());
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkOnSave.
@Test
public void checkOnSave() {
final String commitMessage = "message";
final ObservablePath path = mock(ObservablePath.class);
final PlaceRequest placeRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent content = makeDecisionTableContent();
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(path, path, placeRequest, content);
presenter.onSave(dtPresenter, commitMessage);
final ArgumentCaptor<GuidedDecisionTable52> modelCaptor = ArgumentCaptor.forClass(GuidedDecisionTable52.class);
final ArgumentCaptor<Metadata> metadataCaptor = ArgumentCaptor.forClass(Metadata.class);
verify(dtService, times(1)).saveAndUpdateGraphEntries(eq(path), modelCaptor.capture(), metadataCaptor.capture(), eq(commitMessage));
assertNotNull(modelCaptor.getValue());
assertEquals(dtPresenter.getModel(), modelCaptor.getValue());
assertNotNull(metadataCaptor.getValue());
assertEquals(dtPresenter.getOverview().getMetadata(), metadataCaptor.getValue());
}
Aggregations