Search in sources :

Example 51 with GraphCommandExecutionContext

use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext 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));
}
Also used : GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule) Test(org.junit.Test)

Example 52 with GraphCommandExecutionContext

use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.

the class RemoveParameterCommandTest method testGraphCommandUndoWithParameters.

@Test
public void testGraphCommandUndoWithParameters() {
    final InformationItem otherParameter = new InformationItem();
    function.getFormalParameter().add(otherParameter);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    // Add parameter and then undo
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
    assertFormalParameters(parameter, otherParameter);
}
Also used : GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 53 with GraphCommandExecutionContext

use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.

the class RemoveParameterCommandTest method testRemoveFromMiddleThenUndo.

@Test
public void testRemoveFromMiddleThenUndo() {
    final InformationItem firstParameter = new InformationItem();
    firstParameter.setName(new Name("first"));
    function.getFormalParameter().add(0, firstParameter);
    final InformationItem lastParameter = new InformationItem();
    lastParameter.setName(new Name("last"));
    function.getFormalParameter().add(lastParameter);
    // call to get proper old index of parameter
    this.command = new RemoveParameterCommand(function, parameter, canvasOperation);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    // Add parameter and then undo
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertFormalParameters(firstParameter, lastParameter);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
    assertFormalParameters(firstParameter, parameter, lastParameter);
}
Also used : GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 54 with GraphCommandExecutionContext

use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.

the class RemoveParameterCommandTest method testGraphCommandExecuteWithParameters.

@Test
public void testGraphCommandExecuteWithParameters() {
    final InformationItem otherParameter = new InformationItem();
    function.getFormalParameter().add(otherParameter);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertFormalParameters(otherParameter);
}
Also used : GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 55 with GraphCommandExecutionContext

use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext in project kie-wb-common by kiegroup.

the class AddParameterBindingCommandTest method testGraphCommandExecuteInsertToFirstPlace.

@Test
public void testGraphCommandExecuteInsertToFirstPlace() {
    final Binding firstBinding = new Binding();
    final Binding secondBinding = new Binding();
    invocation.getBinding().add(firstBinding);
    invocation.getBinding().add(secondBinding);
    makeCommand(0);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertBindingDefinitions(binding, firstBinding, secondBinding);
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.v1_1.Binding) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Aggregations

GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)60 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)60 Test (org.junit.Test)47 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)18 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)16 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)12 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)10 AbstractGraphCommand (org.kie.workbench.common.stunner.core.graph.command.impl.AbstractGraphCommand)10 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)8 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)8 Binding (org.kie.workbench.common.dmn.api.definition.v1_1.Binding)7 InputClause (org.kie.workbench.common.dmn.api.definition.v1_1.InputClause)6 OutputClause (org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause)5 UnaryTests (org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)5 ContextEntry (org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry)4 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)4 Command (org.kie.workbench.common.stunner.core.command.Command)4 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)3 CanvasCommandResultBuilder (org.kie.workbench.common.stunner.core.client.command.CanvasCommandResultBuilder)3 CommandResult (org.kie.workbench.common.stunner.core.command.CommandResult)3