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());
}
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());
}
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());
}
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)));
}
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)));
}
Aggregations