Search in sources :

Example 1 with TestScenarioModelContent

use of org.drools.workbench.screens.testscenario.model.TestScenarioModelContent in project drools-wb by kiegroup.

the class ScenarioTestEditorServiceImpl method constructContent.

@Override
protected TestScenarioModelContent constructContent(Path path, Overview overview) {
    final Scenario scenario = load(path);
    final String packageName = moduleService.resolvePackage(path).getPackageName();
    final PackageDataModelOracle dataModelOracle = getDataModel(path);
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    final Set<String> usedFullyQualifiedClassNames = getUsedFullyQualifiedClassNames(scenario, dataModelOracle);
    DataModelOracleUtilities.populateDataModel(dataModelOracle, dataModel, usedFullyQualifiedClassNames);
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new TestScenarioModelContent(scenario, overview, packageName, dataModel);
}
Also used : PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) TestScenarioModelContent(org.drools.workbench.screens.testscenario.model.TestScenarioModelContent) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario)

Example 2 with TestScenarioModelContent

use of org.drools.workbench.screens.testscenario.model.TestScenarioModelContent in project drools-wb by kiegroup.

the class ScenarioEditorPresenterTest method setUp.

@Before
public void setUp() throws Exception {
    promises = new SyncPromises();
    final AsyncPackageDataModelOracleFactory modelOracleFactory = mock(AsyncPackageDataModelOracleFactory.class);
    fakeService = new CallerMock<>(service);
    editor = spy(new ScenarioEditorPresenter(view, user, importsWidget, fakeService, new TestScenarioResourceType(new Decision()), modelOracleFactory, settingsPage, auditPage, testRunnerReportingPanel, testReportingDocksHandler, showTestPanelEvent, hideTestPanelEvent) {

        {
            docks = ScenarioEditorPresenterTest.this.docks;
            kieView = ScenarioEditorPresenterTest.this.kieView;
            versionRecordManager = ScenarioEditorPresenterTest.this.versionRecordManager;
            overviewWidget = ScenarioEditorPresenterTest.this.overviewWidget;
            notification = ScenarioEditorPresenterTest.this.notificationEventMock;
            fileMenuBuilder = ScenarioEditorPresenterTest.this.fileMenuBuilder;
            projectController = ScenarioEditorPresenterTest.this.projectController;
            workbenchContext = ScenarioEditorPresenterTest.this.workbenchContext;
            versionRecordManager = ScenarioEditorPresenterTest.this.versionRecordManager;
            alertsButtonMenuItemBuilder = ScenarioEditorPresenterTest.this.alertsButtonMenuItemBuilder;
            perspectiveManager = ScenarioEditorPresenterTest.this.perspectiveManager;
            placeManager = ScenarioEditorPresenterTest.this.placeManager;
            promises = ScenarioEditorPresenterTest.this.promises;
        }

        @Override
        protected Command getSaveAndRename() {
            return mock(Command.class);
        }
    });
    doNothing().when(editor).addDownloadMenuItem(any());
    scenarioRunResult = new Scenario();
    scenario = new Scenario();
    overview = new Overview();
    when(user.getIdentifier()).thenReturn("userName");
    when(workbenchContext.getActiveOrganizationalUnit()).thenReturn(Optional.empty());
    when(workbenchContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    final TestScenarioModelContent testScenarioModelContent = new TestScenarioModelContent(scenario, overview, "org.test", new PackageDataModelOracleBaselinePayload());
    when(service.loadContent(any())).thenReturn(testScenarioModelContent);
    final TestScenarioResult result = new TestScenarioResult(scenarioRunResult, Collections.EMPTY_SET, mock(TestResultMessage.class));
    when(service.runScenario(eq("userName"), any(), eq(scenario))).thenReturn(result);
    final AsyncPackageDataModelOracle dmo = mock(AsyncPackageDataModelOracle.class);
    when(modelOracleFactory.makeAsyncPackageDataModelOracle(any(), any(), any())).thenReturn(dmo);
    when(alertsButtonMenuItemBuilder.build()).thenReturn(alertsButtonMenuItem);
    when(perspectiveManager.getCurrentPerspective()).thenReturn(mock(PerspectiveActivity.class));
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) PerspectiveActivity(org.uberfire.client.mvp.PerspectiveActivity) SyncPromises(org.uberfire.promise.SyncPromises) TestScenarioModelContent(org.drools.workbench.screens.testscenario.model.TestScenarioModelContent) TestResultMessage(org.guvnor.common.services.shared.test.TestResultMessage) TestScenarioResourceType(org.drools.workbench.screens.testscenario.client.type.TestScenarioResourceType) Overview(org.guvnor.common.services.shared.metadata.model.Overview) TestScenarioResult(org.drools.workbench.screens.testscenario.model.TestScenarioResult) Decision(org.guvnor.common.services.project.categories.Decision) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) AsyncPackageDataModelOracleFactory(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleFactory) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) Before(org.junit.Before)

Aggregations

Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)2 TestScenarioModelContent (org.drools.workbench.screens.testscenario.model.TestScenarioModelContent)2 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)2 TestScenarioResourceType (org.drools.workbench.screens.testscenario.client.type.TestScenarioResourceType)1 TestScenarioResult (org.drools.workbench.screens.testscenario.model.TestScenarioResult)1 Decision (org.guvnor.common.services.project.categories.Decision)1 Overview (org.guvnor.common.services.shared.metadata.model.Overview)1 TestResultMessage (org.guvnor.common.services.shared.test.TestResultMessage)1 Before (org.junit.Before)1 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)1 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)1 AsyncPackageDataModelOracleFactory (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleFactory)1 PerspectiveActivity (org.uberfire.client.mvp.PerspectiveActivity)1 SyncPromises (org.uberfire.promise.SyncPromises)1 ResourceOpenedEvent (org.uberfire.workbench.events.ResourceOpenedEvent)1