Search in sources :

Example 6 with Fixture

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

the class ScenarioTestEditorServiceImplTest method runScenarioWithDependentImports.

@Test
public void runScenarioWithDependentImports() throws Exception {
    final ArrayList<Fixture> fixtures = new ArrayList<Fixture>() {

        {
            add(factData("java.sql.ClientInfoStatus"));
        }
    };
    final Map<String, ModelField[]> modelFields = new HashMap<String, ModelField[]>() {

        {
            put("java.sql.ClientInfoStatus", new ModelField[] { modelField("java.sql.JDBCType") });
        }
    };
    when(scenario.getFixtures()).thenReturn(fixtures);
    when(dataModelService.getDataModel(path)).thenReturn(modelOracle);
    when(modelOracle.getModuleModelFields()).thenReturn(modelFields);
    when(scenario.getImports()).thenReturn(new Imports());
    testEditorService.addDependentImportsToScenario(scenario, path);
    assertEquals(2, scenario.getImports().getImports().size());
}
Also used : ModelField(org.kie.soup.project.datamodel.oracle.ModelField) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Fixture(org.drools.workbench.models.testscenarios.shared.Fixture) Mockito.anyString(org.mockito.Mockito.anyString) Imports(org.kie.soup.project.datamodel.imports.Imports) Test(org.junit.Test)

Example 7 with Fixture

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

the class ScenarioTestEditorServiceImplTest method checkDependentImportsWithPrimitiveTypes.

@Test
public void checkDependentImportsWithPrimitiveTypes() throws Exception {
    final ArrayList<Fixture> fixtures = new ArrayList<>();
    final Imports imports = new Imports() {

        {
            addImport(new Import("int"));
        }
    };
    final Map<String, ModelField[]> modelFields = new HashMap<String, ModelField[]>() {

        {
            put("java.sql.ClientInfoStatus", new ModelField[] { modelField("java.sql.JDBCType") });
        }
    };
    when(scenario.getFixtures()).thenReturn(fixtures);
    when(dataModelService.getDataModel(path)).thenReturn(modelOracle);
    when(modelOracle.getModuleModelFields()).thenReturn(modelFields);
    when(scenario.getImports()).thenCallRealMethod();
    doCallRealMethod().when(scenario).setImports(any(Imports.class));
    scenario.setImports(imports);
    testEditorService.addDependentImportsToScenario(scenario, path);
    assertEquals(1, scenario.getImports().getImports().size());
}
Also used : Import(org.kie.soup.project.datamodel.imports.Import) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Fixture(org.drools.workbench.models.testscenarios.shared.Fixture) Imports(org.kie.soup.project.datamodel.imports.Imports) Mockito.anyString(org.mockito.Mockito.anyString) Test(org.junit.Test)

Example 8 with Fixture

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

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

the class ScenarioTestEditorServiceImplTest method runScenarioWithDependentImportsAndWithoutFactData.

@Test
public void runScenarioWithDependentImportsAndWithoutFactData() throws Exception {
    final ArrayList<Fixture> fixtures = new ArrayList<Fixture>();
    final Imports imports = new Imports() {

        {
            addImport(new Import("java.sql.ClientInfoStatus"));
        }
    };
    final Map<String, ModelField[]> modelFields = new HashMap<String, ModelField[]>() {

        {
            put("java.sql.ClientInfoStatus", new ModelField[] { modelField("java.sql.JDBCType") });
        }
    };
    when(scenario.getFixtures()).thenReturn(fixtures);
    when(dataModelService.getDataModel(path)).thenReturn(modelOracle);
    when(modelOracle.getModuleModelFields()).thenReturn(modelFields);
    when(scenario.getImports()).thenReturn(imports);
    testEditorService.addDependentImportsToScenario(scenario, path);
    assertEquals(2, scenario.getImports().getImports().size());
}
Also used : Import(org.kie.soup.project.datamodel.imports.Import) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Fixture(org.drools.workbench.models.testscenarios.shared.Fixture) Imports(org.kie.soup.project.datamodel.imports.Imports) Mockito.anyString(org.mockito.Mockito.anyString) Test(org.junit.Test)

Example 10 with Fixture

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

the class DataInputWidget method renderEditor.

public void renderEditor() {
    clear();
    if (definitionList.size() == 0) {
        parent.renderEditor();
    }
    // This will work out what row is for what field, adding labels and remove icons
    FactDataWidgetFactory factDataWidgetFactory = new FactDataWidgetFactory(scenario, oracle, definitionList, executionTrace, this, this);
    for (Fixture fixture : definitionList) {
        if (fixture instanceof FactData) {
            factDataWidgetFactory.build(headerText, (FactData) fixture);
        }
    }
    getFlexCellFormatter().setHorizontalAlignment(factDataWidgetFactory.amountOrRows() + 1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    if (factDataWidgetFactory.amountOrRows() == 0) {
        setWidget(1, 1, new ClickableLabel(TestScenarioConstants.INSTANCE.AddAField(), new AddFieldToFactDataClickHandler(definitionList, oracle, parent)));
    }
    ScenarioUtils.addBottomAndRightPaddingToTableCells(this);
}
Also used : FactData(org.drools.workbench.models.testscenarios.shared.FactData) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) Fixture(org.drools.workbench.models.testscenarios.shared.Fixture)

Aggregations

Fixture (org.drools.workbench.models.testscenarios.shared.Fixture)12 ArrayList (java.util.ArrayList)5 FactData (org.drools.workbench.models.testscenarios.shared.FactData)5 Test (org.junit.Test)5 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)5 HashMap (java.util.HashMap)4 ActivateRuleFlowGroup (org.drools.workbench.models.testscenarios.shared.ActivateRuleFlowGroup)4 ExecutionTrace (org.drools.workbench.models.testscenarios.shared.ExecutionTrace)4 Import (org.kie.soup.project.datamodel.imports.Import)4 Imports (org.kie.soup.project.datamodel.imports.Imports)4 Mockito.anyString (org.mockito.Mockito.anyString)4 FixturesMap (org.drools.workbench.models.testscenarios.shared.FixturesMap)3 RetractFact (org.drools.workbench.models.testscenarios.shared.RetractFact)3 VerifyFact (org.drools.workbench.models.testscenarios.shared.VerifyFact)3 VerifyRuleFired (org.drools.workbench.models.testscenarios.shared.VerifyRuleFired)3 CallFixtureMap (org.drools.workbench.models.testscenarios.shared.CallFixtureMap)2 CallMethod (org.drools.workbench.models.testscenarios.shared.CallMethod)2 Expectation (org.drools.workbench.models.testscenarios.shared.Expectation)2 Field (org.drools.workbench.models.testscenarios.shared.Field)2 FixtureList (org.drools.workbench.models.testscenarios.shared.FixtureList)2