Search in sources :

Example 1 with SalienceUiColumn

use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.SalienceUiColumn in project drools-wb by kiegroup.

the class AttributeColumnSynchronizerTest method testUpdateSalienceRowNumber.

@Test
public void testUpdateSalienceRowNumber() throws VetoException {
    modelSynchronizer.appendRow();
    modelSynchronizer.appendRow();
    final AttributeCol52 column = new AttributeCol52();
    column.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
    modelSynchronizer.appendColumn(column);
    final AttributeCol52 edited1 = new AttributeCol52();
    edited1.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
    edited1.setUseRowNumber(true);
    modelSynchronizer.updateColumn(column, edited1);
    assertEquals(1, model.getAttributeCols().size());
    assertEquals(RuleAttributeWidget.SALIENCE_ATTR, model.getAttributeCols().get(0).getAttribute());
    assertEquals(1, model.getData().get(0).get(2).getNumericValue());
    assertEquals(2, model.getData().get(1).get(2).getNumericValue());
    assertEquals(3, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof SalienceUiColumn);
    assertEquals(RuleAttributeWidget.SALIENCE_ATTR, uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
    assertEquals(true, ((SalienceUiColumn) uiModel.getColumns().get(2)).isUseRowNumber());
    assertEquals(1, uiModel.getRow(0).getCells().get(2).getValue().getValue());
    assertEquals(2, uiModel.getRow(1).getCells().get(2).getValue().getValue());
    final AttributeCol52 edited2 = new AttributeCol52();
    edited2.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
    edited2.setUseRowNumber(true);
    edited2.setReverseOrder(true);
    modelSynchronizer.updateColumn(column, edited2);
    assertEquals(1, model.getAttributeCols().size());
    assertEquals(RuleAttributeWidget.SALIENCE_ATTR, model.getAttributeCols().get(0).getAttribute());
    assertEquals(2, model.getData().get(0).get(2).getNumericValue());
    assertEquals(1, model.getData().get(1).get(2).getNumericValue());
    assertEquals(3, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof SalienceUiColumn);
    assertEquals(RuleAttributeWidget.SALIENCE_ATTR, uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
    assertEquals(true, ((SalienceUiColumn) uiModel.getColumns().get(2)).isUseRowNumber());
    assertEquals(2, uiModel.getRow(0).getCells().get(2).getValue().getValue());
    assertEquals(1, uiModel.getRow(1).getCells().get(2).getValue().getValue());
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) SalienceUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.SalienceUiColumn) Test(org.junit.Test)

Aggregations

AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)1 SalienceUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.SalienceUiColumn)1 Test (org.junit.Test)1