Search in sources :

Example 81 with Pattern52

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

the class ConditionColumnSynchronizerTest method testAppendNegated.

@Test
public void testAppendNegated() throws VetoException {
    final Pattern52 pattern = new Pattern52();
    pattern.setNegated(true);
    pattern.setFactType("Applicant");
    final ConditionCol52 condition1 = ageEqualsCondition();
    modelSynchronizer.appendColumn(pattern, condition1);
    assertEquals(3, model.getExpandedColumns().size());
    assertEquals(1, model.getConditions().size());
    assertEquals(3, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
    final ConditionCol52 condition2 = nameEqualsCondition();
    modelSynchronizer.appendColumn(pattern, condition2);
    assertEquals(4, model.getExpandedColumns().size());
    assertEquals(1, model.getConditions().size());
    assertEquals(2, model.getConditions().get(0).getChildColumns().size());
    assertEquals(4, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
    assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
    assertEquals("not Applicant", uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
    assertEquals("not Applicant", uiModel.getColumns().get(3).getHeaderMetaData().get(0).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) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) Test(org.junit.Test)

Example 82 with Pattern52

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

the class ConditionColumnSynchronizerTest method testDelete3.

@Test
public void testDelete3() throws VetoException {
    // Multiple Patterns, multiple Conditions
    final Pattern52 pattern1 = boundApplicantPattern("$a");
    final ConditionCol52 condition1 = ageEqualsCondition();
    modelSynchronizer.appendColumn(pattern1, condition1);
    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());
    modelSynchronizer.deleteColumn(condition1);
    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());
}
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 83 with Pattern52

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

the class ConditionColumnSynchronizerTest method testMoveColumnTo_MoveRight.

@Test
public void testMoveColumnTo_MoveRight() 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(3, uiModelColumn1_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());
}
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)

Example 84 with Pattern52

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

the class ConditionColumnSynchronizerTest method testUpdateToNegated.

@Test
public void testUpdateToNegated() throws VetoException {
    final Pattern52 pattern = spy(boundApplicantPattern("$a"));
    final ConditionCol52 condition = spy(ageEqualsCondition());
    modelSynchronizer.appendColumn(pattern, condition);
    assertEquals("$a : Applicant", uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
    final Pattern52 editedPattern = new Pattern52();
    editedPattern.setNegated(true);
    editedPattern.setFactType("Applicant");
    final ConditionCol52 editedCondition = spy(ageEqualsCondition());
    modelSynchronizer.updateColumn(pattern, condition, editedPattern, editedCondition);
    assertEquals("not Applicant", 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) Test(org.junit.Test)

Example 85 with Pattern52

use of org.drools.workbench.models.guided.dtable.shared.model.Pattern52 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());
    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());
    List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(pattern, condition1, editedPattern, editedCondition);
    assertEquals(1, diffs.size());
    verify(pattern).diff(editedPattern);
    verify(condition1).diff(editedCondition);
    assertEquals(4, model.getExpandedColumns().size());
    assertEquals(2, model.getConditions().size());
    assertEquals(1, model.getConditionPattern("$a").getChildColumns().size());
    assertEquals(1, model.getConditionPattern("$a2").getChildColumns().size());
    assertEquals(4, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof StringUiColumn);
    assertTrue(uiModel.getColumns().get(3) instanceof IntegerUiColumn);
    assertEquals(editedPattern.getBoundName() + " : " + editedPattern.getFactType(), uiModel.getColumns().get(3).getHeaderMetaData().get(0).getTitle());
    assertEquals(editedCondition.getHeader(), uiModel.getColumns().get(3).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) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) Test(org.junit.Test)

Aggregations

Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)243 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)184 Test (org.junit.Test)180 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)92 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)66 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)45 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)39 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)34 ArrayList (java.util.ArrayList)31 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)31 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)28 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)27 Path (org.uberfire.backend.vfs.Path)27 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)26 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)26 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)26 StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)25 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)24 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)24 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)24