Search in sources :

Example 66 with InformationItem

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

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

the class AddRelationColumnCommandTest method testCanvasCommandExecuteWithRowsAddColumnMiddle.

@Test
public void testCanvasCommandExecuteWithRowsAddColumnMiddle() {
    makeCommand(2);
    final InformationItem existingInformationItemFirst = new InformationItem();
    relation.getColumn().add(existingInformationItemFirst);
    final InformationItem existingInformationItemLast = new InformationItem();
    relation.getColumn().add(existingInformationItemLast);
    uiModel.appendColumn(mock(RelationColumn.class));
    uiModel.appendColumn(mock(RelationColumn.class));
    uiModel.appendRow(new DMNGridRow());
    // 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(4, uiModel.getColumnCount());
    assertEquals(uiModelColumn, uiModel.getColumns().get(2));
}
Also used : RelationColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationColumn) 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) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Test(org.junit.Test)

Example 68 with InformationItem

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

the class DeleteRelationColumnCommandTest method setup.

@Before
public void setup() {
    this.relation = new Relation();
    this.informationItem = new InformationItem();
    this.relation.getColumn().add(informationItem);
    this.uiModel = new BaseGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiModelColumn);
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiModelColumn).getIndex();
    this.uiModelMapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector);
}
Also used : RelationUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationUIModelMapper) Relation(org.kie.workbench.common.dmn.api.definition.v1_1.Relation) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 69 with InformationItem

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

the class DeleteRelationRowCommandTest method testCanvasCommandUndoWithColumns.

@Test
public void testCanvasCommandUndoWithColumns() {
    relation.getColumn().add(new InformationItem());
    final LiteralExpression literalExpression = new LiteralExpression();
    literalExpression.setText(VALUE);
    relation.getRow().get(0).getExpression().add(literalExpression);
    uiModel.appendColumn(uiModelColumn);
    uiModelMapper.fromDMNModel(0, 0);
    uiModelMapper.fromDMNModel(0, 1);
    // Delete row 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());
    assertEquals(1, uiModel.getCell(0, 0).getValue().getValue());
    assertEquals(VALUE, uiModel.getCell(0, 1).getValue().getValue());
    verify(command).updateRowNumbers();
    verify(command).updateParentInformation();
    verify(canvasOperation).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Test(org.junit.Test)

Example 70 with InformationItem

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

the class DeleteRelationRowCommandTest method testGraphCommandExecuteRemoveMiddleWithColumns.

@Test
public void testGraphCommandExecuteRemoveMiddleWithColumns() {
    uiModel.appendRow(new DMNGridRow());
    uiModel.appendRow(new DMNGridRow());
    final List firstRow = new List();
    final List lastRow = new List();
    relation.getRow().add(0, firstRow);
    relation.getRow().add(lastRow);
    relation.getColumn().add(new InformationItem());
    relation.getRow().get(0).getExpression().add(new LiteralExpression());
    makeCommand(1);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(2, relation.getRow().size());
    assertEquals(firstRow, relation.getRow().get(0));
    assertEquals(lastRow, relation.getRow().get(1));
    assertEquals(1, relation.getColumn().size());
}
Also used : DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) 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