use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class MetaDataColumnSynchronizerTest method testUpdate2.
@Test
public void testUpdate2() throws VetoException {
final MetadataCol52 column = spy(new MetadataCol52());
column.setMetadata("smurf");
modelSynchronizer.appendColumn(column);
final MetadataCol52 edited = new MetadataCol52();
edited.setWidth(column.getWidth());
edited.setMetadata("smurf");
edited.setHideColumn(true);
List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
assertEquals(1, diffs.size());
verify(column).diff(edited);
assertEquals(1, model.getMetadataCols().size());
assertEquals("smurf", model.getMetadataCols().get(0).getMetadata());
assertEquals(4, uiModel.getColumns().size());
assertEquals("smurf", uiModel.getColumns().get(3).getHeaderMetaData().get(0).getTitle());
assertEquals(false, uiModel.getColumns().get(3).isVisible());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class MetaDataColumnSynchronizerTest method testUpdate1.
@Test
public void testUpdate1() throws VetoException {
final MetadataCol52 column = spy(new MetadataCol52());
column.setMetadata("smurf");
modelSynchronizer.appendColumn(column);
final MetadataCol52 edited = new MetadataCol52();
edited.setWidth(column.getWidth());
edited.setMetadata("changed");
List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
assertEquals(1, diffs.size());
verify(column).diff(edited);
assertEquals(1, model.getMetadataCols().size());
assertEquals("changed", model.getMetadataCols().get(0).getMetadata());
assertEquals(4, uiModel.getColumns().size());
assertEquals("changed", uiModel.getColumns().get(3).getHeaderMetaData().get(0).getTitle());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method checkAddToValueListPreservesData.
@Test
public void checkAddToValueListPreservesData() 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,B,C,D");
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());
assertEquals("B", uiModel.getCell(1, 3).getValue().getValue().toString());
assertEquals("C", uiModel.getCell(2, 3).getValue().getValue().toString());
assertEquals("A", model.getData().get(0).get(3).getStringValue());
assertEquals("B", model.getData().get(1).get(3).getStringValue());
assertEquals("C", model.getData().get(2).get(3).getStringValue());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method testUpdate3.
@Test
public void testUpdate3() throws VetoException {
// Multiple Patterns, multiple Conditions
final Pattern52 pattern1 = spy(boundApplicantPattern("$a"));
final ConditionCol52 condition1 = spy(ageEqualsCondition());
modelSynchronizer.appendColumn(pattern1, condition1);
final ConditionCol52 condition2 = nameEqualsCondition();
modelSynchronizer.appendColumn(pattern1, condition2);
final Pattern52 editedPattern = boundAddressPattern("$d");
final ConditionCol52 editedCondition = new ConditionCol52();
editedCondition.setWidth(condition1.getWidth());
editedCondition.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
editedCondition.setHeader("col1");
editedCondition.setFactField("country");
editedCondition.setOperator("==");
List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(pattern1, condition1, editedPattern, editedCondition);
assertEquals(3, diffs.size());
verify(pattern1).diff(editedPattern);
verify(condition1).diff(editedCondition);
assertEquals(5, model.getExpandedColumns().size());
assertEquals(2, model.getConditions().size());
assertEquals(1, model.getConditionPattern("$a").getChildColumns().size());
assertEquals(1, model.getConditionPattern("$d").getChildColumns().size());
assertEquals(5, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
assertTrue(uiModel.getColumns().get(4) instanceof StringUiColumn);
assertEquals(editedPattern.getBoundName() + " : " + editedPattern.getFactType(), uiModel.getColumns().get(4).getHeaderMetaData().get(0).getTitle());
assertEquals(editedCondition.getHeader(), uiModel.getColumns().get(4).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 testUpdate2.
@Test
public void testUpdate2() throws VetoException {
// Single Pattern, multiple Conditions
final Pattern52 pattern = spy(boundApplicantPattern("$a"));
final ConditionCol52 condition1 = spy(ageEqualsCondition());
condition1.setHeader("$a age is");
modelSynchronizer.appendColumn(pattern, condition1);
final ConditionCol52 condition2 = nameEqualsCondition();
modelSynchronizer.appendColumn(pattern, condition2);
final Pattern52 editedPattern = boundApplicantPattern("$a2");
final ConditionCol52 editedCondition = ageEqualsCondition();
editedCondition.setWidth(condition2.getWidth());
editedCondition.setHeader("$a2 age is");
List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(pattern, condition1, editedPattern, editedCondition);
assertEquals(2, diffs.size());
verify(pattern).diff(editedPattern);
verify(condition1).diff(editedCondition);
assertEquals(5, model.getExpandedColumns().size());
assertEquals(2, model.getConditions().size());
assertEquals(1, model.getConditionPattern("$a").getChildColumns().size());
assertEquals(1, model.getConditionPattern("$a2").getChildColumns().size());
assertEquals(5, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
assertTrue(uiModel.getColumns().get(4) instanceof IntegerUiColumn);
assertEquals(editedPattern.getBoundName() + " : " + editedPattern.getFactType(), uiModel.getColumns().get(4).getHeaderMetaData().get(0).getTitle());
assertEquals(editedCondition.getHeader(), uiModel.getColumns().get(4).getHeaderMetaData().get(1).getTitle());
}
Aggregations