Search in sources :

Example 46 with AttributeCol52

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());
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) Test(org.junit.Test)

Example 47 with AttributeCol52

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());
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) BooleanUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn) Test(org.junit.Test)

Example 48 with AttributeCol52

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());
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) StringUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) Test(org.junit.Test)

Example 49 with AttributeCol52

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);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) Test(org.junit.Test)

Example 50 with AttributeCol52

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);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) Test(org.junit.Test)

Aggregations

AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)86 Test (org.junit.Test)55 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)30 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)20 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)14 ArrayList (java.util.ArrayList)12 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)12 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)10 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)10 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)9 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)8 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)8 MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)7 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 ExcelParser (org.drools.decisiontable.parser.xls.ExcelParser)6 DataListener (org.drools.template.parser.DataListener)6 ConversionResult (org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult)6 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)5 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)5