Search in sources :

Example 11 with GuidedDecisionTableEditorContent

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));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 12 with GuidedDecisionTableEditorContent

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));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) ArrayList(java.util.ArrayList) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) List(java.util.List) ArrayList(java.util.ArrayList) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 13 with GuidedDecisionTableEditorContent

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);
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) OverviewWidgetPresenter(org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 14 with GuidedDecisionTableEditorContent

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);
}
Also used : ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) ArrayList(java.util.ArrayList) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 15 with GuidedDecisionTableEditorContent

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());
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) Overview(org.guvnor.common.services.shared.metadata.model.Overview) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Aggregations

GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)33 ObservablePath (org.uberfire.backend.vfs.ObservablePath)28 PlaceRequest (org.uberfire.mvp.PlaceRequest)27 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)24 Test (org.junit.Test)24 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)12 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)12 DecisionTableSelectedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)10 Path (org.uberfire.backend.vfs.Path)9 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)8 Overview (org.guvnor.common.services.shared.metadata.model.Overview)7 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)7 GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)6 PortableWorkDefinition (org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition)5 GuidedDecisionTableGraphEntry (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry)5 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)4 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Set (java.util.Set)3