Search in sources :

Example 1 with PlaceRequest

use of org.uberfire.mvp.PlaceRequest in project drools-wb by kiegroup.

the class ScenarioEditorPresenterTest method testRunScenario.

@Test
public void testRunScenario() throws Exception {
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    when(versionRecordManager.getCurrentPath()).thenReturn(path);
    editor.onStartup(path, placeRequest);
    reset(view);
    editor.onRunScenario();
    InOrder inOrder = inOrder(view);
    inOrder.verify(view).showBusyIndicator(TestScenarioConstants.INSTANCE.BuildingAndRunningScenario());
    inOrder.verify(view).showResults();
    inOrder.verify(view).hideBusyIndicator();
    verify(settingsPage).refresh(view, path, scenario);
    verify(auditPage).showFiredRulesAuditLog(Collections.emptySet());
    verify(auditPage).showFiredRules(notNull(ExecutionTrace.class));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) InOrder(org.mockito.InOrder) ExecutionTrace(org.drools.workbench.models.testscenarios.shared.ExecutionTrace) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 2 with PlaceRequest

use of org.uberfire.mvp.PlaceRequest in project drools-wb by kiegroup.

the class ScenarioEditorPresenterTest method testRunScenarioAndSave.

@Test
public void testRunScenarioAndSave() throws Exception {
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    when(versionRecordManager.getCurrentPath()).thenReturn(path);
    editor.onStartup(path, placeRequest);
    reset(view);
    reset(importsWidget);
    editor.onRunScenario();
    // Make sure imports are updated
    verify(importsWidget).setContent(any(AsyncPackageDataModelOracle.class), eq(scenarioRunResult.getImports()), anyBoolean());
    editor.save("Commit message");
    verify(service).save(any(Path.class), scenarioArgumentCaptor.capture(), any(Metadata.class), anyString());
    assertEquals(scenarioRunResult, scenarioArgumentCaptor.getValue());
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 3 with PlaceRequest

use of org.uberfire.mvp.PlaceRequest in project drools-wb by kiegroup.

the class ScenarioEditorPresenterTest method testEmptyScenario.

@Test
public void testEmptyScenario() throws Exception {
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    when(versionRecordManager.getCurrentPath()).thenReturn(path);
    editor.onStartup(path, placeRequest);
    verify(view).renderFixtures(eq(path), any(AsyncPackageDataModelOracle.class), eq(scenario));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 4 with PlaceRequest

use of org.uberfire.mvp.PlaceRequest in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerPresenterTest method refreshingDecisionTableRetainsExistingLocation.

@Test
public void refreshingDecisionTableRetainsExistingLocation() {
    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 Point2D dtLocation = new Point2D(100, 100);
    when(dtView.getLocation()).thenReturn(dtLocation);
    final ArgumentCaptor<Command> afterRemovalCommandCaptor = ArgumentCaptor.forClass(Command.class);
    presenter.refreshDecisionTable(dtPresenter, path, placeRequest, dtContent, false);
    verify(dtView, times(1)).getLocation();
    verify(view, times(1)).removeDecisionTable(eq(dtView), afterRemovalCommandCaptor.capture());
    final Command afterRemovalCommand = afterRemovalCommandCaptor.getValue();
    assertNotNull(afterRemovalCommand);
    afterRemovalCommand.execute();
    verify(dtView, times(1)).setLocation(eq(dtLocation));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) Point2D(com.ait.lienzo.client.core.types.Point2D) Command(com.google.gwt.user.client.Command) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 5 with PlaceRequest

use of org.uberfire.mvp.PlaceRequest 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());
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) 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)

Aggregations

PlaceRequest (org.uberfire.mvp.PlaceRequest)36 ObservablePath (org.uberfire.backend.vfs.ObservablePath)33 Test (org.junit.Test)29 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)26 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)25 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)13 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 GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)10 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)7 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)6 Path (org.uberfire.backend.vfs.Path)6 GuidedDecisionTableGraphEntry (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry)5 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)4 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)4 MultiPageEditor (org.uberfire.client.workbench.widgets.multipage.MultiPageEditor)3 Scheduler (com.google.gwt.core.client.Scheduler)2 Command (com.google.gwt.user.client.Command)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2