use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method testMoveColumnsTo_MoveLeft_MidPoint.
@Test
public void testMoveColumnsTo_MoveLeft_MidPoint() throws VetoException {
final Pattern52 pattern1 = boundApplicantPattern("$a");
final ConditionCol52 column1p1 = ageEqualsCondition();
final ConditionCol52 column2p1 = nameEqualsCondition();
modelSynchronizer.appendColumn(pattern1, column1p1);
modelSynchronizer.appendColumn(pattern1, column2p1);
final Pattern52 pattern2 = boundAddressPattern("$d");
final ConditionCol52 column1p2 = new ConditionCol52();
column1p2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
column1p2.setFactField("state");
column1p2.setOperator("==");
column1p2.setHeader("state");
final ConditionCol52 column2p2 = new ConditionCol52();
column2p2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
column2p2.setFactField("country");
column2p2.setOperator("==");
column2p2.setHeader("country");
modelSynchronizer.appendColumn(pattern2, column1p2);
modelSynchronizer.appendColumn(pattern2, column2p2);
final Pattern52 pattern3 = boundAddressPattern("$d2");
final ConditionCol52 column1p3 = new ConditionCol52();
column1p3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
column1p3.setFactField("state");
column1p3.setOperator("==");
column1p3.setHeader("state");
final ConditionCol52 column2p3 = new ConditionCol52();
column2p3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
column2p3.setFactField("country");
column2p3.setOperator("==");
column2p3.setHeader("country");
modelSynchronizer.appendColumn(pattern3, column1p3);
modelSynchronizer.appendColumn(pattern3, column2p3);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<Integer>(45));
uiModel.setCellValue(0, 3, new BaseGridCellValue<String>("Smurf"));
uiModel.setCellValue(0, 4, new BaseGridCellValue<String>("NY"));
uiModel.setCellValue(0, 5, new BaseGridCellValue<String>("America"));
uiModel.setCellValue(0, 6, new BaseGridCellValue<String>("Essex"));
uiModel.setCellValue(0, 7, new BaseGridCellValue<String>("England"));
assertEquals(3, model.getPatterns().size());
final List<ConditionCol52> conditionColumns1_1p1 = model.getPatterns().get(0).getChildColumns();
assertEquals(column1p1, conditionColumns1_1p1.get(0));
assertEquals(column2p1, conditionColumns1_1p1.get(1));
assertEquals(45, model.getData().get(0).get(2).getNumericValue());
assertEquals("Smurf", model.getData().get(0).get(3).getStringValue());
final List<ConditionCol52> conditionColumns1_1p2 = model.getPatterns().get(1).getChildColumns();
assertEquals(column1p2, conditionColumns1_1p2.get(0));
assertEquals(column2p2, conditionColumns1_1p2.get(1));
assertEquals("NY", model.getData().get(0).get(4).getStringValue());
assertEquals("America", model.getData().get(0).get(5).getStringValue());
final List<ConditionCol52> conditionColumns1_1p3 = model.getPatterns().get(2).getChildColumns();
assertEquals(column1p3, conditionColumns1_1p3.get(0));
assertEquals(column2p3, conditionColumns1_1p3.get(1));
assertEquals("Essex", model.getData().get(0).get(6).getStringValue());
assertEquals("England", model.getData().get(0).get(7).getStringValue());
assertEquals(8, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(3);
final GridColumn<?> uiModelColumn3_1 = uiModel.getColumns().get(4);
final GridColumn<?> uiModelColumn4_1 = uiModel.getColumns().get(5);
final GridColumn<?> uiModelColumn5_1 = uiModel.getColumns().get(6);
final GridColumn<?> uiModelColumn6_1 = uiModel.getColumns().get(7);
assertEquals("$a : Applicant", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
assertEquals("$a : Applicant", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
assertEquals("$d : Address", uiModelColumn3_1.getHeaderMetaData().get(0).getTitle());
assertEquals("$d : Address", uiModelColumn4_1.getHeaderMetaData().get(0).getTitle());
assertEquals("$d2 : Address", uiModelColumn5_1.getHeaderMetaData().get(0).getTitle());
assertEquals("$d2 : Address", uiModelColumn6_1.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_1 instanceof IntegerUiColumn);
assertTrue(uiModelColumn2_1 instanceof StringUiColumn);
assertTrue(uiModelColumn3_1 instanceof StringUiColumn);
assertTrue(uiModelColumn4_1 instanceof StringUiColumn);
assertTrue(uiModelColumn5_1 instanceof StringUiColumn);
assertTrue(uiModelColumn6_1 instanceof StringUiColumn);
assertEquals(2, uiModelColumn1_1.getIndex());
assertEquals(3, uiModelColumn2_1.getIndex());
assertEquals(4, uiModelColumn3_1.getIndex());
assertEquals(5, uiModelColumn4_1.getIndex());
assertEquals(6, uiModelColumn5_1.getIndex());
assertEquals(7, uiModelColumn6_1.getIndex());
assertEquals(45, uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
assertEquals("NY", uiModel.getRow(0).getCells().get(uiModelColumn3_1.getIndex()).getValue().getValue());
assertEquals("America", uiModel.getRow(0).getCells().get(uiModelColumn4_1.getIndex()).getValue().getValue());
assertEquals("Essex", uiModel.getRow(0).getCells().get(uiModelColumn5_1.getIndex()).getValue().getValue());
assertEquals("England", uiModel.getRow(0).getCells().get(uiModelColumn6_1.getIndex()).getValue().getValue());
uiModel.moveColumnsTo(4, new ArrayList<GridColumn<?>>() {
{
add(uiModelColumn5_1);
add(uiModelColumn6_1);
}
});
assertEquals(3, model.getPatterns().size());
final List<ConditionCol52> conditionColumns1_2p1 = model.getPatterns().get(0).getChildColumns();
assertEquals(column1p1, conditionColumns1_2p1.get(0));
assertEquals(column2p1, conditionColumns1_2p1.get(1));
assertEquals(45, model.getData().get(0).get(2).getNumericValue());
assertEquals("Smurf", model.getData().get(0).get(3).getStringValue());
final List<ConditionCol52> conditionColumns1_2p3 = model.getPatterns().get(1).getChildColumns();
assertEquals(column1p3, conditionColumns1_2p3.get(0));
assertEquals(column2p3, conditionColumns1_2p3.get(1));
assertEquals("Essex", model.getData().get(0).get(4).getStringValue());
assertEquals("England", model.getData().get(0).get(5).getStringValue());
final List<ConditionCol52> conditionColumns1_2p2 = model.getPatterns().get(2).getChildColumns();
assertEquals(column1p2, conditionColumns1_2p2.get(0));
assertEquals(column2p2, conditionColumns1_2p2.get(1));
assertEquals("NY", model.getData().get(0).get(6).getStringValue());
assertEquals("America", model.getData().get(0).get(7).getStringValue());
assertEquals(8, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
final GridColumn<?> uiModelColumn3_2 = uiModel.getColumns().get(4);
final GridColumn<?> uiModelColumn4_2 = uiModel.getColumns().get(5);
final GridColumn<?> uiModelColumn5_2 = uiModel.getColumns().get(6);
final GridColumn<?> uiModelColumn6_2 = uiModel.getColumns().get(7);
assertEquals("$a : Applicant", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
assertEquals("$a : Applicant", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
assertEquals("$d2 : Address", uiModelColumn3_2.getHeaderMetaData().get(0).getTitle());
assertEquals("$d2 : Address", uiModelColumn4_2.getHeaderMetaData().get(0).getTitle());
assertEquals("$d : Address", uiModelColumn5_2.getHeaderMetaData().get(0).getTitle());
assertEquals("$d : Address", uiModelColumn6_2.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_2 instanceof IntegerUiColumn);
assertTrue(uiModelColumn2_2 instanceof StringUiColumn);
assertTrue(uiModelColumn3_2 instanceof StringUiColumn);
assertTrue(uiModelColumn4_2 instanceof StringUiColumn);
assertTrue(uiModelColumn5_2 instanceof StringUiColumn);
assertTrue(uiModelColumn6_2 instanceof StringUiColumn);
assertEquals(2, uiModelColumn1_2.getIndex());
assertEquals(3, uiModelColumn2_2.getIndex());
assertEquals(6, uiModelColumn3_2.getIndex());
assertEquals(7, uiModelColumn4_2.getIndex());
assertEquals(4, uiModelColumn5_2.getIndex());
assertEquals(5, uiModelColumn6_2.getIndex());
assertEquals(45, uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
assertEquals("Essex", uiModel.getRow(0).getCells().get(uiModelColumn3_2.getIndex()).getValue().getValue());
assertEquals("England", uiModel.getRow(0).getCells().get(uiModelColumn4_2.getIndex()).getValue().getValue());
assertEquals("NY", uiModel.getRow(0).getCells().get(uiModelColumn5_2.getIndex()).getValue().getValue());
assertEquals("America", uiModel.getRow(0).getCells().get(uiModelColumn6_2.getIndex()).getValue().getValue());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 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, 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,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, 2).getValue().getValue().toString());
assertEquals("B", uiModel.getCell(1, 2).getValue().getValue().toString());
assertEquals("C", uiModel.getCell(2, 2).getValue().getValue().toString());
assertEquals("A", model.getData().get(0).get(2).getStringValue());
assertEquals("B", model.getData().get(1).get(2).getStringValue());
assertEquals("C", model.getData().get(2).get(2).getStringValue());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method testMoveColumnTo_MoveLeft.
@Test
public void testMoveColumnTo_MoveLeft() throws VetoException {
final Pattern52 pattern = boundApplicantPattern("$a");
final ConditionCol52 column1 = ageEqualsCondition();
final ConditionCol52 column2 = nameEqualsCondition();
modelSynchronizer.appendColumn(pattern, column1);
modelSynchronizer.appendColumn(pattern, column2);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<Integer>(45));
uiModel.setCellValue(0, 3, new BaseGridCellValue<String>("Smurf"));
assertEquals(1, model.getPatterns().size());
final List<ConditionCol52> conditionColumns1_1 = model.getPatterns().get(0).getChildColumns();
assertEquals(column1, conditionColumns1_1.get(0));
assertEquals(column2, conditionColumns1_1.get(1));
assertEquals(45, model.getData().get(0).get(2).getNumericValue());
assertEquals("Smurf", 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("$a : Applicant", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
assertEquals("$a : Applicant", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_1 instanceof IntegerUiColumn);
assertTrue(uiModelColumn2_1 instanceof StringUiColumn);
assertEquals(2, uiModelColumn1_1.getIndex());
assertEquals(3, uiModelColumn2_1.getIndex());
assertEquals(45, uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
uiModel.moveColumnTo(2, uiModelColumn2_1);
assertEquals(1, model.getPatterns().size());
final List<ConditionCol52> conditionColumns1_2 = model.getPatterns().get(0).getChildColumns();
assertEquals(column2, conditionColumns1_2.get(0));
assertEquals(column1, conditionColumns1_2.get(1));
assertEquals("Smurf", model.getData().get(0).get(2).getStringValue());
assertEquals(45, model.getData().get(0).get(3).getNumericValue());
assertEquals(4, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
assertEquals("$a : Applicant", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
assertEquals("$a : Applicant", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_2 instanceof StringUiColumn);
assertTrue(uiModelColumn2_2 instanceof IntegerUiColumn);
assertEquals(3, uiModelColumn1_2.getIndex());
assertEquals(2, uiModelColumn2_2.getIndex());
assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
assertEquals(45, uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method testAppend3.
@Test
public void testAppend3() throws VetoException {
// Multiple Patterns, multiple Conditions
final Pattern52 pattern1 = boundApplicantPattern("$a");
final ConditionCol52 condition1 = ageEqualsCondition();
modelSynchronizer.appendColumn(pattern1, condition1);
assertEquals(3, model.getExpandedColumns().size());
assertEquals(1, model.getConditions().size());
assertEquals(3, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
final Pattern52 pattern2 = boundAddressPattern("$d");
final ConditionCol52 condition2 = new ConditionCol52();
condition2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
condition2.setHeader("col2");
condition2.setFactField("country");
condition2.setOperator("==");
modelSynchronizer.appendColumn(pattern2, condition2);
assertEquals(4, model.getExpandedColumns().size());
assertEquals(2, model.getConditions().size());
assertEquals(1, model.getConditionPattern("$a").getChildColumns().size());
assertEquals(1, model.getConditionPattern("$d").getChildColumns().size());
assertEquals(4, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method nameEqualsCondition.
private ConditionCol52 nameEqualsCondition() {
ConditionCol52 condition = new ConditionCol52();
condition.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
condition.setHeader("col2");
condition.setFactField("name");
condition.setOperator("==");
return condition;
}
Aggregations