use of org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method testCanvasCommandAddOutputClauseToRuleWithoutInputsThenUndo.
@Test
public void testCanvasCommandAddOutputClauseToRuleWithoutInputsThenUndo() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
final String ruleOneOutputValue = "one";
final String ruleTwoOutputValue = "two";
dtable.getRule().add(new DecisionRule());
dtable.getRule().add(new DecisionRule());
uiModel.appendRow(new BaseGridRow());
uiModel.appendRow(new BaseGridRow());
// Graph command populates OutputEntries so overwrite with test values
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
graphCommand.execute(graphCommandExecutionContext);
dtable.getRule().get(0).getOutputEntry().get(0).setText(ruleOneOutputValue);
dtable.getRule().get(1).getOutputEntry().get(0).setText(ruleTwoOutputValue);
final Command<AbstractCanvasHandler, CanvasViolation> canvasAddOutputClauseCommand = command.newCanvasCommand(canvasHandler);
canvasAddOutputClauseCommand.execute(canvasHandler);
// first rule
assertEquals(ruleOneOutputValue, uiModel.getRow(0).getCells().get(1).getValue().getValue());
// second rule
assertEquals(ruleTwoOutputValue, uiModel.getRow(1).getCells().get(1).getValue().getValue());
assertEquals(2, uiModel.getColumnCount());
assertEquals(CanvasCommandResultBuilder.SUCCESS, canvasAddOutputClauseCommand.undo(canvasHandler));
assertEquals(1, uiModel.getColumnCount());
// one time in execute(), one time in undo()
verify(canvasOperation, times(2)).execute();
verify(command, times(2)).updateParentInformation();
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method testGraphCommandUndoNoOutputClauseColumns.
@Test(expected = ArrayIndexOutOfBoundsException.class)
public void testGraphCommandUndoNoOutputClauseColumns() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
dtable.getRule().add(new DecisionRule());
assertEquals(0, dtable.getOutput().size());
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.undo(graphCommandExecutionContext));
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule in project kie-wb-common by kiegroup.
the class MoveRowsCommandTest method appendRow.
private void appendRow(final int rowIndex, final String rowIdentifier) {
final String inValue = "in " + rowIdentifier;
final String outValue = "out " + rowIdentifier;
dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
setText(inValue);
}
});
getOutputEntry().add(new LiteralExpression() {
{
setText(outValue);
}
});
}
});
final DMNGridRow uiRow = new DMNGridRow();
uiModel.appendRow(uiRow);
uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>(inValue));
uiModel.setCellValue(rowIndex, 2, new BaseGridCellValue<>(outValue));
rowsUnderTest.add(uiRow);
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule in project kie-wb-common by kiegroup.
the class CommandUtilsTest method setUp.
@Before
public void setUp() throws Exception {
decisionRuleOne = new DecisionRule();
decisionRuleTwo = new DecisionRule();
decisionRuleThree = new DecisionRule();
decisionRuleOne.setId(new Id("1"));
decisionRuleTwo.setId(new Id("2"));
decisionRuleThree.setId(new Id("3"));
allRows.clear();
allRows.add(decisionRuleOne);
allRows.add(decisionRuleTwo);
allRows.add(decisionRuleThree);
rowsToMove.clear();
uiModel = new DMNGridData();
gridWidget = new BaseGridWidget(uiModel, selectionManager, pinnedModeManager, renderer);
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule in project kie-wb-common by kiegroup.
the class DecisionRulePropertyConverter method wbFromDMN.
public static DecisionRule wbFromDMN(final org.kie.dmn.model.v1_1.DecisionRule dmn) {
Id id = new Id(dmn.getId());
Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
DecisionRule result = new DecisionRule();
result.setId(id);
result.setDescription(description);
for (org.kie.dmn.model.v1_1.UnaryTests ie : dmn.getInputEntry()) {
result.getInputEntry().add(UnaryTestsPropertyConverter.wbFromDMN(ie));
}
for (org.kie.dmn.model.v1_1.LiteralExpression oe : dmn.getOutputEntry()) {
result.getOutputEntry().add(LiteralExpressionPropertyConverter.wbFromDMN(oe));
}
return result;
}
Aggregations