Search in sources :

Example 76 with LiteralExpression

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

the class DeleteRelationColumnCommandTest method testCanvasCommandUndoWithRows.

@Test
public void testCanvasCommandUndoWithRows() {
    final List rowList = new List();
    relation.getRow().add(rowList);
    final LiteralExpression literalExpression = new LiteralExpression();
    literalExpression.getText().setValue(VALUE);
    relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, literalExpression));
    uiModel.appendRow(new BaseGridRow());
    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);
    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(undoCanvasOperation).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) List(org.kie.workbench.common.dmn.api.definition.model.List) Test(org.junit.Test)

Example 77 with LiteralExpression

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

the class DeleteRelationColumnCommandTest method testGraphCommandExecuteWithRows.

@Test
public void testGraphCommandExecuteWithRows() {
    final List rowList = new List();
    relation.getRow().add(rowList);
    relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, new LiteralExpression()));
    makeCommand();
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(0, relation.getColumn().size());
    assertEquals(1, relation.getRow().size());
    assertEquals(0, relation.getRow().get(0).getExpression().size());
}
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)

Example 78 with LiteralExpression

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

the class RegisterNodeCommandTest method makeLiteralExpression.

private LiteralExpression makeLiteralExpression(final String text) {
    final LiteralExpression expression = new LiteralExpression();
    expression.setId(new Id("0"));
    expression.setText(new Text(text));
    return expression;
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) Id(org.kie.workbench.common.dmn.api.property.dmn.Id)

Example 79 with LiteralExpression

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

the class JavaFunctionEditorDefinitionTest method testModelEnrichment.

@Test
public void testModelEnrichment() {
    final Optional<Context> oModel = definition.getModelClass();
    definition.enrich(Optional.empty(), hasExpression, oModel);
    final Context model = oModel.get();
    assertEquals(2, model.getContextEntry().size());
    assertEquals(JavaFunctionEditorDefinition.VARIABLE_CLASS, model.getContextEntry().get(0).getVariable().getName().getValue());
    assertTrue(model.getContextEntry().get(0).getExpression() instanceof LiteralExpression);
    assertEquals(model, model.getContextEntry().get(0).getParent());
    assertEquals(JavaFunctionEditorDefinition.VARIABLE_METHOD_SIGNATURE, model.getContextEntry().get(1).getVariable().getName().getValue());
    assertTrue(model.getContextEntry().get(1).getExpression() instanceof LiteralExpression);
    assertEquals(model, model.getContextEntry().get(1).getParent());
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.model.Context) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) Test(org.junit.Test)

Example 80 with LiteralExpression

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

the class InvocationEditorDefinitionTest method testModelEnrichment.

@Test
public void testModelEnrichment() {
    final Optional<Invocation> oModel = definition.getModelClass();
    definition.enrich(Optional.empty(), hasExpression, oModel);
    final Invocation model = oModel.get();
    assertNotNull(model.getExpression());
    assertTrue(model.getExpression() instanceof LiteralExpression);
    assertEquals(1, model.getBinding().size());
    assertNotNull(model.getBinding().get(0).getParameter());
    assertEquals(InvocationDefaultValueUtilities.PREFIX + "1", model.getBinding().get(0).getParameter().getName().getValue());
    assertNull(model.getBinding().get(0).getExpression());
    assertNotNull(model.getId());
    assertEquals(model, model.getExpression().getParent());
    assertEquals(model, model.getBinding().get(0).getParent());
    assertEquals(model.getBinding().get(0), model.getBinding().get(0).getParameter().getParent());
}
Also used : Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) 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