Search in sources :

Example 86 with ConditionCol52

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

the class ConditionColumnSynchronizerTest method testAppendBoolean.

@Test
public void testAppendBoolean() throws VetoException {
    // Single Pattern, single Condition
    final Pattern52 pattern = boundApplicantPattern("$a");
    final ConditionCol52 condition = new ConditionCol52();
    condition.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    condition.setHeader("col1");
    condition.setFactField("approved");
    condition.setOperator("==");
    // Test column append
    modelSynchronizer.appendColumn(pattern, condition);
    modelSynchronizer.appendRow();
    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 BooleanUiColumn);
    // Test row append (boolean cells should be instantiated for Model and UiModel)
    modelSynchronizer.appendRow();
    assertFalse(model.getData().get(0).get(2).getBooleanValue());
    assertFalse(((Boolean) uiModel.getRow(0).getCells().get(2).getValue().getValue()));
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BooleanUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn) Test(org.junit.Test)

Example 87 with ConditionCol52

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

the class ConditionColumnSynchronizerTest method checkConditionCanBeDeletedWithMultipleChildColumns.

@Test
public void checkConditionCanBeDeletedWithMultipleChildColumns() throws VetoException {
    final Pattern52 pattern = boundApplicantPattern("$a");
    final ConditionCol52 condition1 = ageEqualsCondition();
    final ConditionCol52 condition2 = nameEqualsCondition();
    modelSynchronizer.appendColumn(pattern, condition1);
    modelSynchronizer.appendColumn(pattern, condition2);
    try {
        modelSynchronizer.deleteColumn(condition2);
    } catch (VetoException veto) {
        fail("Deletion should have been permitted.");
    }
    assertEquals(3, model.getExpandedColumns().size());
    assertTrue(model.getExpandedColumns().get(0) instanceof RowNumberCol52);
    assertTrue(model.getExpandedColumns().get(1) instanceof DescriptionCol52);
    assertEquals(condition1, model.getExpandedColumns().get(2));
}
Also used : VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 88 with ConditionCol52

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

the class ConditionColumnSynchronizerTest method testUpdate4.

@Test
public void testUpdate4() throws VetoException {
    // Multiple Patterns, multiple Conditions
    final Pattern52 pattern1 = spy(boundApplicantPattern("$a"));
    final ConditionCol52 condition1 = spy(ageEqualsCondition());
    modelSynchronizer.appendColumn(pattern1, condition1);
    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(3, model.getExpandedColumns().size());
    assertEquals(1, model.getConditions().size());
    assertNull(model.getConditionPattern("$a"));
    assertEquals(1, model.getConditionPattern("$d").getChildColumns().size());
    assertEquals(3, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof StringUiColumn);
    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) 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)

Example 89 with ConditionCol52

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

the class ConditionColumnSynchronizerTest method testDelete2.

@Test
public void testDelete2() throws VetoException {
    // Single Pattern, multiple Conditions
    final Pattern52 pattern = boundApplicantPattern("$a");
    final ConditionCol52 condition1 = ageEqualsCondition();
    modelSynchronizer.appendColumn(pattern, condition1);
    final ConditionCol52 condition2 = nameEqualsCondition();
    modelSynchronizer.appendColumn(pattern, condition2);
    assertEquals(4, model.getExpandedColumns().size());
    assertEquals(1, model.getConditions().size());
    assertEquals(4, uiModel.getColumns().size());
    modelSynchronizer.deleteColumn(condition1);
    assertEquals(3, model.getExpandedColumns().size());
    assertEquals(1, model.getConditions().size());
    assertEquals(1, model.getConditionPattern("$a").getChildColumns().size());
    assertEquals(3, uiModel.getColumns().size());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) Test(org.junit.Test)

Example 90 with ConditionCol52

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

the class ConditionColumnSynchronizerTest method testMoveColumnTo_SingleColumnPattern.

@Test
public void testMoveColumnTo_SingleColumnPattern() throws VetoException {
    final Pattern52 pattern1 = boundApplicantPattern("$a");
    final ConditionCol52 column1p1 = ageEqualsCondition();
    modelSynchronizer.appendColumn(pattern1, column1p1);
    final Pattern52 pattern2 = boundApplicantPattern("$a2");
    final ConditionCol52 column1p2 = nameEqualsCondition();
    modelSynchronizer.appendColumn(pattern2, column1p2);
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 2, new BaseGridCellValue<Integer>(45));
    uiModel.setCellValue(0, 3, new BaseGridCellValue<String>("Smurf"));
    assertEquals(2, model.getPatterns().size());
    final List<ConditionCol52> conditionColumns1_1 = model.getPatterns().get(0).getChildColumns();
    assertEquals(column1p1, conditionColumns1_1.get(0));
    final List<ConditionCol52> conditionColumns2_1 = model.getPatterns().get(1).getChildColumns();
    assertEquals(column1p2, conditionColumns2_1.get(0));
    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("$a2 : 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(3, uiModelColumn1_1);
    assertEquals(2, model.getPatterns().size());
    final List<ConditionCol52> conditionColumns1_2 = model.getPatterns().get(0).getChildColumns();
    assertEquals(column1p2, conditionColumns1_2.get(0));
    final List<ConditionCol52> conditionColumns2_2 = model.getPatterns().get(1).getChildColumns();
    assertEquals(column1p1, conditionColumns2_2.get(0));
    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("$a2 : 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());
}
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) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) Test(org.junit.Test)

Aggregations

ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)229 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)184 Test (org.junit.Test)170 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)74 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)59 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)38 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)38 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)34 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)31 ArrayList (java.util.ArrayList)27 Path (org.uberfire.backend.vfs.Path)27 StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)25 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)25 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)25 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)25 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)24 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)24 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)23 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)23 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)23