Search in sources :

Example 6 with ActionRetractFactCol52

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());
}
Also used : ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) UpdateColumnAuditLogEntry(org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Test(org.junit.Test)

Example 7 with ActionRetractFactCol52

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

Example 8 with ActionRetractFactCol52

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

Example 9 with ActionRetractFactCol52

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

Example 10 with ActionRetractFactCol52

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

Aggregations

ActionRetractFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52)31 Test (org.junit.Test)24 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)11 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)10 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)8 LimitedEntryActionRetractFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionRetractFactCol52)7 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)6 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)4 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)4 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)4 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)4 LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)4 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)4 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)4 BoundFactUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BoundFactUiColumn)4 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)3 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2