Search in sources :

Example 61 with BaseColumnFieldDiff

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.

the class AttributeColumnSynchronizerTest method testUpdate2.

@Test
public void testUpdate2() throws VetoException {
    final AttributeCol52 column = spy(new AttributeCol52());
    column.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
    modelSynchronizer.appendColumn(column);
    final AttributeCol52 edited = new AttributeCol52();
    edited.setWidth(column.getWidth());
    edited.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
    edited.setHideColumn(true);
    List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
    assertEquals(1, diffs.size());
    verify(column).diff(edited);
    assertEquals(1, model.getAttributeCols().size());
    assertEquals(RuleAttributeWidget.SALIENCE_ATTR, model.getAttributeCols().get(0).getAttribute());
    assertEquals(3, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
    assertEquals(RuleAttributeWidget.SALIENCE_ATTR, uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
    assertEquals(false, uiModel.getColumns().get(2).isVisible());
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) Test(org.junit.Test)

Example 62 with BaseColumnFieldDiff

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.

the class BRLConditionColumnSynchronizerTest method testUpdate3.

@Test
public void testUpdate3() throws VetoException {
    // Single Column, multiple variables
    final BRLConditionColumn column = spy(new BRLConditionColumn());
    final BRLConditionVariableColumn columnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
    final BRLConditionVariableColumn columnV1 = new BRLConditionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
    column.getChildColumns().add(columnV0);
    column.getChildColumns().add(columnV1);
    column.setHeader("col1");
    columnV0.setHeader("col1v0");
    columnV1.setHeader("col1v1");
    modelSynchronizer.appendColumn(column);
    assertEquals(4, model.getExpandedColumns().size());
    assertEquals(1, model.getConditions().size());
    assertEquals(4, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
    assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
    assertEquals("$age", uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle());
    final BRLConditionColumn edited = new BRLConditionColumn();
    final BRLConditionVariableColumn editedColumnV0 = new BRLConditionVariableColumn("$s", DataType.TYPE_NUMERIC_LONG, "Applicant", "salary");
    edited.getChildColumns().add(editedColumnV0);
    edited.setHideColumn(true);
    edited.setHeader("updated");
    editedColumnV0.setHeader("updated");
    List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
    assertEquals(6, // header, hide, field name, field type, binding, removed column
    diffs.size());
    verify(column).diff(edited);
    assertEquals(3, model.getExpandedColumns().size());
    assertEquals(1, model.getConditions().size());
    assertEquals(3, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof LongUiColumn);
    assertEquals("updated", uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
    assertEquals(false, uiModel.getColumns().get(2).isVisible());
    assertEquals("$s", uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle());
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) LongUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.LongUiColumn) StringUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) Test(org.junit.Test)

Example 63 with BaseColumnFieldDiff

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.

the class ConditionColumnSynchronizerTest method checkRemoveFromValueListClearsData.

@Test
public void checkRemoveFromValueListClearsData() throws VetoException {
    // Single Pattern, single Condition
    final Pattern52 pattern = spy(boundApplicantPattern("$a"));
    final ConditionCol52 condition = spy(nameEqualsCondition());
    condition.setValueList("A,B,C");
    modelSynchronizer.appendColumn(pattern, condition);
    modelSynchronizer.appendRow();
    modelSynchronizer.appendRow();
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 2, new BaseGridCellValue<>("A"));
    uiModel.setCellValue(1, 2, new BaseGridCellValue<>("B"));
    uiModel.setCellValue(2, 2, new BaseGridCellValue<>("C"));
    final Pattern52 editedPattern = boundApplicantPattern("$a");
    final ConditionCol52 editedCondition = nameEqualsCondition();
    editedCondition.setWidth(condition.getWidth());
    editedCondition.setValueList("A");
    List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(pattern, condition, editedPattern, editedCondition);
    assertEquals(1, diffs.size());
    verify(pattern).diff(editedPattern);
    verify(condition).diff(editedCondition);
    assertEquals(ConditionCol52.FIELD_VALUE_LIST, diffs.get(0).getFieldName());
    assertEquals("A", uiModel.getCell(0, 2).getValue().getValue().toString());
    assertNull(uiModel.getCell(1, 2));
    assertNull(uiModel.getCell(2, 2));
    assertEquals("A", model.getData().get(0).get(2).getStringValue());
    assertFalse(model.getData().get(1).get(2).hasValue());
    assertFalse(model.getData().get(2).get(2).hasValue());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) Test(org.junit.Test)

Example 64 with BaseColumnFieldDiff

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.

the class ConditionColumnSynchronizerTest method testUpdate5.

@Test
public void testUpdate5() throws VetoException {
    final Pattern52 pattern1 = spy(boundApplicantPattern("$a"));
    final ConditionCol52 condition1 = spy(ageEqualsCondition());
    modelSynchronizer.appendColumn(pattern1, condition1);
    final Pattern52 editedPattern = boundApplicantPattern("$a");
    final ConditionCol52 editedCondition = ageEqualsCondition();
    editedCondition.setWidth(condition1.getWidth());
    editedCondition.setHideColumn(true);
    editedCondition.setHeader("updated");
    List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(pattern1, condition1, editedPattern, editedCondition);
    assertEquals(2, diffs.size());
    verify(pattern1).diff(editedPattern);
    verify(condition1).diff(editedCondition);
    assertEquals(3, model.getExpandedColumns().size());
    assertEquals(1, model.getConditions().size());
    assertEquals(1, model.getConditionPattern("$a").getChildColumns().size());
    assertEquals(3, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
    assertEquals(false, uiModel.getColumns().get(2).isVisible());
    assertEquals(editedPattern.getBoundName() + " : " + editedPattern.getFactType(), uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
    assertEquals(editedCondition.getHeader(), uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) Test(org.junit.Test)

Example 65 with BaseColumnFieldDiff

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.

the class ConditionColumnSynchronizerTest method testUpdate7.

@Test
public void testUpdate7() throws VetoException {
    // Single Pattern (updated), single Condition
    final String boundName = "$a";
    final Pattern52 pattern = spy(boundApplicantPattern(boundName));
    final Pattern52 editedPattern = boundApplicantPattern(boundName);
    final ConditionCol52 condition = spy(ageEqualsCondition());
    final ConditionCol52 editedCondition = nameEqualsCondition();
    final String entryPoint = "entryPoint";
    modelSynchronizer.appendColumn(pattern, condition);
    editedPattern.setEntryPointName(entryPoint);
    editedCondition.setWidth(condition.getWidth());
    final List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(pattern, condition, editedPattern, editedCondition);
    assertEquals(3, diffs.size());
    verify(pattern).diff(editedPattern);
    verify(condition).diff(editedCondition);
    verify(pattern).setEntryPointName(entryPoint);
    assertEquals("entryPointName", diffs.get(0).getFieldName());
    assertEquals("header", diffs.get(1).getFieldName());
    assertEquals("factField", diffs.get(2).getFieldName());
    assertEquals(3, model.getExpandedColumns().size());
    assertEquals(1, model.getConditions().size());
    assertEquals(1, model.getConditionPattern(boundName).getChildColumns().size());
    assertEquals(3, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof StringUiColumn);
    final String expectedTitle = editedPattern.getBoundName() + " : " + editedPattern.getFactType();
    final String actualTitle = uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle();
    assertEquals(expectedTitle, actualTitle);
    final String expectedHeader = editedCondition.getHeader();
    final String actualHeader = uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle();
    assertEquals(expectedHeader, actualHeader);
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) StringUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) Test(org.junit.Test)

Aggregations

BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)66 Test (org.junit.Test)39 UpdateColumnAuditLogEntry (org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry)15 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)14 StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)13 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)12 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)12 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)12 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)10 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)8 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)6 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)6 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)4 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)4 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)4 BooleanUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn)4 ArrayList (java.util.ArrayList)3 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)3 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)3 ActionWorkItemInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52)3