Search in sources :

Example 21 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools-wb by kiegroup.

the class ScenarioTestEditorServiceImplTest method loadBrokenScenarioNullPackage.

@Test
public void loadBrokenScenarioNullPackage() throws Exception {
    when(moduleService.resolvePackage(path)).thenReturn(null);
    final Scenario load = testEditorService.load(path);
    assertNotNull(load);
    assertNull(load.getPackageName());
    assertNotNull(load.getImports());
}
Also used : Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) Test(org.junit.Test)

Example 22 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools-wb by kiegroup.

the class ScenarioEditorPresenterTest method setUp.

@Before
public void setUp() throws Exception {
    final AsyncPackageDataModelOracleFactory modelOracleFactory = mock(AsyncPackageDataModelOracleFactory.class);
    fakeService = new CallerMock<>(service);
    editor = spy(new ScenarioEditorPresenter(view, user, importsWidget, fakeService, new CallerMock<>(testService), new TestScenarioResourceType(new Others()), modelOracleFactory, settingsPage, auditPage) {

        {
            kieView = ScenarioEditorPresenterTest.this.kieView;
            versionRecordManager = ScenarioEditorPresenterTest.this.versionRecordManager;
            overviewWidget = ScenarioEditorPresenterTest.this.overviewWidget;
            notification = makeNotificationEvent();
            fileMenuBuilder = ScenarioEditorPresenterTest.this.fileMenuBuilder;
            projectController = ScenarioEditorPresenterTest.this.projectController;
            workbenchContext = ScenarioEditorPresenterTest.this.workbenchContext;
            versionRecordManager = ScenarioEditorPresenterTest.this.versionRecordManager;
            alertsButtonMenuItemBuilder = ScenarioEditorPresenterTest.this.alertsButtonMenuItemBuilder;
        }

        @Override
        protected Command getSaveAndRename() {
            return mock(Command.class);
        }
    });
    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(Path.class))).thenReturn(testScenarioModelContent);
    final TestScenarioResult result = new TestScenarioResult(scenarioRunResult, Collections.EMPTY_SET);
    when(service.runScenario(eq("userName"), any(Path.class), eq(scenario))).thenReturn(result);
    final AsyncPackageDataModelOracle dmo = mock(AsyncPackageDataModelOracle.class);
    when(modelOracleFactory.makeAsyncPackageDataModelOracle(any(Path.class), any(HasImports.class), any(PackageDataModelOracleBaselinePayload.class))).thenReturn(dmo);
    when(alertsButtonMenuItemBuilder.build()).thenReturn(alertsButtonMenuItem);
}
Also used : ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) Others(org.uberfire.workbench.category.Others) TestScenarioModelContent(org.drools.workbench.screens.testscenario.model.TestScenarioModelContent) 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) 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) HasImports(org.kie.soup.project.datamodel.imports.HasImports) Before(org.junit.Before)

Example 23 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools-wb by kiegroup.

the class FixtureLayoutTest method testDeleteExecutionTraceButtonSomeExecutionTraceRenderedAlready.

@Test
public void testDeleteExecutionTraceButtonSomeExecutionTraceRenderedAlready() throws Exception {
    final Scenario scenario = mock(Scenario.class);
    final ExecutionTrace executionTrace = mock(ExecutionTrace.class);
    final ScenarioParentWidget parentWidgetToRender = mock(ScenarioParentWidget.class);
    testedLayout.addDeleteExecutionTraceButtonIfNotNull(scenario, executionTrace, parentWidgetToRender);
    verify(testedLayout).setWidget(eq(0), eq(0), eq(deleteExecutionTraceButton));
    verify(deleteExecutionTraceButton).init(scenario, executionTrace, parentWidgetToRender);
}
Also used : ExecutionTrace(org.drools.workbench.models.testscenarios.shared.ExecutionTrace) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) Test(org.junit.Test)

Example 24 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools-wb by kiegroup.

the class ScenarioUtilsTest method testFindExecutionTraceDefault.

@Test
public void testFindExecutionTraceDefault() throws Exception {
    final Scenario scenario = new Scenario();
    Assert.assertNotNull(ScenarioUtils.findExecutionTrace(scenario));
}
Also used : Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) Test(org.junit.Test)

Example 25 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools-wb by kiegroup.

the class TestScenarioFactory method makeTestScenarioWithVerifyFact.

public static Scenario makeTestScenarioWithVerifyFact(final String packageName, final Collection<Import> imports, final String name) {
    final Scenario model = new Scenario();
    model.getImports().getImports().addAll(imports);
    model.setPackageName(packageName);
    model.setName(name);
    model.getFixtures().add(new FactData("Applicant", "$a", new ArrayList<Field>() {

        {
            add(new FieldData("age", "33"));
        }
    }, false));
    model.getFixtures().add(new VerifyFact("Mortgage", new ArrayList<VerifyField>() {

        {
            add(new VerifyField("amount", "10000", "=="));
        }
    }, true));
    return model;
}
Also used : FieldData(org.drools.workbench.models.testscenarios.shared.FieldData) VerifyField(org.drools.workbench.models.testscenarios.shared.VerifyField) FactData(org.drools.workbench.models.testscenarios.shared.FactData) ArrayList(java.util.ArrayList) VerifyFact(org.drools.workbench.models.testscenarios.shared.VerifyFact) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario)

Aggregations

Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)59 Test (org.junit.Test)45 FactData (org.drools.workbench.models.testscenarios.shared.FactData)24 ExecutionTrace (org.drools.workbench.models.testscenarios.shared.ExecutionTrace)20 VerifyFact (org.drools.workbench.models.testscenarios.shared.VerifyFact)17 KieSession (org.kie.api.runtime.KieSession)14 Import (org.kie.soup.project.datamodel.imports.Import)14 VerifyField (org.drools.workbench.models.testscenarios.shared.VerifyField)13 FieldData (org.drools.workbench.models.testscenarios.shared.FieldData)12 ArrayList (java.util.ArrayList)11 VerifyRuleFired (org.drools.workbench.models.testscenarios.shared.VerifyRuleFired)9 Expectation (org.drools.workbench.models.testscenarios.shared.Expectation)6 Path (org.uberfire.backend.vfs.Path)6 Field (org.drools.workbench.models.testscenarios.shared.Field)5 HashMap (java.util.HashMap)4 RetractFact (org.drools.workbench.models.testscenarios.shared.RetractFact)4 Failure (org.junit.runner.notification.Failure)4 RunListener (org.junit.runner.notification.RunListener)4 RunNotifier (org.junit.runner.notification.RunNotifier)4 Date (java.util.Date)3