Search in sources :

Example 1 with BaseColumnFieldDiff

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());
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) Test(org.junit.Test)

Example 2 with BaseColumnFieldDiff

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());
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) Test(org.junit.Test)

Example 3 with BaseColumnFieldDiff

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());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) Test(org.junit.Test)

Example 4 with BaseColumnFieldDiff

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());
}
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 5 with BaseColumnFieldDiff

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());
}
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

BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)66 Test (org.junit.Test)39 UpdateColumnAuditLogEntry (org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry)15 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)14 StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)13 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)12 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)12 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)12 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)10 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)8 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)6 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)6 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)4 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)4 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)4 BooleanUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn)4 ArrayList (java.util.ArrayList)3 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)3 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)3 ActionWorkItemInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52)3