Search in sources :

Example 11 with ExecutionTrace

use of org.drools.workbench.models.testscenarios.shared.ExecutionTrace 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 12 with ExecutionTrace

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

the class AuditPageTest method testShowFiredRules.

@Test
public void testShowFiredRules() {
    final ExecutionTrace executionTrace = mock(ExecutionTrace.class);
    auditPage.showFiredRules(executionTrace);
    verify(auditPageView).showFiredRules(executionTrace);
}
Also used : ExecutionTrace(org.drools.workbench.models.testscenarios.shared.ExecutionTrace) Test(org.junit.Test)

Example 13 with ExecutionTrace

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

the class FixtureLayout method render.

private void render(final Scenario scenario, final ScenarioParentWidget parentWidgetToRender) {
    layoutRow = 1;
    executionTraceLine = 0;
    previousExecutionTrace = null;
    for (final Fixture fixture : fixtures) {
        if (fixture instanceof ExecutionTrace) {
            ExecutionTrace currentExecutionTrace = (ExecutionTrace) fixture;
            addExecutionTrace(currentExecutionTrace);
            previousExecutionTrace = currentExecutionTrace;
        } else if (fixture instanceof FixturesMap) {
            // add delete execution trace button if scenario has more parts
            addDeleteExecutionTraceButtonIfNotNull(scenario, previousExecutionTrace, parentWidgetToRender);
            layoutRow = addGiven((FixturesMap) fixture);
        } else if (fixture instanceof CallFixtureMap) {
            layoutRow = addCallFixture((CallFixtureMap) fixture);
        } else {
            addFixtureList((FixtureList) fixture);
        }
        layoutRow++;
    }
    // add the last delete execution trace button
    addDeleteExecutionTraceButtonIfNotNull(scenario, previousExecutionTrace, parentWidgetToRender);
    addFooter();
}
Also used : CallFixtureMap(org.drools.workbench.models.testscenarios.shared.CallFixtureMap) ExecutionTrace(org.drools.workbench.models.testscenarios.shared.ExecutionTrace) FixturesMap(org.drools.workbench.models.testscenarios.shared.FixturesMap) Fixture(org.drools.workbench.models.testscenarios.shared.Fixture)

Example 14 with ExecutionTrace

use of org.drools.workbench.models.testscenarios.shared.ExecutionTrace in project drools by kiegroup.

the class ScenarioRunner method applyFixtures.

private void applyFixtures(final List<Fixture> fixtures, final ScenarioSettings scenarioSettings) throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InvalidClockTypeException {
    for (Iterator<Fixture> iterator = fixtures.iterator(); iterator.hasNext(); ) {
        Fixture fixture = iterator.next();
        if (fixture instanceof FactData) {
            factPopulator.add(factPopulatorFactory.createFactPopulator((FactData) fixture));
        } else if (fixture instanceof RetractFact) {
            factPopulator.retractFact(((RetractFact) fixture).getName());
        } else if (fixture instanceof CallMethod) {
            workingMemoryWrapper.executeMethod((CallMethod) fixture);
        } else if (fixture instanceof ActivateRuleFlowGroup) {
            workingMemoryWrapper.activateRuleFlowGroup(((ActivateRuleFlowGroup) fixture).getName());
        } else if (fixture instanceof ExecutionTrace) {
            factPopulator.populate();
            workingMemoryWrapper.executeSubScenario((ExecutionTrace) fixture, scenarioSettings);
        } else if (fixture instanceof Expectation) {
            factPopulator.populate();
            workingMemoryWrapper.verifyExpectation((Expectation) fixture);
        } else {
            throw new IllegalArgumentException("Not sure what to do with " + fixture);
        }
    }
    factPopulator.populate();
}
Also used : FactData(org.drools.workbench.models.testscenarios.shared.FactData) ExecutionTrace(org.drools.workbench.models.testscenarios.shared.ExecutionTrace) Fixture(org.drools.workbench.models.testscenarios.shared.Fixture) ActivateRuleFlowGroup(org.drools.workbench.models.testscenarios.shared.ActivateRuleFlowGroup) Expectation(org.drools.workbench.models.testscenarios.shared.Expectation) RetractFact(org.drools.workbench.models.testscenarios.shared.RetractFact) CallMethod(org.drools.workbench.models.testscenarios.shared.CallMethod)

Example 15 with ExecutionTrace

use of org.drools.workbench.models.testscenarios.shared.ExecutionTrace in project drools by kiegroup.

the class ScenarioRunnerTest method testIntegrationWithModify.

@Test
public void testIntegrationWithModify() throws Exception {
    Scenario sc = new Scenario();
    sc.getImports().addImport(new Import("org.drools.workbench.models.testscenarios.backend.Cheese"));
    sc.getFixtures().add(new FactData("Cheese", "c1", Arrays.<Field>asList(new FieldData("price", "1")), false));
    sc.getFixtures().add(new ExecutionTrace());
    sc.getFixtures().add(new VerifyFact("c1", ls(new VerifyField("type", "rule1", "=="))));
    sc.getFixtures().add(new FactData("Cheese", "c1", Arrays.<Field>asList(new FieldData("price", "42")), true));
    sc.getFixtures().add(new ExecutionTrace());
    sc.getFixtures().add(new VerifyFact("c1", ls(new VerifyField("type", "rule3", "=="))));
    KieSession ksession = getKieSession("test_stateful.drl");
    ScenarioRunner run = new ScenarioRunner(ksession);
    run.run(sc);
    assertTrue(sc.wasSuccessful());
}
Also used : FieldData(org.drools.workbench.models.testscenarios.shared.FieldData) VerifyField(org.drools.workbench.models.testscenarios.shared.VerifyField) Field(org.drools.workbench.models.testscenarios.shared.Field) Import(org.kie.soup.project.datamodel.imports.Import) VerifyField(org.drools.workbench.models.testscenarios.shared.VerifyField) FactData(org.drools.workbench.models.testscenarios.shared.FactData) ExecutionTrace(org.drools.workbench.models.testscenarios.shared.ExecutionTrace) KieSession(org.kie.api.runtime.KieSession) VerifyFact(org.drools.workbench.models.testscenarios.shared.VerifyFact) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) Test(org.junit.Test)

Aggregations

ExecutionTrace (org.drools.workbench.models.testscenarios.shared.ExecutionTrace)26 Test (org.junit.Test)22 Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)20 FactData (org.drools.workbench.models.testscenarios.shared.FactData)16 VerifyFact (org.drools.workbench.models.testscenarios.shared.VerifyFact)13 VerifyField (org.drools.workbench.models.testscenarios.shared.VerifyField)9 FieldData (org.drools.workbench.models.testscenarios.shared.FieldData)8 VerifyRuleFired (org.drools.workbench.models.testscenarios.shared.VerifyRuleFired)8 ArrayList (java.util.ArrayList)7 KieSession (org.kie.api.runtime.KieSession)7 Import (org.kie.soup.project.datamodel.imports.Import)7 Expectation (org.drools.workbench.models.testscenarios.shared.Expectation)6 RetractFact (org.drools.workbench.models.testscenarios.shared.RetractFact)6 Field (org.drools.workbench.models.testscenarios.shared.Field)4 Fixture (org.drools.workbench.models.testscenarios.shared.Fixture)4 Date (java.util.Date)3 ActivateRuleFlowGroup (org.drools.workbench.models.testscenarios.shared.ActivateRuleFlowGroup)3 HashSet (java.util.HashSet)2 ProjectClassLoader (org.drools.core.common.ProjectClassLoader)2 KnowledgeBaseImpl (org.drools.core.impl.KnowledgeBaseImpl)2