Search in sources :

Example 41 with RuleViolation

use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.

the class AddInputClauseCommandTest method testGraphCommandUndoNoInputClauseColumns.

@Test(expected = ArrayIndexOutOfBoundsException.class)
public void testGraphCommandUndoNoInputClauseColumns() throws Exception {
    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));
}
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 42 with RuleViolation

use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.

the class AddOutputClauseCommandTest method testGraphCommandExecute.

@Test
public void testGraphCommandExecute() throws Exception {
    makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
    dtable.getRule().add(new DecisionRule());
    dtable.getRule().add(new DecisionRule());
    assertEquals(0, dtable.getOutput().size());
    final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
    // one new output column
    assertEquals(1, dtable.getOutput().size());
    // first rule
    assertEquals(1, dtable.getRule().get(0).getOutputEntry().size());
    assertEquals(AddOutputClauseCommand.OUTPUT_CLAUSE_DEFAULT_VALUE, dtable.getRule().get(0).getOutputEntry().get(0).getText());
    // second rule
    assertEquals(1, dtable.getRule().get(1).getOutputEntry().size());
    assertEquals(AddOutputClauseCommand.OUTPUT_CLAUSE_DEFAULT_VALUE, dtable.getRule().get(1).getOutputEntry().get(0).getText());
}
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 43 with RuleViolation

use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.

the class AddParameterCommandTest 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(1, 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 44 with RuleViolation

use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.

the class AddParameterCommandTest 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(2, otherParameter, parameter);
}
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 45 with RuleViolation

use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.

the class AddParameterBindingCommandTest method testGraphCommandExecuteWithParameters.

@Test
public void testGraphCommandExecuteWithParameters() {
    final Binding otherBinding = new Binding();
    invocation.getBinding().add(otherBinding);
    makeCommand();
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertBindingDefinitions(otherBinding, binding);
}
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

RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)122 Test (org.junit.Test)81 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)59 Node (org.kie.workbench.common.stunner.core.graph.Node)27 Edge (org.kie.workbench.common.stunner.core.graph.Edge)26 RuleViolations (org.kie.workbench.common.stunner.core.rule.RuleViolations)21 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)18 RuleEvaluationContext (org.kie.workbench.common.stunner.core.rule.RuleEvaluationContext)18 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)16 DefaultRuleViolations (org.kie.workbench.common.stunner.core.rule.violations.DefaultRuleViolations)16 RuleSet (org.kie.workbench.common.stunner.core.rule.RuleSet)15 ContainmentRuleViolation (org.kie.workbench.common.stunner.core.rule.violations.ContainmentRuleViolation)15 GraphCommandResultBuilder (org.kie.workbench.common.stunner.core.graph.command.GraphCommandResultBuilder)13 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)12 AbstractGraphCommand (org.kie.workbench.common.stunner.core.graph.command.impl.AbstractGraphCommand)11 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)10 Collection (java.util.Collection)8 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