Search in sources :

Example 86 with LiteralExpression

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

the class MoveRowsCommandTest method appendRow.

private void appendRow(final int rowIndex, final String rowIdentifier) {
    final String inValue = "in " + rowIdentifier;
    final String outValue = "out " + rowIdentifier;
    dtable.getRule().add(new DecisionRule() {

        {
            getInputEntry().add(new UnaryTests() {

                {
                    getText().setValue(inValue);
                }
            });
            getOutputEntry().add(new LiteralExpression() {

                {
                    getText().setValue(outValue);
                }
            });
        }
    });
    final GridRow uiRow = new BaseGridRow();
    uiModel.appendRow(uiRow);
    uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
    uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>(inValue));
    uiModel.setCellValue(rowIndex, 2, new BaseGridCellValue<>(outValue));
    rowsUnderTest.add(uiRow);
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule)

Example 87 with LiteralExpression

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

the class DeleteListRowCommandTest method testGraphCommandExecuteRemoveMiddle.

@Test
public void testGraphCommandExecuteRemoveMiddle() {
    uiModel.appendRow(new BaseGridRow());
    uiModel.appendRow(new BaseGridRow());
    final HasExpression firstRow = HasExpression.wrap(list, new LiteralExpression());
    final HasExpression lastRow = HasExpression.wrap(list, new LiteralExpression());
    list.getExpression().add(0, firstRow);
    list.getExpression().add(lastRow);
    makeCommand(1);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(2, list.getExpression().size());
    assertEquals(firstRow, list.getExpression().get(0));
    assertEquals(lastRow, list.getExpression().get(1));
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 88 with LiteralExpression

use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression 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(HasExpression.wrap(row, existingLiteralExpressionFirst));
    row.getExpression().add(HasExpression.wrap(row, 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(RelationDefaultValueUtilities.PREFIX + "1", informationItem.getName().getValue());
    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).getExpression());
    assertTrue(relation.getRow().get(0).getExpression().get(1).getExpression() instanceof LiteralExpression);
    assertEquals(existingLiteralExpressionLast, relation.getRow().get(0).getExpression().get(2).getExpression());
    assertEquals(relation, informationItem.getParent());
    assertEquals(relation.getRow().get(0), relation.getRow().get(0).getExpression().get(1).getExpression().getParent());
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) List(org.kie.workbench.common.dmn.api.definition.model.List) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 89 with LiteralExpression

use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression 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(HasExpression.wrap(row, new LiteralExpression() {

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

Example 90 with LiteralExpression

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

the class DeleteRelationRowCommandTest method testGraphCommandExecuteRemoveMiddleWithColumns.

@Test
public void testGraphCommandExecuteRemoveMiddleWithColumns() {
    uiModel.appendRow(new BaseGridRow());
    uiModel.appendRow(new BaseGridRow());
    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(HasExpression.wrap(rowList, 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 : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) List(org.kie.workbench.common.dmn.api.definition.model.List) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Aggregations

LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)113 Test (org.junit.Test)64 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)25 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)25 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)23 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)21 List (org.kie.workbench.common.dmn.api.definition.model.List)20 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)16 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)15 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)14 Before (org.junit.Before)13 RuleAnnotationClauseText (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText)12 Optional (java.util.Optional)11 TLiteralExpression (org.kie.dmn.model.v1_2.TLiteralExpression)11 HasComponentWidths (org.kie.workbench.common.dmn.api.definition.HasComponentWidths)11 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)11 Context (org.kie.workbench.common.dmn.api.definition.model.Context)10 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)10 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)9 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)9