Search in sources :

Example 16 with GraphCommandExecutionContext

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

the class AddRelationColumnCommandTest method testGraphCommandExecuteWithRows.

@Test
public void testGraphCommandExecuteWithRows() {
    relation.getRow().add(new List());
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(1, relation.getColumn().size());
    assertEquals(informationItem, relation.getColumn().get(0));
    assertEquals(1, relation.getRow().size());
    assertEquals(1, relation.getRow().get(0).getExpression().size());
    assertTrue(relation.getRow().get(0).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) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 17 with GraphCommandExecutionContext

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

the class AddRelationColumnCommandTest method testGraphCommandUndoWithRows.

@Test
public void testGraphCommandUndoWithRows() {
    relation.getRow().add(new List());
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    // Add column and then undo
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
    assertEquals(0, relation.getColumn().size());
    assertEquals(1, relation.getRow().size());
    assertEquals(0, relation.getRow().get(0).getExpression().size());
}
Also used : 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 18 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_InsertBefore.

@Test
public void testGraphCommandExecuteWithExistingColumn_InsertBefore() {
    final InformationItem existingInformationItem = new InformationItem();
    relation.getColumn().add(existingInformationItem);
    final List row = new List();
    relation.getRow().add(row);
    final LiteralExpression existingLiteralExpression = new LiteralExpression();
    row.getExpression().add(0, existingLiteralExpression);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(2, relation.getColumn().size());
    assertEquals(informationItem, relation.getColumn().get(0));
    assertEquals(existingInformationItem, relation.getColumn().get(1));
    assertEquals(1, relation.getRow().size());
    assertEquals(2, relation.getRow().get(0).getExpression().size());
    assertTrue(relation.getRow().get(0).getExpression().get(0) instanceof LiteralExpression);
    assertEquals(existingLiteralExpression, relation.getRow().get(0).getExpression().get(1));
}
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) 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 19 with GraphCommandExecutionContext

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

the class AddRelationRowCommandTest method testGraphCommandExecuteWithColumns.

@Test
public void testGraphCommandExecuteWithColumns() {
    relation.getColumn().add(new InformationItem());
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(1, relation.getRow().size());
    assertEquals(row, relation.getRow().get(0));
    assertEquals(1, relation.getColumn().size());
    assertEquals(1, relation.getRow().get(0).getExpression().size());
    assertTrue(relation.getRow().get(0).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) 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 20 with GraphCommandExecutionContext

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

the class AddRelationRowCommandTest method testGraphCommandUndoWithColumns.

@Test
public void testGraphCommandUndoWithColumns() {
    relation.getColumn().add(new InformationItem());
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    // Add column and then undo
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
    assertEquals(1, relation.getColumn().size());
    assertEquals(0, relation.getRow().size());
}
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)

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