Search in sources :

Example 16 with LiteralExpression

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

the class FunctionEditorDefinitionTest method testModelDefinition.

@Test
public void testModelDefinition() {
    final Optional<FunctionDefinition> oModel = definition.getModelClass();
    assertTrue(oModel.isPresent());
    final FunctionDefinition model = oModel.get();
    assertEquals(DMNModelInstrumentedBase.URI_KIE, model.getNsContext().get(FunctionDefinition.DROOLS_PREFIX));
    assertEquals(FunctionDefinition.Kind.FEEL.code(), model.getAdditionalAttributes().get(FunctionDefinition.KIND_QNAME));
    assertTrue(model.getExpression() instanceof LiteralExpression);
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.v1_1.FunctionDefinition) Test(org.junit.Test)

Example 17 with LiteralExpression

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

the class JavaFunctionEditorDefinitionTest method testModelDefinition.

@Test
public void testModelDefinition() {
    final Optional<Context> oModel = definition.getModelClass();
    assertTrue(oModel.isPresent());
    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(JavaFunctionEditorDefinition.VARIABLE_METHOD_SIGNATURE, model.getContextEntry().get(1).getVariable().getName().getValue());
    assertTrue(model.getContextEntry().get(1).getExpression() instanceof LiteralExpression);
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.v1_1.Context) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Test(org.junit.Test)

Example 18 with LiteralExpression

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

the class InvocationUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.uiModel = new BaseGridData();
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiNameColumn);
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiNameColumn).getIndex();
    doReturn(2).when(uiExpressionEditorColumn).getIndex();
    doReturn(uiModel).when(gridWidget).getModel();
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditor).getExpression();
    doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    final LiteralExpression invocationExpression = new LiteralExpression();
    invocationExpression.setText("invocation-expression");
    final LiteralExpression bindingExpression = new LiteralExpression();
    bindingExpression.setText("binding-expression");
    final Binding binding = new Binding();
    final InformationItem parameter = new InformationItem();
    parameter.setName(new Name("p0"));
    binding.setParameter(parameter);
    binding.setExpression(bindingExpression);
    this.invocation = new Invocation();
    this.invocation.setExpression(invocationExpression);
    this.invocation.getBinding().add(binding);
    this.mapper = new InvocationUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(invocation), expressionEditorDefinitionsSupplier, listSelector, 0);
    this.cellValueSupplier = Optional::empty;
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.v1_1.Binding) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Optional(java.util.Optional) Invocation(org.kie.workbench.common.dmn.api.definition.v1_1.Invocation) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Before(org.junit.Before)

Example 19 with LiteralExpression

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

the class LiteralExpressionEditorDefinitionTest method testEditor.

@Test
public void testEditor() {
    final Optional<LiteralExpression> expression = definition.getModelClass();
    final Optional<BaseExpressionGrid> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, expression, hasName, 0);
    assertThat(oEditor).isPresent();
    final GridWidget editor = oEditor.get();
    assertThat(editor).isInstanceOf(LiteralExpressionGrid.class);
}
Also used : GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Test(org.junit.Test)

Example 20 with LiteralExpression

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

the class MoveColumnsCommandTest method setUp.

@Before
public void setUp() throws Exception {
    this.dtable = new DecisionTable();
    this.uiModel = new DMNGridData();
    dtable.getInput().add(inputClauseOne);
    dtable.getInput().add(inputClauseTwo);
    dtable.getInput().add(inputClauseThree);
    dtable.getOutput().add(outputClauseOne);
    dtable.getOutput().add(outputClauseTwo);
    dtable.getOutput().add(outputClauseThree);
    dtable.getRule().add(new DecisionRule() {

        {
            getInputEntry().add(new UnaryTests());
            getInputEntry().add(new UnaryTests());
            getInputEntry().add(new UnaryTests());
            getOutputEntry().add(new LiteralExpression());
            getOutputEntry().add(new LiteralExpression());
            getOutputEntry().add(new LiteralExpression());
        }
    });
    uiModel.appendColumn(uiRowNumberColumn);
    uiModel.appendColumn(uiInputClauseColumnOne);
    uiModel.appendColumn(uiInputClauseColumnTwo);
    uiModel.appendColumn(uiInputClauseColumnThree);
    uiModel.appendColumn(uiOutputClauseColumnOne);
    uiModel.appendColumn(uiOutputClauseColumnTwo);
    uiModel.appendColumn(uiOutputClauseColumnThree);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiInputClauseColumnOne).getIndex();
    doReturn(2).when(uiInputClauseColumnTwo).getIndex();
    doReturn(3).when(uiInputClauseColumnThree).getIndex();
    doReturn(4).when(uiOutputClauseColumnOne).getIndex();
    doReturn(5).when(uiOutputClauseColumnTwo).getIndex();
    doReturn(6).when(uiOutputClauseColumnThree).getIndex();
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) UnaryTests(org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule) Before(org.junit.Before)

Aggregations

LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)60 Test (org.junit.Test)27 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)18 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)18 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)18 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)13 Before (org.junit.Before)11 Optional (java.util.Optional)10 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)10 UnaryTests (org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)10 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)10 HasName (org.kie.workbench.common.dmn.api.definition.HasName)9 LiteralExpression (org.kie.dmn.model.v1_1.LiteralExpression)8 Context (org.kie.workbench.common.dmn.api.definition.v1_1.Context)8 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)8 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)8 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)7 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)7 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)7 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)7