use of org.drools.workbench.models.testscenarios.shared.FactData in project drools by kiegroup.
the class FactPopulatorTest method testDateField.
@Test
public void testDateField() throws Exception {
factPopulator.add(new NewFactPopulator(populatedData, getTypeResolver(), new FactData("Cheese", "c1", Arrays.<Field>asList(new FieldData("type", "cheddar"), new FieldData("usedBy", "10-Jul-2008")), false)));
factPopulator.add(new NewFactPopulator(populatedData, getTypeResolver(), new FactData("OuterFact", "p1", Arrays.<Field>asList(new FieldData("name", "mic"), new FieldData("innerFact", "=c1")), false)));
factPopulator.populate();
assertTrue(populatedData.containsKey("c1"));
assertTrue(populatedData.containsKey("p1"));
Cheese c = (Cheese) populatedData.get("c1");
assertNotNull(c.getUsedBy());
}
use of org.drools.workbench.models.testscenarios.shared.FactData in project drools by kiegroup.
the class NewFactPopulatorTest method testDummyRunNoRules.
@Test
public void testDummyRunNoRules() throws Exception {
typeResolver.addImport("org.drools.workbench.models.testscenarios.backend.Cheese");
List<Field> fieldData = new ArrayList<Field>();
fieldData.add(new FieldData("type", "cheddar"));
fieldData.add(new FieldData("price", "42"));
FactData fact = new FactData("Cheese", "c1", fieldData, false);
NewFactPopulator newFactPopulator = new NewFactPopulator(populatedData, typeResolver, fact);
newFactPopulator.populate(workingMemory, new HashMap<String, FactHandle>());
assertTrue(populatedData.containsKey("c1"));
assertNotNull(populatedData.get("c1"));
verify(workingMemory).insert(populatedData.get("c1"));
}
use of org.drools.workbench.models.testscenarios.shared.FactData in project drools-wb by kiegroup.
the class TestScenarioFactory method makeTestScenarioWithGlobalVerifyGlobal.
public static Scenario makeTestScenarioWithGlobalVerifyGlobal(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.getGlobals().add(new FactData("Date", "day", new ArrayList<Field>(), false));
model.getFixtures().add(new VerifyFact("day", new ArrayList<VerifyField>() {
{
add(new VerifyField("minutes", "45", "=="));
}
}, false));
return model;
}
use of org.drools.workbench.models.testscenarios.shared.FactData 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);
}
use of org.drools.workbench.models.testscenarios.shared.FactData in project drools-wb by kiegroup.
the class FactDataWidgetFactory method build.
public void build(final String headerText, final Fact fact) {
if (fact instanceof FactData) {
FactData factData = (FactData) fact;
widget.setWidget(0, ++col, new SmallLabel("[" + factData.getName() + "]"));
} else {
col++;
}
widget.setWidget(0, 0, new ClickableLabel(headerText, createAddFieldButton(fact)));
Map<FieldData, FieldDataConstraintEditor> enumEditorMap = new HashMap<FieldData, FieldDataConstraintEditor>();
// Sets row name and delete button.
for (final Field field : fact.getFieldData()) {
// Avoid duplicate field rows, only one for each name.
if (rowIndexByFieldName.doesNotContain(field.getName())) {
newRow(fact, field.getName());
}
// Sets row data
int fieldRowIndex = rowIndexByFieldName.getRowIndex(field.getName());
IsWidget editableCell = editableCell(field, fact, fact.getType());
widget.setWidget(fieldRowIndex, col, editableCell);
if (field instanceof FieldData) {
FieldData fieldData = (FieldData) field;
if (fieldData.getNature() == FieldData.TYPE_ENUM) {
enumEditorMap.put(fieldData, (FieldDataConstraintEditor) editableCell);
}
}
}
for (FieldDataConstraintEditor outerEnumEditor : enumEditorMap.values()) {
for (FieldDataConstraintEditor innerEnumEditor : enumEditorMap.values()) {
if (outerEnumEditor != innerEnumEditor) {
outerEnumEditor.addIfDependentEnumEditor(innerEnumEditor);
}
}
}
if (fact instanceof FactData) {
DeleteFactColumnButton deleteFactColumnButton = new DeleteFactColumnButton((FactData) fact);
widget.setWidget(rowIndexByFieldName.amountOrRows() + 1, col, deleteFactColumnButton);
}
}
Aggregations