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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations