Search in sources :

Example 46 with List

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

the class DeleteRelationColumnCommandTest method testCanvasCommandUndoWithRows.

@Test
public void testCanvasCommandUndoWithRows() {
    relation.getRow().add(new List());
    final LiteralExpression literalExpression = new LiteralExpression();
    literalExpression.setText(VALUE);
    relation.getRow().get(0).getExpression().add(literalExpression);
    uiModel.appendRow(new DMNGridRow());
    uiModelMapper.fromDMNModel(0, 1);
    makeCommand();
    // Delete 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());
    assertEquals(1, uiModel.getRows().get(0).getCells().size());
    assertEquals(VALUE, 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) 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 47 with List

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

Example 48 with List

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

the class DeleteRelationRowCommandTest method testCanvasCommandExecuteRemoveMiddleWithColumns.

@Test
public void testCanvasCommandExecuteRemoveMiddleWithColumns() {
    uiModel.appendColumn(uiModelColumn);
    final DMNGridRow firstRow = new DMNGridRow();
    final DMNGridRow lastRow = new DMNGridRow();
    uiModel.insertRow(0, firstRow);
    uiModel.appendRow(lastRow);
    relation.getRow().add(0, new List());
    relation.getRow().add(new List());
    makeCommand(1);
    final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
    assertEquals(2, uiModel.getRowCount());
    assertEquals(firstRow, uiModel.getRow(0));
    assertEquals(lastRow, uiModel.getRow(1));
    assertEquals(2, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
    assertEquals(uiModelColumn, uiModel.getColumns().get(1));
    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) Test(org.junit.Test)

Example 49 with List

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

the class ListPropertyConverter method wbFromDMN.

public static List wbFromDMN(final org.kie.dmn.model.v1_1.List dmn) {
    Id id = new Id(dmn.getId());
    Description description = new Description(dmn.getDescription());
    QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
    java.util.List<Expression> expression = new ArrayList<>();
    for (org.kie.dmn.model.v1_1.Expression e : dmn.getExpression()) {
        Expression eConverted = ExpressionPropertyConverter.wbFromDMN(e);
        expression.add(eConverted);
    }
    List result = new List(id, description, typeRef, expression);
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ArrayList(java.util.ArrayList) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) ArrayList(java.util.ArrayList) Id(org.kie.workbench.common.dmn.api.property.dmn.Id)

Example 50 with List

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

the class ListPropertyConverter method dmnFromWB.

public static org.kie.dmn.model.v1_1.List dmnFromWB(final List wb) {
    org.kie.dmn.model.v1_1.List result = new org.kie.dmn.model.v1_1.List();
    result.setId(wb.getId().getValue());
    result.setDescription(wb.getDescription().getValue());
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    for (Expression e : wb.getExpression()) {
        org.kie.dmn.model.v1_1.Expression eConverted = ExpressionPropertyConverter.dmnFromWB(e);
        result.getExpression().add(eConverted);
    }
    return result;
}
Also used : Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) ArrayList(java.util.ArrayList)

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