Search in sources :

Example 71 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.

the class AttributeColumnSynchronizerTest method testDelete.

@Test
public void testDelete() throws VetoException {
    final AttributeCol52 column = new AttributeCol52();
    column.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
    modelSynchronizer.appendColumn(column);
    assertEquals(1, model.getAttributeCols().size());
    assertEquals(3, uiModel.getColumns().size());
    modelSynchronizer.deleteColumn(column);
    assertEquals(0, model.getAttributeCols().size());
    assertEquals(2, uiModel.getColumns().size());
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) Test(org.junit.Test)

Example 72 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 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)

Example 73 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.

the class AttributeColumnSynchronizerTest method testMoveColumnTo_MoveLeft.

@Test
public void testMoveColumnTo_MoveLeft() 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(2, uiModelColumn2_1);
    assertEquals(2, model.getAttributeCols().size());
    assertEquals(column2, model.getAttributeCols().get(0));
    assertEquals(column1, model.getAttributeCols().get(1));
    assertEquals("smurf", model.getData().get(0).get(2).getStringValue());
    assertEquals(1, 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(RuleAttributeWidget.AGENDA_GROUP_ATTR, uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
    assertEquals(RuleAttributeWidget.SALIENCE_ATTR, 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(1, 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 74 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.

the class AttributeColumnSynchronizerTest method checkHandlesMoveColumnsToWithMultipleMetadata.

@Test
public void checkHandlesMoveColumnsToWithMultipleMetadata() throws VetoException {
    final MoveColumnToMetaData md0 = mock(MoveColumnToMetaData.class);
    final MoveColumnToMetaData md1 = mock(MoveColumnToMetaData.class);
    final AttributeColumnSynchronizer synchronizer = new AttributeColumnSynchronizer();
    when(md0.getColumn()).thenReturn(mock(AttributeCol52.class));
    when(md1.getColumn()).thenReturn(mock(AttributeCol52.class));
    assertFalse(synchronizer.handlesMoveColumnsTo(Arrays.asList(md0, md1)));
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) MoveColumnToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.BaseSynchronizer.MoveColumnToMetaData) Test(org.junit.Test)

Example 75 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.

the class AttributeColumnSynchronizerTest method checkHandlesMoveColumnsToWithSingleMetadata.

@Test
public void checkHandlesMoveColumnsToWithSingleMetadata() throws VetoException {
    final MoveColumnToMetaData md0 = mock(MoveColumnToMetaData.class);
    final AttributeColumnSynchronizer synchronizer = new AttributeColumnSynchronizer();
    when(md0.getColumn()).thenReturn(mock(AttributeCol52.class));
    assertTrue(synchronizer.handlesMoveColumnsTo(Collections.singletonList(md0)));
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) MoveColumnToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.BaseSynchronizer.MoveColumnToMetaData) 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