use of org.kie.workbench.common.dmn.api.definition.model.DecisionRule in project kie-wb-common by kiegroup.
the class MoveColumnsCommandTest method setUp.
@Before
public void setUp() {
this.dtable = new DecisionTable();
this.uiModel = new DMNGridData();
dtable.getInput().add(inputClauseOne);
dtable.getInput().add(inputClauseTwo);
dtable.getInput().add(inputClauseThree);
dtable.getOutput().add(outputClauseOne);
dtable.getOutput().add(outputClauseTwo);
dtable.getOutput().add(outputClauseThree);
dtable.getAnnotations().add(annotationClauseOne);
dtable.getAnnotations().add(annotationClauseTwo);
dtable.getAnnotations().add(annotationClauseThree);
dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests());
getInputEntry().add(new UnaryTests());
getInputEntry().add(new UnaryTests());
getOutputEntry().add(new LiteralExpression());
getOutputEntry().add(new LiteralExpression());
getOutputEntry().add(new LiteralExpression());
getAnnotationEntry().add(new RuleAnnotationClauseText());
getAnnotationEntry().add(new RuleAnnotationClauseText());
getAnnotationEntry().add(new RuleAnnotationClauseText());
}
});
uiModel.appendColumn(uiRowNumberColumn);
uiModel.appendColumn(uiInputClauseColumnOne);
uiModel.appendColumn(uiInputClauseColumnTwo);
uiModel.appendColumn(uiInputClauseColumnThree);
uiModel.appendColumn(uiOutputClauseColumnOne);
uiModel.appendColumn(uiOutputClauseColumnTwo);
uiModel.appendColumn(uiOutputClauseColumnThree);
uiModel.appendColumn(uiRuleAnnotationClauseColumnOne);
uiModel.appendColumn(uiRuleAnnotationClauseColumnTwo);
uiModel.appendColumn(uiRuleAnnotationClauseColumnThree);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiInputClauseColumnOne).getIndex();
doReturn(2).when(uiInputClauseColumnTwo).getIndex();
doReturn(3).when(uiInputClauseColumnThree).getIndex();
doReturn(4).when(uiOutputClauseColumnOne).getIndex();
doReturn(5).when(uiOutputClauseColumnTwo).getIndex();
doReturn(6).when(uiOutputClauseColumnThree).getIndex();
doReturn(7).when(uiRuleAnnotationClauseColumnOne).getIndex();
doReturn(8).when(uiRuleAnnotationClauseColumnTwo).getIndex();
doReturn(9).when(uiRuleAnnotationClauseColumnThree).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionRule in project kie-wb-common by kiegroup.
the class DeleteRuleAnnotationClauseCommandTest method testNewCanvasCommandUndo.
@Test
public void testNewCanvasCommandUndo() {
final DeleteRuleAnnotationClauseCommand command = mock(DeleteRuleAnnotationClauseCommand.class);
final AbstractCanvasHandler handler = mock(AbstractCanvasHandler.class);
final GridData uiModel = mock(GridData.class);
final GridColumn oldUiModelColumn = mock(GridColumn.class);
final int uiColumnIndex = 3;
final DecisionRule rule1 = mock(DecisionRule.class);
final DecisionRule rule2 = mock(DecisionRule.class);
final List<DecisionRule> rules = Arrays.asList(rule1, rule2);
final org.uberfire.mvp.Command undoCanvasOperation = mock(org.uberfire.mvp.Command.class);
final DecisionTableUIModelMapper uiModelMapper = mock(DecisionTableUIModelMapper.class);
doCallRealMethod().when(command).newCanvasCommand(handler);
when(command.getUiModel()).thenReturn(uiModel);
when(command.getUiColumnIndex()).thenReturn(uiColumnIndex);
when(command.getOldUiModelColumn()).thenReturn(oldUiModelColumn);
when(command.getDecisionTable()).thenReturn(decisionTable);
when(decisionTable.getRule()).thenReturn(rules);
when(command.getUiModelMapper()).thenReturn(uiModelMapper);
when(command.getUndoCanvasOperation()).thenReturn(undoCanvasOperation);
final Command<AbstractCanvasHandler, CanvasViolation> canvasCommand = command.newCanvasCommand(handler);
final CommandResult<CanvasViolation> result = canvasCommand.undo(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, result);
verify(uiModelMapper).fromDMNModel(0, uiColumnIndex);
verify(uiModelMapper).fromDMNModel(1, uiColumnIndex);
verify(command).updateParentInformation();
verify(undoCanvasOperation).execute();
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionRule in project kie-wb-common by kiegroup.
the class AddInputClauseCommandTest method testGraphCommandUndoNoInputClauseColumns.
@Test(expected = IndexOutOfBoundsException.class)
public void testGraphCommandUndoNoInputClauseColumns() {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
dtable.getRule().add(new DecisionRule());
assertEquals(0, dtable.getInput().size());
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.undo(graphCommandExecutionContext));
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionRule in project kie-wb-common by kiegroup.
the class AddRuleAnnotationClauseCommandTest method testNewGraphCommandUndo.
@Test
public void testNewGraphCommandUndo() {
final AbstractCanvasHandler context = mock(AbstractCanvasHandler.class);
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(context);
final GraphCommandExecutionContext executionContext = mock(GraphCommandExecutionContext.class);
final int ruleAnnotationIndex = 3;
final DecisionRule rule1 = mock(DecisionRule.class);
final DecisionRule rule2 = mock(DecisionRule.class);
final List rule1AnnotationEntries = mock(List.class);
final List rule2AnnotationEntries = mock(List.class);
final List<DecisionRule> rules = Arrays.asList(rule1, rule2);
when(rule1.getAnnotationEntry()).thenReturn(rule1AnnotationEntries);
when(rule2.getAnnotationEntry()).thenReturn(rule2AnnotationEntries);
when(decisionTable.getRule()).thenReturn(rules);
when(annotations.indexOf(ruleAnnotationClause)).thenReturn(ruleAnnotationIndex);
final CommandResult<RuleViolation> undoResult = graphCommand.undo(executionContext);
verify(componentsWidths).remove(uiColumnIndex);
verify(rule1AnnotationEntries).remove(ruleAnnotationIndex);
verify(rule2AnnotationEntries).remove(ruleAnnotationIndex);
verify(annotations).remove(ruleAnnotationClause);
assertEquals(GraphCommandResultBuilder.SUCCESS, undoResult);
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionRule in project kie-wb-common by kiegroup.
the class DeleteInputClauseCommandTest method testGraphCommandExecuteRemoveMiddle.
@Test
public void testGraphCommandExecuteRemoveMiddle() {
final InputClause firstInput = mock(InputClause.class);
final InputClause lastInput = mock(InputClause.class);
dtable.getInput().add(0, firstInput);
dtable.getInput().add(lastInput);
final UnaryTests inputOneValue = mock(UnaryTests.class);
final UnaryTests inputTwoValue = mock(UnaryTests.class);
final UnaryTests inputThreeValue = mock(UnaryTests.class);
final DecisionRule rule = new DecisionRule();
rule.getInputEntry().add(inputOneValue);
rule.getInputEntry().add(inputTwoValue);
rule.getInputEntry().add(inputThreeValue);
dtable.getRule().add(rule);
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + 1);
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(2, dtable.getInput().size());
assertEquals(firstInput, dtable.getInput().get(0));
assertEquals(lastInput, dtable.getInput().get(1));
assertEquals(2, dtable.getRule().get(0).getInputEntry().size());
assertEquals(inputOneValue, dtable.getRule().get(0).getInputEntry().get(0));
assertEquals(inputThreeValue, dtable.getRule().get(0).getInputEntry().get(1));
}
Aggregations