Search in sources :

Example 36 with List

use of org.kie.workbench.common.dmn.api.definition.v1_1.List in project kie-wb-common by kiegroup.

the class AddRelationColumnCommandTest method testCanvasCommandUndoWithRows.

@Test
public void testCanvasCommandUndoWithRows() {
    relation.getRow().add(new List());
    uiModel.appendRow(new DMNGridRow());
    uiModelMapper.fromDMNModel(0, 0);
    // Add Graph column first as RelationUIModelMapper relies on the model being first updated
    command.newGraphCommand(handler).execute(gce);
    // Add column and then undo
    final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
    reset(command, canvasOperation);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.undo(handler));
    assertEquals(1, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
    assertEquals(1, uiModel.getRowCount());
    assertEquals(1, uiModel.getRows().get(0).getCells().size());
    assertEquals(1, uiModel.getCell(0, 0).getValue().getValue());
    verify(command).updateParentInformation();
    verify(canvasOperation).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) Test(org.junit.Test)

Example 37 with List

use of org.kie.workbench.common.dmn.api.definition.v1_1.List in project kie-wb-common by kiegroup.

the class AddRelationColumnCommandTest method testCanvasCommandExecuteWithRows.

@Test
public void testCanvasCommandExecuteWithRows() {
    relation.getRow().add(new List());
    uiModel.appendRow(new DMNGridRow());
    uiModelMapper.fromDMNModel(0, 0);
    // Add Graph column first as RelationUIModelMapper relies on the model being first updated
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
    assertEquals(2, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
    assertEquals(uiModelColumn, uiModel.getColumns().get(1));
    assertEquals(1, uiModel.getRowCount());
    assertEquals(2, uiModel.getRows().get(0).getCells().size());
    assertEquals(1, uiModel.getCell(0, 0).getValue().getValue());
    assertEquals("", uiModel.getCell(0, 1).getValue().getValue());
    verify(command).updateParentInformation();
    verify(canvasOperation).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) Test(org.junit.Test)

Example 38 with List

use of org.kie.workbench.common.dmn.api.definition.v1_1.List 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(existingLiteralExpressionFirst);
    row.getExpression().add(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(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));
    assertTrue(relation.getRow().get(0).getExpression().get(1) instanceof LiteralExpression);
    assertEquals(existingLiteralExpressionLast, relation.getRow().get(0).getExpression().get(2));
}
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 39 with List

use of org.kie.workbench.common.dmn.api.definition.v1_1.List in project kie-wb-common by kiegroup.

the class BaseMoveCommandsTest method addRelationRow.

protected void addRelationRow(final String identifier) {
    final List row = new List();
    for (int index = 0; index < relation.getColumn().size(); index++) {
        final String ii = makeIdentifier(identifier, index);
        row.getExpression().add(new LiteralExpression() {

            {
                setId(new Id(ii));
            }
        });
    }
    relation.getRow().add(row);
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) Id(org.kie.workbench.common.dmn.api.property.dmn.Id)

Example 40 with List

use of org.kie.workbench.common.dmn.api.definition.v1_1.List in project kie-wb-common by kiegroup.

the class DeleteRelationColumnCommandTest method testGraphCommandExecuteWithRows.

@Test
public void testGraphCommandExecuteWithRows() {
    relation.getRow().add(new List());
    relation.getRow().get(0).getExpression().add(new LiteralExpression());
    makeCommand();
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(0, relation.getColumn().size());
    assertEquals(1, relation.getRow().size());
    assertEquals(0, relation.getRow().get(0).getExpression().size());
}
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)

Aggregations

List (org.kie.workbench.common.dmn.api.definition.v1_1.List)26 Test (org.junit.Test)22 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)20 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)15 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)15 List (java.util.List)13 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)13 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)11 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)11 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)10 ArrayList (java.util.ArrayList)9 Optional (java.util.Optional)7 Relation (org.kie.workbench.common.dmn.api.definition.v1_1.Relation)7 Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)6 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)5 HasName (org.kie.workbench.common.dmn.api.definition.HasName)5 DRGElement (org.kie.workbench.common.dmn.api.definition.v1_1.DRGElement)5 GridDataCache (org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache)5 Edge (org.kie.workbench.common.stunner.core.graph.Edge)5 View (org.kie.workbench.common.stunner.core.graph.content.view.View)5