Search in sources :

Example 26 with BRLConditionColumn

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

the class ColumnManagementViewTest method testRenderColumnBrlConditionEditable.

@Test
public void testRenderColumnBrlConditionEditable() throws Exception {
    final BRLConditionColumn conditionColumnOne = mock(BRLConditionColumn.class);
    final BRLConditionColumn conditionColumnTwo = mock(BRLConditionColumn.class);
    final Map<String, List<BaseColumn>> columnGroups = new HashMap<String, List<BaseColumn>>() {

        {
            put(GuidedDecisionTableConstants.INSTANCE.BrlConditions(), Arrays.asList(conditionColumnOne, conditionColumnTwo));
        }
    };
    final ColumnLabelWidget columnLabel = mockColumnLabelWidget();
    doReturn(columnLabel).when(view).newColumnLabelWidget(anyString());
    doReturn(true).when(modellerPresenter).isActiveDecisionTableEditable();
    doReturn("brl one").when(conditionColumnOne).getHeader();
    doReturn("brl two").when(conditionColumnTwo).getHeader();
    view.renderColumns(columnGroups);
    verify(view).renderColumn(conditionColumnOne);
    verify(view).renderColumn(conditionColumnTwo);
    // There are two brl conditions
    verify(horizontalPanel, times(2)).add(columnLabel);
    verify(view, times(2)).editAnchor(clickHandlerCaptor.capture());
    verify(view).deleteAnchor(eq("brl one"), any(Command.class));
    verify(view).deleteAnchor(eq("brl two"), any(Command.class));
    clickHandlerCaptor.getAllValues().get(0).onClick(mock(ClickEvent.class));
    verify(decisionTablePresenter).editCondition(eq(conditionColumnOne));
    clickHandlerCaptor.getAllValues().get(1).onClick(mock(ClickEvent.class));
    verify(decisionTablePresenter).editCondition(eq(conditionColumnTwo));
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) HashMap(java.util.HashMap) Command(com.google.gwt.user.client.Command) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) List(java.util.List) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 27 with BRLConditionColumn

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

the class ColumnManagementViewTest method testRenderColumnBrlConditionNotEditable.

@Test
public void testRenderColumnBrlConditionNotEditable() throws Exception {
    final BRLConditionColumn conditionColumnOne = mock(BRLConditionColumn.class);
    final BRLConditionColumn conditionColumnTwo = mock(BRLConditionColumn.class);
    final Map<String, List<BaseColumn>> columnGroups = new HashMap<String, List<BaseColumn>>() {

        {
            put(GuidedDecisionTableConstants.INSTANCE.BrlConditions(), Arrays.asList(conditionColumnOne, conditionColumnTwo));
        }
    };
    final ColumnLabelWidget columnLabel = mockColumnLabelWidget();
    doReturn(columnLabel).when(view).newColumnLabelWidget(anyString());
    doReturn("brl one").when(conditionColumnOne).getHeader();
    doReturn("brl two").when(conditionColumnTwo).getHeader();
    view.renderColumns(columnGroups);
    verify(view).renderColumn(conditionColumnOne);
    verify(view).renderColumn(conditionColumnTwo);
    // There are two brl conditions
    verify(horizontalPanel, times(2)).add(columnLabel);
    verify(view, times(2)).editAnchor(any(ClickHandler.class));
    verify(view, never()).deleteAnchor(eq("brl one"), any(Command.class));
    verify(view, never()).deleteAnchor(eq("brl two"), any(Command.class));
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) HashMap(java.util.HashMap) Command(com.google.gwt.user.client.Command) List(java.util.List) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 28 with BRLConditionColumn

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

the class ConditionColumnPluginTest method testGetPatternsWithBRLCondition.

@Test
public void testGetPatternsWithBRLCondition() throws Exception {
    final Pattern52 pattern = new Pattern52() {

        {
            setFactType("FactType");
            setBoundName("$fact");
        }
    };
    final BRLConditionColumn brlColumn = new BRLConditionColumn();
    final FactPattern fp = new FactPattern("AnotherFact") {

        {
            setBoundName("$another");
        }
    };
    brlColumn.setDefinition(Collections.singletonList(fp));
    doReturn(Arrays.asList(pattern, brlColumn)).when(model).getConditions();
    doReturn(pattern).when(model).getConditionPattern(eq("$fact"));
    doReturn(new FactPatternPattern52Adaptor(fp)).when(model).getConditionPattern(eq("$another"));
    final Set<PatternWrapper> patterns = plugin.getPatterns();
    assertEquals(1, patterns.size());
    assertTrue(patterns.contains(new PatternWrapper("FactType", "$fact", false)));
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) FactPatternPattern52Adaptor(org.drools.workbench.models.guided.dtable.shared.model.adaptors.FactPatternPattern52Adaptor) Test(org.junit.Test)

Example 29 with BRLConditionColumn

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

the class DecisionTableColumnViewUtilsTest method testColumnManagementGroupTitleBrlCondition.

@Test
public void testColumnManagementGroupTitleBrlCondition() throws Exception {
    final BRLConditionColumn column = mock(BRLConditionColumn.class);
    assertEquals(GuidedDecisionTableConstants.INSTANCE.BrlConditions(), DecisionTableColumnViewUtils.getColumnManagementGroupTitle(column));
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) Test(org.junit.Test)

Example 30 with BRLConditionColumn

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

the class BRLConditionColumnSynchronizerTest method checkBRLFragmentConditionCanBeDeletedWithNoAction.

@Test
public void checkBRLFragmentConditionCanBeDeletedWithNoAction() throws VetoException {
    final BRLConditionColumn column = new BRLConditionColumn();
    final BRLConditionVariableColumn columnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
    final BRLConditionVariableColumn columnV1 = new BRLConditionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
    column.getChildColumns().add(columnV0);
    column.getChildColumns().add(columnV1);
    column.setHeader("col1");
    columnV0.setHeader("col1v0");
    columnV1.setHeader("col1v1");
    modelSynchronizer.appendColumn(column);
    try {
        modelSynchronizer.deleteColumn(column);
    } catch (VetoException veto) {
        fail("Deletion should have been permitted.");
    }
    assertEquals(2, model.getExpandedColumns().size());
    assertTrue(model.getExpandedColumns().get(0) instanceof RowNumberCol52);
    assertTrue(model.getExpandedColumns().get(1) instanceof DescriptionCol52);
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Aggregations

BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)73 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)53 Test (org.junit.Test)49 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)30 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)26 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)26 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)24 ArrayList (java.util.ArrayList)22 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)22 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)22 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)21 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)17 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)16 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)15 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)14 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)14 IAction (org.drools.workbench.models.datamodel.rule.IAction)11 IOException (java.io.IOException)10 InputStream (java.io.InputStream)10 ExcelParser (org.drools.decisiontable.parser.xls.ExcelParser)10