use of org.drools.workbench.models.testscenarios.shared.FactData in project drools-wb by kiegroup.
the class MethodParameterCallValueEditor method boundVariable.
private ListBox boundVariable(final FieldNature c) {
/*
* If there is a bound variable that is the same type of the current
* variable type, then propose a list
*/
final ListBox listVariable = new ListBox();
List<String> vars = model.getFactNamesInScope(ex, true);
for (String v : vars) {
FactData factData = (FactData) model.getFactTypes().get(v);
if (factData.getType().equals(this.methodParameter.type)) {
// First selection is empty
if (listVariable.getItemCount() == 0) {
listVariable.addItem("...");
}
listVariable.addItem("=" + v);
}
}
if (methodParameter.value.equals("=")) {
listVariable.setSelectedIndex(0);
} else {
for (int i = 0; i < listVariable.getItemCount(); i++) {
if (listVariable.getItemText(i).equals(methodParameter.value)) {
listVariable.setSelectedIndex(i);
}
}
}
if (listVariable.getItemCount() > 0) {
listVariable.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
methodParameter.value = listVariable.getValue(listVariable.getSelectedIndex());
refresh();
}
});
}
return listVariable;
}
use of org.drools.workbench.models.testscenarios.shared.FactData in project drools-wb by kiegroup.
the class ScenarioHelper method lumpyMap.
/**
* Called lumpy map - as this takes a flat list of fixtures, and groups
* things together. It will return a list - of which each element will
* either be a list - or a map. If its a map - then its a map of FactData to
* the fact type. If its a list, then it will be expectations or
* retractions.
* <p/>
* Man, this will be so much nicer with generics.
* @return List<List<VeryifyRuleFired or VerifyFact or RetractFact> OR
* Map<String, List<FactData>> OR ExecutionTrace>
*/
public List<Fixture> lumpyMap(final List<Fixture> fixtures) {
List<Fixture> output = new ArrayList<Fixture>();
FixturesMap dataInput = new FixturesMap();
CallFixtureMap callOnDataInput = new CallFixtureMap();
FixtureList verifyFact = new FixtureList();
FixtureList verifyRule = new FixtureList();
FixtureList retractFacts = new FixtureList();
for (Fixture fixture : fixtures) {
if (fixture instanceof FactData) {
accumulateDataForFactData(dataInput, (FactData) fixture);
} else if (fixture instanceof CallMethod) {
accumulateCallMethod(callOnDataInput, (CallMethod) fixture);
} else if (fixture instanceof ActivateRuleFlowGroup) {
accumulateDataForActivateRuleFlowGroup(dataInput, fixture);
} else if (fixture instanceof RetractFact) {
retractFacts.add(fixture);
} else if (fixture instanceof VerifyRuleFired) {
verifyRule.add(fixture);
} else if (fixture instanceof VerifyFact) {
verifyFact.add(fixture);
} else if (fixture instanceof ExecutionTrace) {
gatherFixtures(output, dataInput, callOnDataInput, verifyFact, verifyRule, retractFacts, false);
output.add(fixture);
verifyRule = new FixtureList();
verifyFact = new FixtureList();
retractFacts = new FixtureList();
callOnDataInput = new CallFixtureMap();
dataInput = new FixturesMap();
}
}
gatherFixtures(output, dataInput, callOnDataInput, verifyFact, verifyRule, retractFacts, true);
return output;
}
use of org.drools.workbench.models.testscenarios.shared.FactData in project drools-wb by kiegroup.
the class VerifyFieldConstraintEditor method isThereABoundVariableToSet.
private boolean isThereABoundVariableToSet() {
boolean retour = false;
List<String> vars = this.scenario.getFactNamesInScope(executionTrace, true);
if (vars.size() > 0) {
for (int i = 0; i < vars.size(); i++) {
String var = vars.get(i);
FactData f = scenario.getFactTypes().get(var);
String fieldType = oracle.getFieldType(this.factType, field.getFieldName());
if (f.getType().equals(fieldType)) {
retour = true;
break;
}
}
}
return retour;
}
use of org.drools.workbench.models.testscenarios.shared.FactData in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImplTest method loadScenario.
@Test
public void loadScenario() throws Exception {
final URL scenarioResource = getClass().getResource("Are they old enough.scenario");
final Path scenarioPath = PathFactory.newPath(scenarioResource.getFile(), scenarioResource.toURI().toString());
final Scenario loadedScenario = testEditorService.load(scenarioPath);
assertNotNull(loadedScenario);
assertEquals("mortgages.mortgages", loadedScenario.getPackageName());
assertEquals(5, loadedScenario.getFixtures().size());
assertTrue(loadedScenario.getFixtures().get(0) instanceof FactData);
assertTrue(loadedScenario.getFixtures().get(1) instanceof FactData);
assertTrue(loadedScenario.getFixtures().get(2) instanceof FactData);
assertTrue(loadedScenario.getFixtures().get(3) instanceof ExecutionTrace);
assertTrue(loadedScenario.getFixtures().get(4) instanceof VerifyFact);
}
Aggregations