use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent 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));
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkOnValidateWithErrors.
@Test
@SuppressWarnings("unchecked")
public void checkOnValidateWithErrors() {
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 List<ValidationMessage> validationMessages = new ArrayList<ValidationMessage>() {
{
add(new ValidationMessage());
}
};
when(dtService.validate(any(Path.class), any(GuidedDecisionTable52.class))).thenReturn(validationMessages);
doNothing().when(presenter).showValidationPopup(any(List.class));
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, never()).fire(any(NotificationEvent.class));
verify(presenter, times(1)).showValidationPopup(eq(validationMessages));
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkBuildModelFromEditor.
@Test
public void checkBuildModelFromEditor() {
final ObservablePath dtPath1 = mock(ObservablePath.class);
final PlaceRequest dtPlaceRequest1 = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent dtContent1 = makeDecisionTableContent(0);
final GuidedDecisionTableView.Presenter dtPresenter1 = makeDecisionTable(dtPath1, dtPath1, dtPlaceRequest1, dtContent1);
final ObservablePath dtPath2 = mock(ObservablePath.class);
final PlaceRequest dtPlaceRequest2 = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent dtContent2 = makeDecisionTableContent(0);
final GuidedDecisionTableView.Presenter dtPresenter2 = makeDecisionTable(dtPath2, dtPath2, dtPlaceRequest2, dtContent2);
when(dtPresenter1.getView().getX()).thenReturn(100.0);
when(dtPresenter1.getView().getY()).thenReturn(110.0);
when(dtPresenter2.getView().getX()).thenReturn(200.0);
when(dtPresenter2.getView().getY()).thenReturn(220.0);
when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter1);
add(dtPresenter2);
}
});
final GuidedDecisionTableEditorGraphModel model = presenter.buildModelFromEditor();
assertNotNull(model);
assertNotNull(model.getEntries());
assertEquals(2, model.getEntries().size());
assertContains(model.getEntries(), dtPath1, 100.0, 110.0);
assertContains(model.getEntries(), dtPath2, 200.0, 220.0);
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkOnOpenDocumentsInEditor.
@Test
public void checkOnOpenDocumentsInEditor() {
final Path dtPath1 = PathFactory.newPath("file1", "file1Url");
final Path dtPath2 = PathFactory.newPath("file2", "file2Url");
final List<Path> dtPaths = new ArrayList<Path>() {
{
add(dtPath1);
add(dtPath2);
}
};
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);
when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), any(GuidedDecisionTableEditorContent.class), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter);
presenter.onOpenDocumentsInEditor(dtPaths);
verify(dtService, times(2)).loadContent(dtPathCaptor.capture());
final List<Path> dtLoadedPaths = dtPathCaptor.getAllValues();
assertNotNull(dtLoadedPaths);
assertEquals(2, dtLoadedPaths.size());
assertContains(dtLoadedPaths, dtPath1);
assertContains(dtLoadedPaths, dtPath2);
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method testGetContentSupplier.
@Test
public void testGetContentSupplier() {
final GuidedDecisionTableView.Presenter presenter = mock(GuidedDecisionTableView.Presenter.class);
final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
final Overview overview = mock(Overview.class);
final ObservablePath currentPath = mock(ObservablePath.class);
final ObservablePath latestPath = mock(ObservablePath.class);
doReturn(model).when(presenter).getModel();
doReturn(overview).when(presenter).getOverview();
doReturn(currentPath).when(presenter).getCurrentPath();
doReturn(latestPath).when(presenter).getLatestPath();
doReturn(asSet(presenter)).when(this.presenter).getAvailableDecisionTables();
final List<GuidedDecisionTableEditorContent> content = this.presenter.getContentSupplier().get();
final GuidedDecisionTableEditorContent firstContent = content.get(0);
assertEquals(1, content.size());
assertEquals(model, firstContent.getModel());
assertEquals(overview, firstContent.getOverview());
assertEquals(currentPath, firstContent.getCurrentPath());
assertEquals(latestPath, firstContent.getLatestPath());
}
Aggregations