Search in sources :

Example 31 with List

use of org.kie.dmn.model.v1_1.List 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 32 with List

use of org.kie.dmn.model.v1_1.List 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 33 with List

use of org.kie.dmn.model.v1_1.List in project kie-wb-common by kiegroup.

the class AddRelationRowCommandTest method setup.

@Before
public void setup() {
    this.relation = new Relation();
    this.row = new List();
    this.uiModelRow = new DMNGridRow();
    this.uiModel = new BaseGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModelMapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector);
    makeCommand(0);
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiModelColumn).getIndex();
}
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) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 34 with List

use of org.kie.dmn.model.v1_1.List in project kie-wb-common by kiegroup.

the class DeleteRelationColumnCommandTest method testCanvasCommandExecuteWithRows.

@Test
public void testCanvasCommandExecuteWithRows() {
    relation.getRow().add(new List());
    relation.getRow().get(0).getExpression().add(new LiteralExpression());
    uiModel.appendRow(new DMNGridRow());
    uiModelMapper.fromDMNModel(0, 0);
    uiModelMapper.fromDMNModel(0, 1);
    makeCommand();
    final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(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) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) Test(org.junit.Test)

Example 35 with List

use of org.kie.dmn.model.v1_1.List 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)

Aggregations

Test (org.junit.Test)54 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)26 ItemDefinition (org.kie.dmn.model.v1_1.ItemDefinition)21 QName (javax.xml.namespace.QName)17 ArrayList (java.util.ArrayList)15 List (java.util.List)14 DMNMessage (org.kie.dmn.api.core.DMNMessage)14 Import (org.kie.dmn.model.v1_1.Import)13 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)13 CoreMatchers.is (org.hamcrest.CoreMatchers.is)11 DMNMessageType (org.kie.dmn.api.core.DMNMessageType)11 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)11 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)10 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)10 Definitions (org.kie.dmn.model.v1_1.Definitions)9 IOException (java.io.IOException)8 Collectors (java.util.stream.Collectors)8 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)8 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)8 Reader (java.io.Reader)7