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 RowExpanderTests method testExpansionWithValuesList.
@Test
@SuppressWarnings("serial")
public void testExpansionWithValuesList() {
GuidedDecisionTable52 model = new GuidedDecisionTable52();
final ModuleDataModelOracle projectLoader = 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)).addField(new ModelField("dateOfBirth", Boolean.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_DATE)).addField(new ModelField("approved", Boolean.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_BOOLEAN)).end().build();
// Emulate server-to-client conversions
final AsyncPackageDataModelOracle oracle = getOracle();
final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
dataModel.setModelFields(projectLoader.getModuleModelFields());
populateDataModelOracle(mock(Path.class), model, oracle, dataModel);
Pattern52 p1 = new Pattern52();
p1.setBoundName("c1");
p1.setFactType("Driver");
ConditionCol52 c1 = new ConditionCol52();
c1.setFactField("name");
c1.setOperator("==");
c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
c1.setValueList("c1a,c1b");
p1.getChildColumns().add(c1);
model.getConditions().add(p1);
Pattern52 p2 = new Pattern52();
p2.setBoundName("c2");
p2.setFactType("Driver");
ConditionCol52 c2 = new ConditionCol52();
c2.setFactField("age");
c2.setOperator("==");
c2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
c2.setValueList("c2a,c2b");
p2.getChildColumns().add(c2);
model.getConditions().add(p2);
Pattern52 p3 = new Pattern52();
p3.setBoundName("c3");
p3.setFactType("Driver");
ConditionCol52 c3 = new ConditionCol52();
c3.setFactField("dateOfBirth");
c3.setOperator("==");
c3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
c3.setValueList("c3a,c3b");
p3.getChildColumns().add(c3);
model.getConditions().add(p3);
Pattern52 p4 = new Pattern52();
p4.setBoundName("c4");
p4.setFactType("Driver");
ConditionCol52 c4 = new ConditionCol52();
c4.setFactField("approved");
c4.setOperator("==");
c4.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
c4.setValueList("c4a,c4b");
p4.getChildColumns().add(c4);
model.getConditions().add(p4);
ActionSetFieldCol52 a1 = new ActionSetFieldCol52();
a1.setBoundName("c1");
a1.setFactField("name");
a1.setValueList("a1a,a1b");
model.getActionCols().add(a1);
ActionInsertFactCol52 a2 = new ActionInsertFactCol52();
a2.setBoundName("a2");
a2.setFactType("Driver");
a2.setFactField("name");
a2.setValueList("a2a,a2b");
model.getActionCols().add(a2);
RowExpander re = new RowExpander(model, oracle);
List<RowExpander.ColumnValues> columns = re.getColumns();
assertEquals(8, columns.size());
assertEquals(1, columns.get(0).values.size());
assertEquals(1, columns.get(1).values.size());
assertEquals(2, columns.get(2).values.size());
assertEquals(2, columns.get(3).values.size());
assertEquals(2, columns.get(4).values.size());
assertEquals(2, columns.get(5).values.size());
assertEquals(1, columns.get(6).values.size());
assertEquals(1, columns.get(7).values.size());
assertEquals("c1a", columns.get(2).values.get(0).getStringValue());
assertEquals("c1b", columns.get(2).values.get(1).getStringValue());
assertEquals("c2a", columns.get(3).values.get(0).getStringValue());
assertEquals("c2b", columns.get(3).values.get(1).getStringValue());
assertEquals("c3a", columns.get(4).values.get(0).getStringValue());
assertEquals("c3b", columns.get(4).values.get(1).getStringValue());
assertEquals("c4a", columns.get(5).values.get(0).getStringValue());
assertEquals("c4b", columns.get(5).values.get(1).getStringValue());
assertNull(columns.get(6).values.get(0));
assertNull(columns.get(7).values.get(0));
RowExpander.RowIterator ri = re.iterator();
assertTrue(ri.hasNext());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52 in project drools-wb by kiegroup.
the class BRLActionColumnSynchronizerTest method testMoveActionBefore.
@Test
public void testMoveActionBefore() throws VetoException {
final BRLActionColumn column1 = new BRLActionColumn();
final BRLActionVariableColumn column1v0 = new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
column1v0.setHeader("age");
final BRLActionVariableColumn column1v1 = new BRLActionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
column1v1.setHeader("name");
final ActionInsertFactCol52 column2 = new ActionInsertFactCol52();
column2.setHeader("country");
column2.setBoundName("$a");
column2.setFactType("Address");
column2.setFactField("country");
column1.getChildColumns().add(column1v0);
column1.getChildColumns().add(column1v1);
modelSynchronizer.appendColumn(column1);
modelSynchronizer.appendColumn(column2);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<>(55));
uiModel.setCellValue(0, 3, new BaseGridCellValue<>("Smurf"));
uiModel.setCellValue(0, 4, new BaseGridCellValue<>("Canada"));
assertEquals(2, model.getActionCols().size());
assertEquals(column1, model.getActionCols().get(0));
assertEquals(column2, model.getActionCols().get(1));
assertEquals(55, model.getData().get(0).get(2).getNumericValue());
assertEquals("Smurf", model.getData().get(0).get(3).getStringValue());
assertEquals("Canada", model.getData().get(0).get(4).getStringValue());
assertEquals(5, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(3);
final GridColumn<?> uiModelColumn3_1 = uiModel.getColumns().get(4);
assertEquals("age", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
assertEquals("name", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_1 instanceof IntegerUiColumn);
assertTrue(uiModelColumn2_1 instanceof StringUiColumn);
assertTrue(uiModelColumn3_1 instanceof StringUiColumn);
assertEquals(2, uiModelColumn1_1.getIndex());
assertEquals(3, uiModelColumn2_1.getIndex());
assertEquals(4, uiModelColumn3_1.getIndex());
assertEquals(55, uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
assertEquals("Canada", uiModel.getRow(0).getCells().get(uiModelColumn3_1.getIndex()).getValue().getValue());
uiModel.moveColumnTo(2, uiModelColumn3_1);
assertEquals(2, model.getActionCols().size());
assertEquals(column2, model.getActionCols().get(0));
assertEquals(column1, model.getActionCols().get(1));
assertEquals("Canada", model.getData().get(0).get(2).getStringValue());
assertEquals(55, model.getData().get(0).get(3).getNumericValue());
assertEquals("Smurf", model.getData().get(0).get(4).getStringValue());
assertEquals(5, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
final GridColumn<?> uiModelColumn3_2 = uiModel.getColumns().get(4);
assertEquals("$a : Address", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
assertEquals("age", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
assertEquals("name", uiModelColumn3_2.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_2 instanceof StringUiColumn);
assertTrue(uiModelColumn2_2 instanceof IntegerUiColumn);
assertTrue(uiModelColumn3_2 instanceof StringUiColumn);
assertEquals(4, uiModelColumn1_2.getIndex());
assertEquals(2, uiModelColumn2_2.getIndex());
assertEquals(3, uiModelColumn3_2.getIndex());
assertEquals("Canada", uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
assertEquals(55, uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn3_2.getIndex()).getValue().getValue());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52 in project drools-wb by kiegroup.
the class BRLActionColumnSynchronizerTest method testMoveBRLActionBlockTo.
@Test
public void testMoveBRLActionBlockTo() throws VetoException {
final BRLActionColumn column1 = new BRLActionColumn();
final BRLActionVariableColumn column1v0 = new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
column1v0.setHeader("age");
final BRLActionVariableColumn column1v1 = new BRLActionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
column1v1.setHeader("name");
final ActionInsertFactCol52 column2 = new ActionInsertFactCol52();
column2.setHeader("country");
column2.setBoundName("$a");
column2.setFactType("Address");
column2.setFactField("country");
column1.getChildColumns().add(column1v0);
column1.getChildColumns().add(column1v1);
modelSynchronizer.appendColumn(column1);
modelSynchronizer.appendColumn(column2);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<>(55));
uiModel.setCellValue(0, 3, new BaseGridCellValue<>("Smurf"));
uiModel.setCellValue(0, 4, new BaseGridCellValue<>("Canada"));
assertEquals(2, model.getActionCols().size());
assertEquals(column1, model.getActionCols().get(0));
assertEquals(column2, model.getActionCols().get(1));
assertEquals(55, model.getData().get(0).get(2).getNumericValue());
assertEquals("Smurf", model.getData().get(0).get(3).getStringValue());
assertEquals("Canada", model.getData().get(0).get(4).getStringValue());
assertEquals(5, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(3);
final GridColumn<?> uiModelColumn3_1 = uiModel.getColumns().get(4);
assertEquals("age", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
assertEquals("name", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_1 instanceof IntegerUiColumn);
assertTrue(uiModelColumn2_1 instanceof StringUiColumn);
assertTrue(uiModelColumn3_1 instanceof StringUiColumn);
assertEquals(2, uiModelColumn1_1.getIndex());
assertEquals(3, uiModelColumn2_1.getIndex());
assertEquals(4, uiModelColumn3_1.getIndex());
assertEquals(55, uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
assertEquals("Canada", uiModel.getRow(0).getCells().get(uiModelColumn3_1.getIndex()).getValue().getValue());
uiModel.moveColumnsTo(4, new ArrayList<GridColumn<?>>() {
{
add(uiModelColumn1_1);
add(uiModelColumn2_1);
}
});
assertEquals(2, model.getActionCols().size());
assertEquals(column2, model.getActionCols().get(0));
assertEquals(column1, model.getActionCols().get(1));
assertEquals("Canada", model.getData().get(0).get(2).getStringValue());
assertEquals(55, model.getData().get(0).get(3).getNumericValue());
assertEquals("Smurf", model.getData().get(0).get(4).getStringValue());
assertEquals(5, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
final GridColumn<?> uiModelColumn3_2 = uiModel.getColumns().get(4);
assertEquals("$a : Address", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
assertEquals("age", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
assertEquals("name", uiModelColumn3_2.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_2 instanceof StringUiColumn);
assertTrue(uiModelColumn2_2 instanceof IntegerUiColumn);
assertTrue(uiModelColumn3_2 instanceof StringUiColumn);
assertEquals(4, uiModelColumn1_2.getIndex());
assertEquals(2, uiModelColumn2_2.getIndex());
assertEquals(3, uiModelColumn3_2.getIndex());
assertEquals("Canada", uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
assertEquals(55, uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn3_2.getIndex()).getValue().getValue());
}
Aggregations