Search in sources :

Example 66 with GraphCommandExecutionContext

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

the class AddDecisionRuleCommandTest method testGraphCommandExecuteInsertBelow.

@Test
public void testGraphCommandExecuteInsertBelow() {
    // The default behaviour of tests in this class is to "insert above"
    final DecisionRule existingRule = new DecisionRule();
    dtable.getRule().add(existingRule);
    makeCommand(1);
    final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
    graphCommand.execute(graphCommandExecutionContext);
    assertEquals(2, dtable.getRule().size());
    assertEquals(existingRule, dtable.getRule().get(0));
    assertEquals(rule, dtable.getRule().get(1));
}
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.model.DecisionRule) Test(org.junit.Test)

Example 67 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.model.InformationItem) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 68 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.model.InformationItem) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 69 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.model.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 70 with GraphCommandExecutionContext

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

the class SetParametersCommandTest method testGraphCommandUndoWithParameters.

@Test
public void testGraphCommandUndoWithParameters() {
    final InformationItem otherParameter = new InformationItem();
    function.getFormalParameter().add(otherParameter);
    setupCommand();
    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(otherParameter);
}
Also used : GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Aggregations

GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)85 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)84 Test (org.junit.Test)66 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)25 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)20 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)19 AbstractGraphCommand (org.kie.workbench.common.stunner.core.graph.command.impl.AbstractGraphCommand)14 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)11 List (org.kie.workbench.common.dmn.api.definition.model.List)10 InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)8 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)8 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)8 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)8 Binding (org.kie.workbench.common.dmn.api.definition.model.Binding)7 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)7 List (java.util.List)6 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)6 RuleAnnotationClauseText (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText)5 Command (org.kie.workbench.common.stunner.core.command.Command)5 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)4