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(4, model.getExpandedColumns().size());
assertEquals(1, model.getConditions().size());
assertEquals(1, model.getConditionPattern("$a").getChildColumns().size());
assertEquals(4, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(3) instanceof IntegerUiColumn);
assertEquals(false, uiModel.getColumns().get(3).isVisible());
assertEquals(editedPattern.getBoundName() + " : " + editedPattern.getFactType(), uiModel.getColumns().get(3).getHeaderMetaData().get(0).getTitle());
assertEquals(editedCondition.getHeader(), uiModel.getColumns().get(3).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, 3, new BaseGridCellValue<>("A"));
uiModel.setCellValue(1, 3, new BaseGridCellValue<>("B"));
uiModel.setCellValue(2, 3, 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, 3).getValue().getValue().toString());
assertNull(uiModel.getCell(1, 3));
assertNull(uiModel.getCell(2, 3));
assertEquals("A", model.getData().get(0).get(3).getStringValue());
assertFalse(model.getData().get(1).get(3).hasValue());
assertFalse(model.getData().get(2).get(3).hasValue());
}
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(4, model.getExpandedColumns().size());
assertEquals(1, model.getConditions().size());
assertEquals(1, model.getConditionPattern(boundName).getChildColumns().size());
assertEquals(4, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
final String expectedTitle = editedPattern.getBoundName() + " : " + editedPattern.getFactType();
final String actualTitle = uiModel.getColumns().get(3).getHeaderMetaData().get(0).getTitle();
assertEquals(expectedTitle, actualTitle);
final String expectedHeader = editedCondition.getHeader();
final String actualHeader = uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle();
assertEquals(expectedHeader, actualHeader);
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method testUpdate1.
@Test
public void testUpdate1() throws VetoException {
// Single Pattern, single Condition
final Pattern52 pattern = spy(boundApplicantPattern("$a"));
final ConditionCol52 condition = spy(ageEqualsCondition());
modelSynchronizer.appendColumn(pattern, condition);
final Pattern52 editedPattern = boundApplicantPattern("$a");
final ConditionCol52 editedCondition = nameEqualsCondition();
editedCondition.setWidth(condition.getWidth());
List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(pattern, condition, editedPattern, editedCondition);
assertEquals(2, diffs.size());
verify(pattern).diff(editedPattern);
verify(condition).diff(editedCondition);
assertEquals("header", diffs.get(0).getFieldName());
assertEquals("factField", diffs.get(1).getFieldName());
assertEquals(4, model.getExpandedColumns().size());
assertEquals(1, model.getConditions().size());
assertEquals(1, model.getConditionPattern("$a").getChildColumns().size());
assertEquals(4, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
assertEquals(editedPattern.getBoundName() + " : " + editedPattern.getFactType(), uiModel.getColumns().get(3).getHeaderMetaData().get(0).getTitle());
assertEquals(editedCondition.getHeader(), uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class ActionWorkItemInsertFactColumnSynchronizerTest method testUpdate.
@Test
public void testUpdate() throws VetoException {
final ActionWorkItemInsertFactCol52 column = spy(new ActionWorkItemInsertFactCol52());
column.setWorkItemName(WORK_ITEM_NAME);
column.setHeader("col1");
modelSynchronizer.appendColumn(column);
final ActionWorkItemInsertFactCol52 edited = new ActionWorkItemInsertFactCol52();
edited.setWorkItemName(WORK_ITEM_NAME);
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(2, model.getActionCols().size());
assertEquals(5, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(4) instanceof BooleanUiColumn);
assertEquals("updated", uiModel.getColumns().get(4).getHeaderMetaData().get(1).getTitle());
assertEquals(false, uiModel.getColumns().get(4).isVisible());
}
Aggregations