Search in sources :

Example 36 with InformationItem

use of org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem 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 37 with InformationItem

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

the class AddRelationRowCommandTest method testCanvasCommandExecuteWithColumns.

@Test
public void testCanvasCommandExecuteWithColumns() {
    relation.getRow().add(new List());
    relation.getRow().add(new List());
    relation.getColumn().add(new InformationItem());
    uiModel.appendColumn(uiModelColumn);
    uiModel.appendRow(new DMNGridRow());
    uiModel.appendRow(new DMNGridRow());
    makeCommand(1);
    // Add Graph row 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(3, uiModel.getRowCount());
    assertEquals(uiModelRow, uiModel.getRows().get(1));
    assertEquals(2, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
    // checking just the row added by command
    assertEquals(uiModelColumn, uiModel.getColumns().get(1));
    assertEquals(2, uiModel.getRows().get(1).getCells().size());
    assertEquals(2, uiModel.getCell(1, 0).getValue().getValue());
    assertEquals("", uiModel.getCell(1, 1).getValue().getValue());
    verify(command).updateRowNumbers();
    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) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Test(org.junit.Test)

Example 38 with InformationItem

use of org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem 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)

Example 39 with InformationItem

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

the class AddRelationRowCommandTest method testCanvasCommandUndoWithColumns.

@Test
public void testCanvasCommandUndoWithColumns() {
    relation.getColumn().add(new InformationItem());
    relation.getRow().add(new org.kie.workbench.common.dmn.api.definition.v1_1.List());
    uiModel.appendColumn(uiModelColumn);
    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(2, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
    assertEquals(uiModelColumn, uiModel.getColumns().get(1));
    assertEquals(1, uiModel.getRowCount());
    verify(command).updateRowNumbers();
    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) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Test(org.junit.Test)

Example 40 with InformationItem

use of org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem 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)

Aggregations

InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)66 Test (org.junit.Test)33 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)20 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)20 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)19 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)18 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)12 Before (org.junit.Before)11 ContextEntry (org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry)11 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)10 Binding (org.kie.workbench.common.dmn.api.definition.v1_1.Binding)8 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)7 Optional (java.util.Optional)6 InformationItem (org.kie.dmn.model.v1_1.InformationItem)6 HasName (org.kie.workbench.common.dmn.api.definition.HasName)6 Relation (org.kie.workbench.common.dmn.api.definition.v1_1.Relation)6 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)6 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)6 Context (org.kie.workbench.common.dmn.api.definition.v1_1.Context)5 Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)5