Search in sources :

Example 21 with GraphCommandExecutionContext

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

the class AddRelationRowCommandTest method testGraphCommandExecuteInsertMiddleWithColumns.

@Test
public void testGraphCommandExecuteInsertMiddleWithColumns() {
    relation.getRow().add(new List());
    relation.getRow().add(new List());
    relation.getColumn().add(new InformationItem());
    makeCommand(1);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(3, relation.getRow().size());
    assertEquals(row, relation.getRow().get(1));
    assertEquals(1, relation.getColumn().size());
    assertEquals(1, relation.getRow().get(1).getExpression().size());
    assertTrue(relation.getRow().get(1).getExpression().get(0) instanceof LiteralExpression);
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) 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 22 with GraphCommandExecutionContext

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

the class DeleteRelationColumnCommandTest method testGraphCommandUndoWithRows.

@Test
public void testGraphCommandUndoWithRows() {
    relation.getRow().add(new List());
    final LiteralExpression literalExpression = new LiteralExpression();
    literalExpression.setText(VALUE);
    relation.getRow().get(0).getExpression().add(literalExpression);
    makeCommand();
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    // Delete column and then undo
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
    assertEquals(1, relation.getColumn().size());
    assertEquals(1, relation.getRow().size());
    assertEquals(1, relation.getRow().get(0).getExpression().size());
    assertEquals(VALUE, ((LiteralExpression) relation.getRow().get(0).getExpression().get(0)).getText());
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 23 with GraphCommandExecutionContext

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

the class DeleteRelationColumnCommandTest method testGraphCommandExecuteDeleteMiddleWithRows.

@Test
public void testGraphCommandExecuteDeleteMiddleWithRows() {
    uiModel.appendColumn(mock(RelationColumn.class));
    uiModel.appendColumn(mock(RelationColumn.class));
    relation.getColumn().add(new InformationItem());
    relation.getColumn().add(new InformationItem());
    relation.getRow().add(new List());
    final LiteralExpression firstExpression = new LiteralExpression();
    final LiteralExpression lastExpression = new LiteralExpression();
    relation.getRow().get(0).getExpression().add(firstExpression);
    relation.getRow().get(0).getExpression().add(new LiteralExpression());
    relation.getRow().get(0).getExpression().add(lastExpression);
    makeCommand(2);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(2, relation.getColumn().size());
    assertEquals(1, relation.getRow().size());
    assertEquals(2, relation.getRow().get(0).getExpression().size());
    assertEquals(firstExpression, relation.getRow().get(0).getExpression().get(0));
    assertEquals(lastExpression, relation.getRow().get(0).getExpression().get(1));
}
Also used : RelationColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationColumn) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 24 with GraphCommandExecutionContext

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

the class DeleteRelationRowCommandTest method testGraphCommandExecuteWithColumns.

@Test
public void testGraphCommandExecuteWithColumns() {
    relation.getColumn().add(new InformationItem());
    relation.getRow().get(0).getExpression().add(new LiteralExpression());
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(0, relation.getRow().size());
    assertEquals(1, relation.getColumn().size());
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) 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 25 with GraphCommandExecutionContext

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

the class DeleteRelationRowCommandTest method testGraphCommandUndoWithColumns.

@Test
public void testGraphCommandUndoWithColumns() {
    relation.getColumn().add(new InformationItem());
    final LiteralExpression literalExpression = new LiteralExpression();
    literalExpression.setText(VALUE);
    relation.getRow().get(0).getExpression().add(literalExpression);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    // Delete row and then undo
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
    assertEquals(1, relation.getColumn().size());
    assertEquals(1, relation.getRow().size());
    assertEquals(1, relation.getRow().get(0).getExpression().size());
    assertEquals(VALUE, ((LiteralExpression) relation.getRow().get(0).getExpression().get(0)).getText());
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) 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)

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