Search in sources :

Example 36 with LiteralExpression

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

the class AddListRowCommandTest method testGraphCommandUndoMultipleEntriesPresent.

@Test
public void testGraphCommandUndoMultipleEntriesPresent() {
    final HasExpression firstEntry = HasExpression.wrap(list, new LiteralExpression());
    list.getExpression().add(0, firstEntry);
    makeCommand();
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    // Add row and then undo
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
    assertEquals(1, list.getExpression().size());
    assertEquals(firstEntry, list.getExpression().get(0));
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) 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 37 with LiteralExpression

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

the class DeleteListRowCommandTest method setup.

@Before
public void setup() {
    this.list = new List();
    this.uiModel = new BaseGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    this.uiModel.appendRow(new BaseGridRow());
    this.list.getExpression().add(HasExpression.wrap(list, new LiteralExpression()));
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiExpressionEditorColumn).getIndex();
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) List(org.kie.workbench.common.dmn.api.definition.model.List) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 38 with LiteralExpression

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

the class DeleteListRowCommandTest method testGraphCommandUndo.

@Test
public void testGraphCommandUndo() {
    final LiteralExpression literalExpression = new LiteralExpression();
    literalExpression.getText().setValue(VALUE);
    list.getExpression().add(HasExpression.wrap(list, literalExpression));
    makeCommand(0);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    // Delete row and then undo
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
    assertEquals(2, list.getExpression().size());
    assertEquals(VALUE, ((LiteralExpression) list.getExpression().get(1).getExpression()).getText().getValue());
}
Also used : 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 39 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_InsertBefore.

@Test
public void testGraphCommandExecuteWithExistingColumn_InsertBefore() {
    final InformationItem existingInformationItem = new InformationItem();
    relation.getColumn().add(existingInformationItem);
    final List row = new List();
    relation.getRow().add(row);
    final LiteralExpression existingLiteralExpression = new LiteralExpression();
    row.getExpression().add(0, HasExpression.wrap(row, existingLiteralExpression));
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(2, relation.getColumn().size());
    assertEquals(informationItem, relation.getColumn().get(0));
    assertEquals(RelationDefaultValueUtilities.PREFIX + "1", informationItem.getName().getValue());
    assertEquals(existingInformationItem, relation.getColumn().get(1));
    assertEquals(1, relation.getRow().size());
    assertEquals(2, relation.getRow().get(0).getExpression().size());
    assertTrue(relation.getRow().get(0).getExpression().get(0).getExpression() instanceof LiteralExpression);
    assertEquals(existingLiteralExpression, relation.getRow().get(0).getExpression().get(1).getExpression());
    assertEquals(relation, informationItem.getParent());
    assertEquals(relation.getRow().get(0), relation.getRow().get(0).getExpression().get(0).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 40 with LiteralExpression

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

the class AddRelationColumnCommandTest method testGraphCommandExecuteWithRows.

@Test
public void testGraphCommandExecuteWithRows() {
    relation.getRow().add(new List());
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(1, relation.getColumn().size());
    assertEquals(informationItem, relation.getColumn().get(0));
    assertEquals(RelationDefaultValueUtilities.PREFIX + "1", informationItem.getName().getValue());
    assertEquals(1, relation.getRow().size());
    assertEquals(1, relation.getRow().get(0).getExpression().size());
    assertTrue(relation.getRow().get(0).getExpression().get(0).getExpression() instanceof LiteralExpression);
    assertEquals(relation, informationItem.getParent());
    assertEquals(relation.getRow().get(0), relation.getRow().get(0).getExpression().get(0).getExpression().getParent());
}
Also used : 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) 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