Search in sources :

Example 71 with GraphCommandExecutionContext

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

the class AddParameterBindingCommandTest method testGraphCommandUndoFromStart.

@Test
public void testGraphCommandUndoFromStart() {
    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);
    // Add parameter and then undo
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
    assertBindingDefinitions(firstBinding, secondBinding);
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 72 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);
    assertEquals(invocation, binding.getParent());
    assertEquals(binding, binding.getParameter().getParent());
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 73 with GraphCommandExecutionContext

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

the class DeleteParameterBindingCommandTest method testGraphCommandExecuteRemoveFromMiddle.

@Test
public void testGraphCommandExecuteRemoveFromMiddle() {
    final Binding firstBinding = new Binding();
    final Binding lastBinding = new Binding();
    invocation.getBinding().add(0, firstBinding);
    invocation.getBinding().add(lastBinding);
    uiModel.appendRow(new BaseGridRow());
    uiModel.appendRow(new BaseGridRow());
    makeCommand(1);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    Assertions.assertThat(invocation.getBinding()).containsExactly(firstBinding, lastBinding);
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 74 with GraphCommandExecutionContext

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

the class DeleteListRowCommandTest method testGraphCommandExecuteRemoveMiddle.

@Test
public void testGraphCommandExecuteRemoveMiddle() {
    uiModel.appendRow(new BaseGridRow());
    uiModel.appendRow(new BaseGridRow());
    final HasExpression firstRow = HasExpression.wrap(list, new LiteralExpression());
    final HasExpression lastRow = HasExpression.wrap(list, new LiteralExpression());
    list.getExpression().add(0, firstRow);
    list.getExpression().add(lastRow);
    makeCommand(1);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(2, list.getExpression().size());
    assertEquals(firstRow, list.getExpression().get(0));
    assertEquals(lastRow, list.getExpression().get(1));
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 75 with GraphCommandExecutionContext

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

the class AddRelationColumnCommandTest method testGraphCommandExecuteWithExistingColumn_InsertMiddle.

@Test
public void testGraphCommandExecuteWithExistingColumn_InsertMiddle() {
    makeCommand(2);
    final InformationItem existingInformationItemFirst = new InformationItem();
    relation.getColumn().add(existingInformationItemFirst);
    final InformationItem existingInformationItemLast = new InformationItem();
    relation.getColumn().add(existingInformationItemLast);
    final List row = new List();
    relation.getRow().add(row);
    final LiteralExpression existingLiteralExpressionFirst = new LiteralExpression();
    final LiteralExpression existingLiteralExpressionLast = new LiteralExpression();
    row.getExpression().add(HasExpression.wrap(row, existingLiteralExpressionFirst));
    row.getExpression().add(HasExpression.wrap(row, existingLiteralExpressionLast));
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(3, relation.getColumn().size());
    assertEquals(existingInformationItemFirst, relation.getColumn().get(0));
    assertEquals(informationItem, relation.getColumn().get(1));
    assertEquals(RelationDefaultValueUtilities.PREFIX + "1", informationItem.getName().getValue());
    assertEquals(existingInformationItemLast, relation.getColumn().get(2));
    assertEquals(1, relation.getRow().size());
    assertEquals(3, relation.getRow().get(0).getExpression().size());
    assertEquals(existingLiteralExpressionFirst, relation.getRow().get(0).getExpression().get(0).getExpression());
    assertTrue(relation.getRow().get(0).getExpression().get(1).getExpression() instanceof LiteralExpression);
    assertEquals(existingLiteralExpressionLast, relation.getRow().get(0).getExpression().get(2).getExpression());
    assertEquals(relation, informationItem.getParent());
    assertEquals(relation.getRow().get(0), relation.getRow().get(0).getExpression().get(1).getExpression().getParent());
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) List(org.kie.workbench.common.dmn.api.definition.model.List) 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