use of org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52 in project drools-wb by kiegroup.
the class AuditLogEntryCellHelperTest method getSafeHtml_ActionRetract.
@Test
public void getSafeHtml_ActionRetract() {
ActionRetractFactCol52 originalColumn = new ActionRetractFactCol52();
originalColumn.setHeader("action1");
originalColumn.setHideColumn(false);
originalColumn.setDefaultValue(new DTCellValue52("def1"));
ActionRetractFactCol52 newColumn = new ActionRetractFactCol52();
newColumn.setHeader("action2");
newColumn.setHideColumn(true);
newColumn.setDefaultValue(new DTCellValue52("def2"));
List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
assertEquals(getHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52 in project drools-wb by kiegroup.
the class ActionRetractFactColumnSynchronizerTest method testMoveColumnTo_MoveRight.
@Test
public void testMoveColumnTo_MoveRight() throws VetoException {
final ActionRetractFactCol52 column1 = new ActionRetractFactCol52();
column1.setHeader("retract1");
final ActionRetractFactCol52 column2 = new ActionRetractFactCol52();
column2.setHeader("retract2");
modelSynchronizer.appendColumn(column1);
modelSynchronizer.appendColumn(column2);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<String>("$r1"));
uiModel.setCellValue(0, 3, new BaseGridCellValue<String>("$r2"));
assertEquals(2, model.getActionCols().size());
assertEquals(column1, model.getActionCols().get(0));
assertEquals(column2, model.getActionCols().get(1));
assertEquals("$r1", model.getData().get(0).get(2).getStringValue());
assertEquals("$r2", 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("retract1", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
assertEquals("retract2", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_1 instanceof BoundFactUiColumn);
assertTrue(uiModelColumn2_1 instanceof BoundFactUiColumn);
assertEquals(2, uiModelColumn1_1.getIndex());
assertEquals(3, uiModelColumn2_1.getIndex());
assertEquals("$r1", uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
assertEquals("$r2", uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
uiModel.moveColumnTo(3, uiModelColumn1_1);
assertEquals(2, model.getActionCols().size());
assertEquals(column2, model.getActionCols().get(0));
assertEquals(column1, model.getActionCols().get(1));
assertEquals("$r2", model.getData().get(0).get(2).getStringValue());
assertEquals("$r1", 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("retract2", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
assertEquals("retract1", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_2 instanceof BoundFactUiColumn);
assertTrue(uiModelColumn2_2 instanceof BoundFactUiColumn);
assertEquals(3, uiModelColumn1_2.getIndex());
assertEquals(2, uiModelColumn2_2.getIndex());
assertEquals("$r2", uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
assertEquals("$r1", uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52 in project drools-wb by kiegroup.
the class ActionRetractFactColumnSynchronizerTest method testMoveColumnTo_MoveLeft.
@Test
public void testMoveColumnTo_MoveLeft() throws VetoException {
final ActionRetractFactCol52 column1 = new ActionRetractFactCol52();
column1.setHeader("retract1");
final ActionRetractFactCol52 column2 = new ActionRetractFactCol52();
column2.setHeader("retract2");
modelSynchronizer.appendColumn(column1);
modelSynchronizer.appendColumn(column2);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<String>("$r1"));
uiModel.setCellValue(0, 3, new BaseGridCellValue<String>("$r2"));
assertEquals(2, model.getActionCols().size());
assertEquals(column1, model.getActionCols().get(0));
assertEquals(column2, model.getActionCols().get(1));
assertEquals("$r1", model.getData().get(0).get(2).getStringValue());
assertEquals("$r2", 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("retract1", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
assertEquals("retract2", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_1 instanceof BoundFactUiColumn);
assertTrue(uiModelColumn2_1 instanceof BoundFactUiColumn);
assertEquals(2, uiModelColumn1_1.getIndex());
assertEquals(3, uiModelColumn2_1.getIndex());
assertEquals("$r1", uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
assertEquals("$r2", uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
uiModel.moveColumnTo(2, uiModelColumn2_1);
assertEquals(2, model.getActionCols().size());
assertEquals(column2, model.getActionCols().get(0));
assertEquals(column1, model.getActionCols().get(1));
assertEquals("$r2", model.getData().get(0).get(2).getStringValue());
assertEquals("$r1", 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("retract2", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
assertEquals("retract1", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_2 instanceof BoundFactUiColumn);
assertTrue(uiModelColumn2_2 instanceof BoundFactUiColumn);
assertEquals(3, uiModelColumn1_2.getIndex());
assertEquals(2, uiModelColumn2_2.getIndex());
assertEquals("$r2", uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
assertEquals("$r1", uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52 in project drools-wb by kiegroup.
the class ActionRetractFactColumnSynchronizerTest method testUpdate.
@Test
public void testUpdate() throws VetoException {
final ActionRetractFactCol52 column = spy(new ActionRetractFactCol52());
column.setHeader("col1");
modelSynchronizer.appendColumn(column);
final ActionRetractFactCol52 edited = new ActionRetractFactCol52();
edited.setWidth(column.getWidth());
edited.setHideColumn(true);
edited.setHeader("updated");
List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
assertEquals(2, diffs.size());
verify(column).diff(edited);
assertEquals(1, model.getActionCols().size());
assertEquals(3, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(2) instanceof BoundFactUiColumn);
assertEquals("updated", 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.ActionRetractFactCol52 in project drools-wb by kiegroup.
the class ActionRetractFactColumnSynchronizerTest method testMoveColumnTo_OutOfBounds.
@Test
public void testMoveColumnTo_OutOfBounds() throws VetoException {
final ActionRetractFactCol52 column1 = new ActionRetractFactCol52();
column1.setHeader("retract1");
final ActionRetractFactCol52 column2 = new ActionRetractFactCol52();
column2.setHeader("retract2");
modelSynchronizer.appendColumn(column1);
modelSynchronizer.appendColumn(column2);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<String>("$r1"));
uiModel.setCellValue(0, 3, new BaseGridCellValue<String>("$r2"));
assertEquals(2, model.getActionCols().size());
assertEquals(column1, model.getActionCols().get(0));
assertEquals(column2, model.getActionCols().get(1));
assertEquals("$r1", model.getData().get(0).get(2).getStringValue());
assertEquals("$r2", 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("retract1", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
assertEquals("retract2", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_1 instanceof BoundFactUiColumn);
assertTrue(uiModelColumn2_1 instanceof BoundFactUiColumn);
assertEquals(2, uiModelColumn1_1.getIndex());
assertEquals(3, uiModelColumn2_1.getIndex());
assertEquals("$r1", uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
assertEquals("$r2", uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
uiModel.moveColumnTo(0, uiModelColumn1_1);
assertEquals(2, model.getActionCols().size());
assertEquals(column1, model.getActionCols().get(0));
assertEquals(column2, model.getActionCols().get(1));
assertEquals("$r1", model.getData().get(0).get(2).getStringValue());
assertEquals("$r2", 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("retract1", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
assertEquals("retract2", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_2 instanceof BoundFactUiColumn);
assertTrue(uiModelColumn2_2 instanceof BoundFactUiColumn);
assertEquals(2, uiModelColumn1_2.getIndex());
assertEquals(3, uiModelColumn2_2.getIndex());
assertEquals("$r1", uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
assertEquals("$r2", uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
Aggregations