use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52 in project drools-wb by kiegroup.
the class GuidedDecisionTableTest method testNumeric.
@Test
@SuppressWarnings("serial")
public void testNumeric() {
final GuidedDecisionTable52 model = new GuidedDecisionTable52();
final ModuleDataModelOracle loader = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator()).addFact("Driver").addField(new ModelField("age", Integer.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_NUMERIC_INTEGER)).addField(new ModelField("name", String.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_STRING)).end().build();
// Emulate server-to-client conversions
final AsyncPackageDataModelOracle oracle = getOracle();
final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
dataModel.setModelFields(loader.getModuleModelFields());
populateDataModelOracle(mock(Path.class), model, oracle, dataModel);
final ColumnUtilities utils = new ColumnUtilities(model, oracle);
final AttributeCol52 at = new AttributeCol52();
at.setAttribute(Attribute.SALIENCE.getAttributeName());
final AttributeCol52 at_ = new AttributeCol52();
at_.setAttribute(Attribute.ENABLED.getAttributeName());
model.getAttributeCols().add(at);
model.getAttributeCols().add(at_);
final ConditionCol52 c1 = new ConditionCol52();
final Pattern52 p1 = new Pattern52();
p1.setBoundName("c1");
p1.setFactType("Driver");
c1.setFactField("name");
c1.setOperator("==");
c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
p1.getChildColumns().add(c1);
model.getConditions().add(p1);
final ConditionCol52 c1_ = new ConditionCol52();
final Pattern52 p1_ = new Pattern52();
p1_.setBoundName("c1");
p1_.setFactType("Driver");
c1_.setFactField("age");
c1_.setOperator("==");
c1_.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
p1_.getChildColumns().add(c1_);
model.getConditions().add(p1_);
final ConditionCol52 c2 = new ConditionCol52();
final Pattern52 p2 = new Pattern52();
p2.setBoundName("c1");
p2.setFactType("Driver");
c2.setFactField("age");
c2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
p2.getChildColumns().add(c2);
model.getConditions().add(p2);
final ActionSetFieldCol52 a = new ActionSetFieldCol52();
a.setBoundName("c1");
a.setFactField("name");
model.getActionCols().add(a);
final ActionSetFieldCol52 a2 = new ActionSetFieldCol52();
a2.setBoundName("c1");
a2.setFactField("age");
model.getActionCols().add(a2);
final ActionInsertFactCol52 ins = new ActionInsertFactCol52();
ins.setBoundName("x");
ins.setFactType("Driver");
ins.setFactField("name");
model.getActionCols().add(ins);
final ActionInsertFactCol52 ins_ = new ActionInsertFactCol52();
ins_.setBoundName("x");
ins_.setFactType("Driver");
ins_.setFactField("age");
model.getActionCols().add(ins_);
assertEquals(DataType.TYPE_NUMERIC_INTEGER, utils.getType(at));
assertEquals(DataType.TYPE_NUMERIC_INTEGER, utils.getType(c1_));
assertEquals(DataType.TYPE_NUMERIC_INTEGER, utils.getType(a2));
assertEquals(DataType.TYPE_NUMERIC_INTEGER, utils.getType(ins_));
assertEquals(DataType.TYPE_BOOLEAN, utils.getType(at_));
assertEquals(DataType.TYPE_STRING, utils.getType(c1));
assertEquals(DataType.TYPE_STRING, utils.getType(a));
assertEquals(DataType.TYPE_STRING, utils.getType(ins));
assertEquals(DataType.TYPE_STRING, utils.getType(c2));
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52 in project drools-wb by kiegroup.
the class ActionInsertFactWrapperTest method testCloneAnActionInsert.
@Test
public void testCloneAnActionInsert() throws Exception {
doReturn(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY).when(model).getTableFormat();
final ActionInsertFactCol52 column = new ActionInsertFactCol52();
column.setFactField("factField");
column.setBoundName("boundName");
column.setValueList("valueList");
column.setHeader("header");
column.setInsertLogical(false);
column.setDefaultValue(new DTCellValue52("defaultValue"));
column.setFactType("factType");
column.setHideColumn(false);
column.setType("type");
final ActionInsertFactWrapper wrapper = new ActionInsertFactWrapper(plugin, column);
final ActionInsertFactCol52 clone = wrapper.getActionCol52();
assertEquals("factField", column.getFactField());
assertEquals("boundName", column.getBoundName());
assertEquals("valueList", column.getValueList());
assertEquals("header", column.getHeader());
assertEquals(false, column.isInsertLogical());
assertEquals(new DTCellValue52("defaultValue"), column.getDefaultValue());
assertEquals("factType", column.getFactType());
assertEquals(false, column.isHideColumn());
assertEquals("type", column.getType());
assertNotSame(column, clone);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52 in project drools-wb by kiegroup.
the class ActionInsertFactFieldsPageViewImplTest method testSetFieldSelectionModel.
@Test
public void testSetFieldSelectionModel() throws Exception {
verify(view.chosenFieldsContainer).add(chosenFieldsWidgetCaptor.capture());
fieldSelectionModel = (MultiSelectionModel<ActionInsertFactCol52>) chosenFieldsWidgetCaptor.getValue().getSelectionModel();
insertFactCol52 = new ActionInsertFactCol52();
insertFactCol52.setType("Applicant");
insertFactCol52.setFactField("age");
insertFactCol52.setType("Integer");
fieldSelectionModel.setSelected(insertFactCol52, true);
assertTrue(fieldSelectionModel.isSelected(insertFactCol52));
insertFactCol52.setDefaultValue(new DTCellValue52(18));
assertTrue(fieldSelectionModel.isSelected(insertFactCol52));
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52 in project drools-wb by kiegroup.
the class ColumnDefinitionFactoryTest method knownColumnType_ActionInsertFactCol52.
@Test
@SuppressWarnings("unchecked")
public void knownColumnType_ActionInsertFactCol52() {
final BaseColumn column = new ActionInsertFactCol52();
final Callback<String> callback = mock(Callback.class);
columnDefinitionFactory.generateColumnDefinition(dtPresenter, column, callback);
verify(actionInsertFactCol52DefinitionBuilder, times(1)).generateDefinition(eq(dtPresenter), eq(column), any(Callback.class));
verify(callback, times(1)).callback(any(String.class));
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52 in project drools-wb by kiegroup.
the class PluginHandler method edit.
public void edit(final ActionCol52 column) {
final DecisionTableColumnPlugin plugin;
if (column instanceof ActionWorkItemSetFieldCol52 || column instanceof ActionWorkItemInsertFactCol52) {
plugin = actionWorkItemSetFieldPlugin.get();
} else if (column instanceof ActionInsertFactCol52 || column instanceof ActionSetFieldCol52) {
plugin = actionSetFactPlugin.get();
} else if (column instanceof ActionRetractFactCol52) {
plugin = actionRetractFactPlugin.get();
} else if (column instanceof ActionWorkItemCol52) {
plugin = actionWorkItemPlugin.get();
} else if (column instanceof BRLActionColumn) {
plugin = brlActionColumnPlugin.get();
} else {
return;
}
plugin.setOriginalColumnConfig52(column);
openWizard(plugin);
}
Aggregations