Search in sources :

Example 26 with MetadataCol52

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

Example 27 with MetadataCol52

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

Example 28 with MetadataCol52

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

Example 29 with MetadataCol52

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

Example 30 with MetadataCol52

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

Aggregations

MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)67 Test (org.junit.Test)52 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)18 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)12 ArrayList (java.util.ArrayList)11 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)10 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)10 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)9 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)9 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)8 DecisionTableSelectionsChangedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent)8 DecisionTableSelectedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)7 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)6 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)6 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)5 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)5 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)4 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)4 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)4 CompositeColumn (org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)4