use of org.drools.workbench.models.testscenarios.shared.FieldData 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.FieldData 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.FieldData 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);
}
}
use of org.drools.workbench.models.testscenarios.shared.FieldData in project drools-wb by kiegroup.
the class FieldConstraintHelper method getEnums.
DropDownData getEnums() {
Map<String, String> currentValueMap = new HashMap<String, String>();
for (Field f : fact.getFieldData()) {
if (f instanceof FieldData) {
FieldData otherFieldData = (FieldData) f;
currentValueMap.put(otherFieldData.getName(), otherFieldData.getValue());
}
}
return oracle.getEnums(factType, field.getName(), currentValueMap);
}
use of org.drools.workbench.models.testscenarios.shared.FieldData in project drools-wb by kiegroup.
the class FieldSelectorWidget method createField.
private Field createField(final SelectionEvent<Integer> selectionEvent) {
if (selectionEvent.getSelectedItem() == FieldData.TYPE_FACT) {
return new FactAssignmentField(field.getName(), helper.getFieldType());
} else {
if (selectionEvent.getSelectedItem() == FieldData.TYPE_COLLECTION) {
CollectionFieldData collectionFieldData = new CollectionFieldData();
collectionFieldData.setName(field.getName());
return collectionFieldData;
} else {
FieldData fieldData = new FieldData(field.getName(), "");
fieldData.setNature(selectionEvent.getSelectedItem());
return fieldData;
}
}
}
Aggregations