use of org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52 in project drools-wb by kiegroup.
the class MetaDataColumnSynchronizerTest method testDelete.
@Test
public void testDelete() throws VetoException {
final MetadataCol52 column = new MetadataCol52();
column.setMetadata("smurf");
modelSynchronizer.appendColumn(column);
assertEquals(1, model.getMetadataCols().size());
assertEquals(3, uiModel.getColumns().size());
modelSynchronizer.deleteColumn(column);
assertEquals(0, model.getMetadataCols().size());
assertEquals(2, uiModel.getColumns().size());
}
use of org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52 in project drools-wb by kiegroup.
the class MetaDataColumnSynchronizerTest method testMoveColumnTo_MoveRight.
@Test
public void testMoveColumnTo_MoveRight() throws VetoException {
final MetadataCol52 column1 = new MetadataCol52();
column1.setMetadata("metadata1");
final MetadataCol52 column2 = new MetadataCol52();
column2.setMetadata("metadata2");
modelSynchronizer.appendColumn(column1);
modelSynchronizer.appendColumn(column2);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<String>("metadata1"));
uiModel.setCellValue(0, 3, new BaseGridCellValue<String>("metadata2"));
assertEquals(2, model.getMetadataCols().size());
assertEquals(column1, model.getMetadataCols().get(0));
assertEquals(column2, model.getMetadataCols().get(1));
assertEquals("metadata1", model.getData().get(0).get(2).getStringValue());
assertEquals("metadata2", 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("metadata1", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
assertEquals("metadata2", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_1 instanceof StringUiColumn);
assertTrue(uiModelColumn2_1 instanceof StringUiColumn);
assertEquals(2, uiModelColumn1_1.getIndex());
assertEquals(3, uiModelColumn2_1.getIndex());
assertEquals("metadata1", uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
assertEquals("metadata2", uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
uiModel.moveColumnTo(3, uiModelColumn1_1);
assertEquals(2, model.getMetadataCols().size());
assertEquals(column2, model.getMetadataCols().get(0));
assertEquals(column1, model.getMetadataCols().get(1));
assertEquals("metadata2", model.getData().get(0).get(2).getStringValue());
assertEquals("metadata1", 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("metadata2", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
assertEquals("metadata1", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_2 instanceof StringUiColumn);
assertTrue(uiModelColumn2_2 instanceof StringUiColumn);
assertEquals(3, uiModelColumn1_2.getIndex());
assertEquals(2, uiModelColumn2_2.getIndex());
assertEquals("metadata2", uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
assertEquals("metadata1", uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
use of org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52 in project drools-wb by kiegroup.
the class MetaDataColumnSynchronizerTest method testUpdate2.
@Test
public void testUpdate2() throws VetoException {
final MetadataCol52 column = spy(new MetadataCol52());
column.setMetadata("smurf");
modelSynchronizer.appendColumn(column);
final MetadataCol52 edited = new MetadataCol52();
edited.setWidth(column.getWidth());
edited.setMetadata("smurf");
edited.setHideColumn(true);
List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
assertEquals(1, diffs.size());
verify(column).diff(edited);
assertEquals(1, model.getMetadataCols().size());
assertEquals("smurf", model.getMetadataCols().get(0).getMetadata());
assertEquals(3, uiModel.getColumns().size());
assertEquals("smurf", uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
assertEquals(false, uiModel.getColumns().get(2).isVisible());
}
use of org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52 in project drools-wb by kiegroup.
the class MetaDataColumnSynchronizerTest method testMoveColumnsTo_MoveRight.
@Test
public void testMoveColumnsTo_MoveRight() throws VetoException {
final MetadataCol52 column1 = new MetadataCol52();
column1.setMetadata("metadata1");
final MetadataCol52 column2 = new MetadataCol52();
column2.setMetadata("metadata2");
final MetadataCol52 column3 = new MetadataCol52();
column3.setMetadata("metadata3");
modelSynchronizer.appendColumn(column1);
modelSynchronizer.appendColumn(column2);
modelSynchronizer.appendColumn(column3);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<String>("metadata1"));
uiModel.setCellValue(0, 3, new BaseGridCellValue<String>("metadata2"));
uiModel.setCellValue(0, 4, new BaseGridCellValue<String>("metadata3"));
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 MetaData columns as an unsupported operation as it's impossible via the UI
uiModel.moveColumnsTo(4, new ArrayList<GridColumn<?>>() {
{
add(uiModelColumn1_1);
add(uiModelColumn2_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.MetadataCol52 in project drools-wb by kiegroup.
the class MetaDataColumnSynchronizerTest method testAppend.
@Test
public void testAppend() throws VetoException {
final MetadataCol52 column = new MetadataCol52();
column.setMetadata("smurf");
modelSynchronizer.appendColumn(column);
assertEquals(1, model.getMetadataCols().size());
assertEquals("smurf", model.getMetadataCols().get(0).getMetadata());
assertEquals(3, uiModel.getColumns().size());
assertEquals("smurf", uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
}
Aggregations