use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkReload.
@Test
public void checkReload() {
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);
}
});
presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
verify(presenter, times(1)).loadDocumentGraph(dtGraphPath);
presenter.reload();
verify(presenter, times(1)).deregisterDocument(eq(dtPresenter));
verify(presenter, times(2)).loadDocumentGraph(dtGraphPath);
verify(modeller, times(1)).releaseDecisionTables();
verify(modellerView, times(1)).clear();
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkOnDecisionTableSelected.
private void checkOnDecisionTableSelected(final ParameterizedCommand<PlaceRequest> setup, 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(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(dtGraphPlaceRequest);
presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
final DecisionTableSelectedEvent event = new DecisionTableSelectedEvent(dtPresenter);
presenter.onDecisionTableSelected(event);
assertion.execute();
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.
the class GuidedDecisionTableModellerPresenterTest method refreshDecisionTable.
@Test
public void refreshDecisionTable() {
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable();
final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent();
final GuidedDecisionTableView dtView = dtPresenter.getView();
final ObservablePath path = mock(ObservablePath.class);
final PlaceRequest placeRequest = mock(PlaceRequest.class);
final ArgumentCaptor<Command> afterRemovalCommandCaptor = ArgumentCaptor.forClass(Command.class);
presenter.refreshDecisionTable(dtPresenter, path, placeRequest, dtContent, false);
verify(view, times(1)).removeDecisionTable(eq(dtView), afterRemovalCommandCaptor.capture());
final Command afterRemovalCommand = afterRemovalCommandCaptor.getValue();
assertNotNull(afterRemovalCommand);
afterRemovalCommand.execute();
verify(view, times(1)).addDecisionTable(eq(dtView));
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.
the class GuidedDecisionTableModellerPresenterTest method addDecisionTable.
@Test
public void addDecisionTable() {
final ObservablePath path = mock(ObservablePath.class);
final PlaceRequest placeRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent();
presenter.addDecisionTable(path, placeRequest, dtContent, false, null, null);
verify(presenter, times(1)).updateLinks();
verify(gridLayer, times(1)).refreshGridWidgetConnectors();
verify(view, times(1)).addDecisionTable(eq(dtableView));
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenter method getRefreshContentSuccessCallback.
private RemoteCallback<GuidedDecisionTableEditorContent> getRefreshContentSuccessCallback(final GuidedDecisionTableView.Presenter dtPresenter) {
final ObservablePath path = dtPresenter.getLatestPath();
final PlaceRequest place = dtPresenter.getPlaceRequest();
final boolean isReadOnly = dtPresenter.isReadOnly();
return (content) -> {
// Refresh Decision Table in modeller
modeller.refreshDecisionTable(dtPresenter, path, place, content, isReadOnly);
activateDocument(dtPresenter);
view.hideBusyIndicator();
};
}
Aggregations