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