use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkMayCloseWithCleanDecisionTable.
@Test
public void checkMayCloseWithCleanDecisionTable() {
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);
when(dtPresenter.getOriginalHashCode()).thenReturn(0);
when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter);
}
});
assertTrue(presenter.mayClose());
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkOnDecisionTableSelectedWhenAvailableSelected.
@Test
public void checkOnDecisionTableSelectedWhenAvailableSelected() {
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);
when(modeller.isDecisionTableAvailable(any(GuidedDecisionTableView.Presenter.class))).thenReturn(true);
when(presenter.getActiveDocument()).thenReturn(dtPresenter);
presenter.onDecisionTableSelected(event);
verify(presenter, never()).activateDocument(any(GuidedDecisionTableView.Presenter.class));
assertTrue(getMenuState(presenter.getMenus(), MenuItems.VALIDATE));
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkOnDecisionTableSelectedWhenNotAvailable.
@Test
public void checkOnDecisionTableSelectedWhenNotAvailable() {
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);
when(modeller.isDecisionTableAvailable(any(GuidedDecisionTableView.Presenter.class))).thenReturn(false);
presenter.onDecisionTableSelected(event);
verify(presenter, never()).activateDocument(any(GuidedDecisionTableView.Presenter.class));
assertTrue(getMenuState(presenter.getMenus(), MenuItems.VALIDATE));
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkOnDecisionTableSelectedEventReselection.
@Test
public void checkOnDecisionTableSelectedEventReselection() {
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 eventSelect = new DecisionTableSelectedEvent(dtPresenter);
doReturn(true).when(modeller).isDecisionTableAvailable(dtPresenter);
presenter.onStartup(path, placeRequest);
presenter.onDecisionTableSelected(eventSelect);
assertEquals(dtPresenter, presenter.getActiveDocument());
final DecisionTableSelectedEvent eventDeselect = DecisionTableSelectedEvent.NONE;
presenter.onDecisionTableSelected(eventDeselect);
assertNull(presenter.getActiveDocument());
presenter.onDecisionTableSelected(eventSelect);
assertEquals(dtPresenter, presenter.getActiveDocument());
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkOnSourceTabSelected.
@Test
public void checkOnSourceTabSelected() {
final String source = "source";
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);
when(dtService.toSource(eq(path), any(GuidedDecisionTable52.class))).thenReturn(source);
presenter.onSourceTabSelected(dtPresenter);
final ArgumentCaptor<GuidedDecisionTable52> modelCaptor = ArgumentCaptor.forClass(GuidedDecisionTable52.class);
verify(dtService, times(1)).toSource(eq(path), modelCaptor.capture());
assertNotNull(modelCaptor.getValue());
assertEquals(dtPresenter.getModel(), modelCaptor.getValue());
verify(presenter, times(1)).updateSource(eq(source));
}
Aggregations