use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.
the class AttributeColumnSynchronizerTest method testAppend.
@Test
public void testAppend() throws VetoException {
final AttributeCol52 column = new AttributeCol52();
column.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
modelSynchronizer.appendColumn(column);
assertEquals(1, model.getAttributeCols().size());
assertEquals(RuleAttributeWidget.SALIENCE_ATTR, model.getAttributeCols().get(0).getAttribute());
assertEquals(3, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
assertEquals(RuleAttributeWidget.SALIENCE_ATTR, uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
assertEquals(true, ((BaseSingletonDOMElementUiColumn) uiModel.getColumns().get(2)).isEditable());
}
use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.
the class AttributeColumnSynchronizerTest method testUpdate1.
@Test
public void testUpdate1() throws VetoException {
final AttributeCol52 column = spy(new AttributeCol52());
column.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
modelSynchronizer.appendColumn(column);
final AttributeCol52 edited = new AttributeCol52();
edited.setWidth(column.getWidth());
edited.setAttribute(RuleAttributeWidget.ENABLED_ATTR);
List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
assertEquals(1, diffs.size());
verify(column).diff(edited);
assertEquals(1, model.getAttributeCols().size());
assertEquals(RuleAttributeWidget.ENABLED_ATTR, model.getAttributeCols().get(0).getAttribute());
assertEquals(3, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(2) instanceof BooleanUiColumn);
assertEquals(RuleAttributeWidget.ENABLED_ATTR, uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
}
use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.
the class AttributeColumnSynchronizerTest method testMoveColumnTo_OutOfBounds.
@Test
public void testMoveColumnTo_OutOfBounds() throws VetoException {
final AttributeCol52 column1 = new AttributeCol52();
column1.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
final AttributeCol52 column2 = new AttributeCol52();
column2.setAttribute(RuleAttributeWidget.AGENDA_GROUP_ATTR);
modelSynchronizer.appendColumn(column1);
modelSynchronizer.appendColumn(column2);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<Integer>(1));
uiModel.setCellValue(0, 3, new BaseGridCellValue<String>("smurf"));
assertEquals(2, model.getAttributeCols().size());
assertEquals(column1, model.getAttributeCols().get(0));
assertEquals(column2, model.getAttributeCols().get(1));
assertEquals(1, 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(RuleAttributeWidget.SALIENCE_ATTR, uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
assertEquals(RuleAttributeWidget.AGENDA_GROUP_ATTR, 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(1, uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
assertEquals("smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
uiModel.moveColumnTo(0, uiModelColumn1_1);
assertEquals(2, model.getAttributeCols().size());
assertEquals(column1, model.getAttributeCols().get(0));
assertEquals(column2, model.getAttributeCols().get(1));
assertEquals(1, model.getData().get(0).get(2).getNumericValue());
assertEquals("smurf", model.getData().get(0).get(3).getStringValue());
assertEquals(4, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
assertEquals(RuleAttributeWidget.SALIENCE_ATTR, uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
assertEquals(RuleAttributeWidget.AGENDA_GROUP_ATTR, uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_2 instanceof IntegerUiColumn);
assertTrue(uiModelColumn2_2 instanceof StringUiColumn);
assertEquals(2, uiModelColumn1_2.getIndex());
assertEquals(3, uiModelColumn2_2.getIndex());
assertEquals(1, uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
assertEquals("smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.
the class AttributeColumnSynchronizerTest method testMoveColumnsTo_MoveLeft.
@Test
public void testMoveColumnsTo_MoveLeft() throws VetoException {
final AttributeCol52 column1 = new AttributeCol52();
column1.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
final AttributeCol52 column2 = new AttributeCol52();
column2.setAttribute(RuleAttributeWidget.AGENDA_GROUP_ATTR);
final AttributeCol52 column3 = new AttributeCol52();
column3.setAttribute(RuleAttributeWidget.AUTO_FOCUS_ATTR);
modelSynchronizer.appendColumn(column1);
modelSynchronizer.appendColumn(column2);
modelSynchronizer.appendColumn(column3);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<Integer>(1));
uiModel.setCellValue(0, 3, new BaseGridCellValue<String>("smurf"));
uiModel.setCellValue(0, 4, new BaseGridCellValue<Boolean>(true));
final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(3);
final GridColumn<?> uiModelColumn3_1 = uiModel.getColumns().get(4);
assertTestMoveColumnsTo(column1, column2, column3, uiModelColumn1_1, uiModelColumn2_1, uiModelColumn3_1);
// Moving multiple Attribute columns as an unsupported operation as it's impossible via the UI
uiModel.moveColumnsTo(2, new ArrayList<GridColumn<?>>() {
{
add(uiModelColumn2_1);
add(uiModelColumn3_1);
}
});
final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
final GridColumn<?> uiModelColumn3_2 = uiModel.getColumns().get(4);
assertTestMoveColumnsTo(column1, column2, column3, uiModelColumn1_2, uiModelColumn2_2, uiModelColumn3_2);
}
use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools by kiegroup.
the class DecisionTableValidatorAttributesTest method addAttributeColumn.
@Test(expected = DuplicateAttributeException.class)
public void addAttributeColumn() throws Exception {
final DecisionTableValidator validator = getDecisionTableValidator();
final AttributeCol52 attributeCol52 = new AttributeCol52();
attributeCol52.setAttribute(attributeName);
try {
validator.isValidToAdd(attributeCol52);
} catch (final Exception e) {
fail("First addition should be valid.");
}
addAttributeCol(attributeCol52);
validator.isValidToAdd(attributeCol52);
}
Aggregations