use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.
the class BaseGuidedDecisionTablePresenterTest method makeDecisionTableContent.
protected GuidedDecisionTableEditorContent makeDecisionTableContent(final int hashCode) {
final GuidedDecisionTable52 model = new GuidedDecisionTable52() {
@Override
public int hashCode() {
return hashCode;
}
@Override
public boolean equals(Object o) {
return super.equals(o);
}
};
final Overview overview = mock(Overview.class);
final Metadata metadata = mock(Metadata.class);
when(overview.getMetadata()).thenReturn(metadata);
return new GuidedDecisionTableEditorContent(model, Collections.<PortableWorkDefinition>emptySet(), overview, mock(PackageDataModelOracleBaselinePayload.class));
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorPresenterTest method startUpSelectsDecisionTable.
@Test
public void startUpSelectsDecisionTable() {
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);
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));
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkMayCloseWithDirtyDecisionTable.
@Test
public void checkMayCloseWithDirtyDecisionTable() {
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(10);
when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter);
}
});
assertFalse(presenter.mayClose());
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkOnValidateWithoutErrors.
@Test
public void checkOnValidateWithoutErrors() {
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.validate(any(Path.class), any(GuidedDecisionTable52.class))).thenReturn(Collections.emptyList());
presenter.onValidate(dtPresenter);
final ArgumentCaptor<GuidedDecisionTable52> modelCaptor = ArgumentCaptor.forClass(GuidedDecisionTable52.class);
verify(dtService, times(1)).validate(eq(path), modelCaptor.capture());
assertNotNull(modelCaptor.getValue());
assertEquals(dtPresenter.getModel(), modelCaptor.getValue());
verify(notification, times(1)).fire(any(NotificationEvent.class));
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent 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();
}
Aggregations