use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn in project drools-wb by kiegroup.
the class BRLConditionColumnSynchronizerTest method testMoveBRLConditionBlockTo.
@Test
public void testMoveBRLConditionBlockTo() throws VetoException {
final CompositeColumn<BRLConditionVariableColumn> column1 = new BRLConditionColumn();
final BRLConditionVariableColumn column1v0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
column1v0.setHeader("age");
final BRLConditionVariableColumn column1v1 = new BRLConditionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
column1v1.setHeader("name");
column1.getChildColumns().add(column1v0);
column1.getChildColumns().add(column1v1);
final Pattern52 column2 = new Pattern52();
column2.setFactType("Address");
final ConditionCol52 column2v0 = new ConditionCol52();
column2v0.setBinding("$country");
column2v0.setFactField("country");
column2v0.setFieldType(DataType.TYPE_STRING);
column2v0.setHeader("country");
modelSynchronizer.appendColumn(column1);
modelSynchronizer.appendColumn(column2, column2v0);
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.getConditions().size());
assertEquals(column1, model.getConditions().get(0));
assertEquals(column2, model.getConditions().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.getConditions().size());
assertEquals(column2, model.getConditions().get(0));
assertEquals(column1, model.getConditions().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("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.screens.guided.dtable.client.widget.table.columns.StringUiColumn in project drools-wb by kiegroup.
the class BRLConditionColumnSynchronizerTest method testUpdate3.
@Test
public void testUpdate3() throws VetoException {
// Single Column, multiple variables
final BRLConditionColumn column = spy(new BRLConditionColumn());
final BRLConditionVariableColumn columnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
final BRLConditionVariableColumn columnV1 = new BRLConditionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
column.getChildColumns().add(columnV0);
column.getChildColumns().add(columnV1);
column.setHeader("col1");
columnV0.setHeader("col1v0");
columnV1.setHeader("col1v1");
modelSynchronizer.appendColumn(column);
assertEquals(4, model.getExpandedColumns().size());
assertEquals(1, model.getConditions().size());
assertEquals(4, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
assertEquals("$age", uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle());
final BRLConditionColumn edited = new BRLConditionColumn();
final BRLConditionVariableColumn editedColumnV0 = new BRLConditionVariableColumn("$s", DataType.TYPE_NUMERIC_LONG, "Applicant", "salary");
edited.getChildColumns().add(editedColumnV0);
edited.setHideColumn(true);
edited.setHeader("updated");
editedColumnV0.setHeader("updated");
List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
assertEquals(6, // header, hide, field name, field type, binding, removed column
diffs.size());
verify(column).diff(edited);
assertEquals(3, model.getExpandedColumns().size());
assertEquals(1, model.getConditions().size());
assertEquals(3, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(2) instanceof LongUiColumn);
assertEquals("updated", uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
assertEquals(false, uiModel.getColumns().get(2).isVisible());
assertEquals("$s", uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle());
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method testAppend2.
@Test
public void testAppend2() throws VetoException {
// Single Pattern, multiple Conditions
final Pattern52 pattern = boundApplicantPattern("$a");
final ConditionCol52 condition1 = ageEqualsCondition();
modelSynchronizer.appendColumn(pattern, condition1);
assertEquals(3, model.getExpandedColumns().size());
assertEquals(1, model.getConditions().size());
assertEquals(3, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
final ConditionCol52 condition2 = nameEqualsCondition();
modelSynchronizer.appendColumn(pattern, condition2);
assertEquals(4, model.getExpandedColumns().size());
assertEquals(1, model.getConditions().size());
assertEquals(2, model.getConditionPattern("$a").getChildColumns().size());
assertEquals(4, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method testUpdate7.
@Test
public void testUpdate7() throws VetoException {
// Single Pattern (updated), single Condition
final String boundName = "$a";
final Pattern52 pattern = spy(boundApplicantPattern(boundName));
final Pattern52 editedPattern = boundApplicantPattern(boundName);
final ConditionCol52 condition = spy(ageEqualsCondition());
final ConditionCol52 editedCondition = nameEqualsCondition();
final String entryPoint = "entryPoint";
modelSynchronizer.appendColumn(pattern, condition);
editedPattern.setEntryPointName(entryPoint);
editedCondition.setWidth(condition.getWidth());
final List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(pattern, condition, editedPattern, editedCondition);
assertEquals(3, diffs.size());
verify(pattern).diff(editedPattern);
verify(condition).diff(editedCondition);
verify(pattern).setEntryPointName(entryPoint);
assertEquals("entryPointName", diffs.get(0).getFieldName());
assertEquals("header", diffs.get(1).getFieldName());
assertEquals("factField", diffs.get(2).getFieldName());
assertEquals(3, model.getExpandedColumns().size());
assertEquals(1, model.getConditions().size());
assertEquals(1, model.getConditionPattern(boundName).getChildColumns().size());
assertEquals(3, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(2) instanceof StringUiColumn);
final String expectedTitle = editedPattern.getBoundName() + " : " + editedPattern.getFactType();
final String actualTitle = uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle();
assertEquals(expectedTitle, actualTitle);
final String expectedHeader = editedCondition.getHeader();
final String actualHeader = uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle();
assertEquals(expectedHeader, actualHeader);
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method testMoveLeftNegatedPattern.
@Test
public void testMoveLeftNegatedPattern() throws VetoException {
final Pattern52 pattern = new Pattern52();
pattern.setNegated(true);
pattern.setFactType("Applicant");
final ConditionCol52 column1 = ageEqualsCondition();
final ConditionCol52 column2 = nameEqualsCondition();
modelSynchronizer.appendColumn(pattern, column1);
modelSynchronizer.appendColumn(pattern, column2);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<Integer>(45));
uiModel.setCellValue(0, 3, new BaseGridCellValue<String>("Smurf"));
assertEquals(1, model.getPatterns().size());
final List<ConditionCol52> conditionColumns1_1 = model.getPatterns().get(0).getChildColumns();
assertEquals(column1, conditionColumns1_1.get(0));
assertEquals(column2, conditionColumns1_1.get(1));
assertEquals(45, model.getData().get(0).get(2).getNumericValue());
assertEquals("Smurf", model.getData().get(0).get(3).getStringValue());
assertEquals(4, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(3);
assertEquals("not Applicant", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
assertEquals("not Applicant", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_1 instanceof IntegerUiColumn);
assertTrue(uiModelColumn2_1 instanceof StringUiColumn);
assertEquals(2, uiModelColumn1_1.getIndex());
assertEquals(3, uiModelColumn2_1.getIndex());
assertEquals(45, uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
uiModel.moveColumnTo(2, uiModelColumn2_1);
assertEquals(1, model.getPatterns().size());
final List<ConditionCol52> conditionColumns1_2 = model.getPatterns().get(0).getChildColumns();
assertEquals(column2, conditionColumns1_2.get(0));
assertEquals(column1, conditionColumns1_2.get(1));
assertEquals("Smurf", model.getData().get(0).get(2).getStringValue());
assertEquals(45, model.getData().get(0).get(3).getNumericValue());
assertEquals(4, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
assertEquals("not Applicant", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
assertEquals("not Applicant", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_2 instanceof StringUiColumn);
assertTrue(uiModelColumn2_2 instanceof IntegerUiColumn);
assertEquals(3, uiModelColumn1_2.getIndex());
assertEquals(2, uiModelColumn2_2.getIndex());
assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
assertEquals(45, uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
Aggregations