use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class ActionWorkItemSetFieldPluginTest method mockPatterns.
private void mockPatterns() {
final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
final List<CompositeColumn<?>> patterns = Collections.singletonList(fakePattern());
final List<ActionCol52> actions = Arrays.asList(fakeActionCol(), fakeActionCol());
when(model.getConditions()).thenReturn(patterns);
when(model.getActionCols()).thenReturn(actions);
when(presenter.getModel()).thenReturn(model);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class BRLActionColumnPluginTest method testGenerateColumnWhenColumnIsNew.
@Test
public void testGenerateColumnWhenColumnIsNew() throws Exception {
final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
final ArrayList<ActionCol52> actionCol52s = new ArrayList<>();
when(model.getActionCols()).thenReturn(actionCol52s);
when(presenter.getModel()).thenReturn(model);
when(editingCol.getHeader()).thenReturn("header");
when(plugin.isNewColumn()).thenReturn(true);
final Boolean success = plugin.generateColumn();
assertTrue(success);
verify(plugin).getDefinedVariables(any());
verify(editingCol).setDefinition(any());
verify(presenter).appendColumn(editingCol);
verify(translationService, never()).format(any());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method checkConditionCannotBeUpdatedWhenBindingIsUsedInAction.
@Test
public void checkConditionCannotBeUpdatedWhenBindingIsUsedInAction() throws VetoException {
final Pattern52 pattern = boundApplicantPattern("$a");
final ConditionCol52 condition = ageEqualsCondition();
final ActionCol52 action = actionUpdatePattern("$a");
modelSynchronizer.appendColumn(pattern, condition);
modelSynchronizer.appendColumn(action);
try {
final Pattern52 editedPattern = boundApplicantPattern("$a2");
final ConditionCol52 editedCondition = nameEqualsCondition();
modelSynchronizer.updateColumn(pattern, condition, editedPattern, editedCondition);
fail("Update of the column should have been vetoed.");
} catch (VetoUpdatePatternInUseException veto) {
// This is expected
} catch (VetoException veto) {
fail("VetoUpdatePatternInUseException was expected.");
}
assertEquals(4, model.getExpandedColumns().size());
assertTrue(model.getExpandedColumns().get(0) instanceof RowNumberCol52);
assertTrue(model.getExpandedColumns().get(1) instanceof DescriptionCol52);
assertEquals(condition, model.getExpandedColumns().get(2));
assertEquals(action, model.getExpandedColumns().get(3));
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method checkConditionCannotBeDeletedWithSingleChildColumnWithAction.
@Test
public void checkConditionCannotBeDeletedWithSingleChildColumnWithAction() throws VetoException {
final Pattern52 pattern = boundApplicantPattern("$a");
final ConditionCol52 condition = ageEqualsCondition();
final ActionCol52 action = actionUpdatePattern("$a");
modelSynchronizer.appendColumn(pattern, condition);
modelSynchronizer.appendColumn(action);
try {
modelSynchronizer.deleteColumn(condition);
fail("Deletion of the column should have been vetoed.");
} catch (VetoDeletePatternInUseException veto) {
// This is expected
} catch (VetoException veto) {
fail("VetoDeletePatternInUseException was expected.");
}
assertEquals(4, model.getExpandedColumns().size());
assertTrue(model.getExpandedColumns().get(0) instanceof RowNumberCol52);
assertTrue(model.getExpandedColumns().get(1) instanceof DescriptionCol52);
assertEquals(condition, model.getExpandedColumns().get(2));
assertEquals(action, model.getExpandedColumns().get(3));
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class CellBuilder method build.
public void build() throws BuildException {
if (baseColumn instanceof ActionCol52) {
final Action action = builderFactory.getActionBuilder().with(rule).with(row).with(columnIndex).with((ActionCol52) baseColumn).build();
rule.getActions().add(action);
} else if (baseColumn instanceof ConditionCol52) {
if (baseColumn instanceof BRLConditionVariableColumn) {
final Condition condition = builderFactory.getBRLConditionBuilder().with((BRLConditionVariableColumn) baseColumn).with(getRealCellValue((BRLConditionVariableColumn) baseColumn, row.get(columnIndex))).with(columnIndex).build();
rule.getConditions().add(condition);
} else {
final Condition condition = builderFactory.getFieldConditionsBuilder().with(resolvePattern(rule)).with((ConditionCol52) baseColumn).with(getRealCellValue((ConditionCol52) baseColumn, row.get(columnIndex))).with(columnIndex).build();
rule.getConditions().add(condition);
}
}
}
Aggregations