Search in sources :

Example 1 with RuleAnnotationClauseColumn

use of org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.RuleAnnotationClauseColumn in project kie-wb-common by kiegroup.

the class AddRuleAnnotationClauseCommandTest method testNewCanvasCommandUndo.

@Test
public void testNewCanvasCommandUndo() {
    final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class);
    final Command<AbstractCanvasHandler, CanvasViolation> canvasCommand = command.newCanvasCommand(canvasHandler);
    final RuleAnnotationClauseColumn column = mock(RuleAnnotationClauseColumn.class);
    final Optional<RuleAnnotationClauseColumn> uiModelColumn = Optional.of(column);
    doReturn(uiModelColumn).when(command).getUiModelColumn();
    final CommandResult<CanvasViolation> result = canvasCommand.undo(canvasHandler);
    verify(command).updateParentInformation();
    verify(undoCanvasOperation).execute();
    verify(uiModel).deleteColumn(column);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, result);
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) RuleAnnotationClauseColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.RuleAnnotationClauseColumn) Test(org.junit.Test)

Example 2 with RuleAnnotationClauseColumn

use of org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.RuleAnnotationClauseColumn in project kie-wb-common by kiegroup.

the class AddRuleAnnotationClauseCommandTest method testNewCanvasCommandExecute.

@Test
public void testNewCanvasCommandExecute() {
    final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class);
    final Command<AbstractCanvasHandler, CanvasViolation> canvasCommand = command.newCanvasCommand(canvasHandler);
    final RuleAnnotationClauseColumn column = mock(RuleAnnotationClauseColumn.class);
    final List<DecisionRule> rules = mock(List.class);
    when(rules.size()).thenReturn(3);
    when(decisionTable.getRule()).thenReturn(rules);
    when(uiModelColumnSupplier.get()).thenReturn(column);
    final CommandResult<CanvasViolation> result = canvasCommand.execute(canvasHandler);
    verify(uiModelMapper).fromDMNModel(0, uiColumnIndex);
    verify(uiModelMapper).fromDMNModel(1, uiColumnIndex);
    verify(uiModelMapper).fromDMNModel(2, uiColumnIndex);
    verify(command).updateParentInformation();
    verify(executeCanvasOperation).execute();
    verify(uiModelColumnSupplier).get();
    verify(uiModel).insertColumn(uiColumnIndex, column);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, result);
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) RuleAnnotationClauseColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.RuleAnnotationClauseColumn) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Test(org.junit.Test)

Example 3 with RuleAnnotationClauseColumn

use of org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.RuleAnnotationClauseColumn in project kie-wb-common by kiegroup.

the class MoveColumnsCommandTest method testMoveSingleAnnotationColumnWithDuplicatedTitle.

@Test
public void testMoveSingleAnnotationColumnWithDuplicatedTitle() {
    final DecisionTable decisionTable = new DecisionTable();
    final DMNGridData model = new DMNGridData();
    final RuleAnnotationClause clauseOne = new RuleAnnotationClause();
    final RuleAnnotationClause clauseTwo = new RuleAnnotationClause();
    final RuleAnnotationClause clauseThree = new RuleAnnotationClause();
    decisionTable.getAnnotations().add(clauseOne);
    decisionTable.getAnnotations().add(clauseTwo);
    decisionTable.getAnnotations().add(clauseThree);
    decisionTable.getRule().add(new DecisionRule() {

        {
            getAnnotationEntry().add(new RuleAnnotationClauseText());
            getAnnotationEntry().add(new RuleAnnotationClauseText());
            getAnnotationEntry().add(new RuleAnnotationClauseText());
        }
    });
    final RuleAnnotationClauseColumn columnOne = mock(RuleAnnotationClauseColumn.class);
    final RuleAnnotationClauseColumn columnTwo = mock(RuleAnnotationClauseColumn.class);
    final RuleAnnotationClauseColumn columnThree = mock(RuleAnnotationClauseColumn.class);
    model.appendColumn(uiRowNumberColumn);
    model.appendColumn(columnOne);
    model.appendColumn(columnTwo);
    model.appendColumn(columnThree);
    when(columnOne.getIndex()).thenReturn(1);
    when(columnOne.getIndex()).thenReturn(2);
    when(columnOne.getIndex()).thenReturn(3);
    command = new MoveColumnsCommand(decisionTable, model, 2, Arrays.asList(columnOne), canvasOperation);
    graphCommand = command.newGraphCommand(canvasHandler);
    canvasCommand = command.newCanvasCommand(canvasHandler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
    assertEquals(CanvasCommandResultBuilder.SUCCESS, canvasCommand.execute(canvasHandler));
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) RuleAnnotationClauseText(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText) RuleAnnotationClause(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause) RuleAnnotationClauseColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.RuleAnnotationClauseColumn) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 RuleAnnotationClauseColumn (org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.RuleAnnotationClauseColumn)3 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)2 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)2 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)2 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)1 RuleAnnotationClause (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause)1 RuleAnnotationClauseText (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText)1 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)1