Search in sources :

Example 6 with Invocation

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

the class InvocationPropertyConverterTest method testDMNFromWB.

@Test
public void testDMNFromWB() {
    final Invocation wb = new Invocation();
    final LiteralExpression literalExpression = new LiteralExpression();
    literalExpression.getComponentWidths().set(0, 200.0);
    literalExpression.getId().setValue(EXPRESSION_UUID);
    wb.getId().setValue(INVOCATION_UUID);
    wb.getDescription().setValue(INVOCATION_DESCRIPTION);
    wb.setTypeRef(new org.kie.workbench.common.dmn.api.property.dmn.QName(org.kie.workbench.common.dmn.api.property.dmn.QName.NULL_NS_URI, INVOCATION_QNAME_LOCALPART));
    wb.setExpression(literalExpression);
    final org.kie.dmn.model.api.Invocation dmn = InvocationPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
    assertThat(dmn).isNotNull();
    assertThat(dmn.getId()).isNotNull();
    assertThat(dmn.getId()).isEqualTo(INVOCATION_UUID);
    assertThat(dmn.getDescription()).isNotNull();
    assertThat(dmn.getDescription()).isEqualTo(INVOCATION_DESCRIPTION);
    assertThat(dmn.getTypeRef()).isNotNull();
    assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(INVOCATION_QNAME_LOCALPART);
    assertThat(dmn.getExpression()).isNotNull();
    assertThat(dmn.getExpression().getId()).isEqualTo(EXPRESSION_UUID);
    verify(componentWidthsConsumer).accept(componentWidthsCaptor.capture());
    final ComponentWidths componentWidths = componentWidthsCaptor.getValue();
    assertThat(componentWidths).isNotNull();
    assertThat(componentWidths.getDmnElementRef().getLocalPart()).isEqualTo(EXPRESSION_UUID);
    assertThat(componentWidths.getWidths().size()).isEqualTo(literalExpression.getRequiredComponentWidthCount());
    assertThat(componentWidths.getWidths().get(0)).isEqualTo(200.0);
}
Also used : TInvocation(org.kie.dmn.model.v1_2.TInvocation) Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) ComponentWidths(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentWidths) Test(org.junit.Test)

Example 7 with Invocation

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

the class InvocationGrid method doAfterSelectionChange.

@Override
public void doAfterSelectionChange(final int uiRowIndex, final int uiColumnIndex) {
    if (hasAnyHeaderCellSelected() || hasMultipleCellsSelected()) {
        super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
        return;
    }
    if (uiColumnIndex == InvocationUIModelMapper.BINDING_PARAMETER_COLUMN_INDEX) {
        if (getExpression().get().isPresent()) {
            final Invocation invocation = getExpression().get().get();
            fireDomainObjectSelectionEvent(invocation.getBinding().get(uiRowIndex).getVariable());
            return;
        }
    }
    super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
}
Also used : Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation)

Example 8 with Invocation

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

the class AddParameterBindingCommandTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.invocation = new Invocation();
    this.binding = new Binding();
    final InformationItem parameter = new InformationItem();
    parameter.setName(new Name("p" + invocation.getBinding().size()));
    this.binding.setParameter(parameter);
    this.uiModel = new BaseGridData(false);
    this.uiModelRow = new BaseGridRow();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiNameColumn);
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    this.uiModelMapper = new InvocationUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(invocation), () -> false, () -> expressionEditorDefinitions, listSelector, 0);
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiNameColumn).getIndex();
    doReturn(2).when(uiExpressionEditorColumn).getIndex();
    doReturn(uiModel).when(gridWidget).getModel();
    doReturn(Optional.empty()).when(expressionEditorDefinitions).getExpressionEditorDefinition(any(Optional.class));
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Optional(java.util.Optional) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) InvocationUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.invocation.InvocationUIModelMapper) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Before(org.junit.Before)

Example 9 with Invocation

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

the class DeleteParameterBindingCommandTest method setup.

@Before
public void setup() {
    this.invocation = new Invocation();
    this.binding = makeBinding("p" + invocation.getBinding().size());
    this.invocation.getBinding().add(binding);
    this.uiModel = new BaseGridData(false);
    this.uiGridRow = new BaseGridRow();
    this.uiModel.appendRow(uiGridRow);
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiNameColumn);
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiNameColumn).getIndex();
    doReturn(2).when(uiExpressionEditorColumn).getIndex();
}
Also used : Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 10 with Invocation

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

the class ExpressionPropertyConverterTest method testDMNFromWB_InvocationConversion.

@Test
public void testDMNFromWB_InvocationConversion() {
    final Invocation wb = new Invocation();
    final List<Double> wbComponentWidths = wb.getComponentWidths();
    wbComponentWidths.set(0, 100.0);
    wbComponentWidths.set(1, 200.0);
    wbComponentWidths.set(2, 300.0);
    wb.getId().setValue(EXPRESSION_UUID);
    assertDMNFromWBConversion(wb, TInvocation.class, 100.0, 200.0, 300.0);
}
Also used : Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation) TInvocation(org.kie.dmn.model.v1_2.TInvocation) Test(org.junit.Test)

Aggregations

Invocation (org.kie.workbench.common.dmn.api.definition.model.Invocation)15 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)5 Test (org.junit.Test)4 Binding (org.kie.workbench.common.dmn.api.definition.model.Binding)4 Context (org.kie.workbench.common.dmn.api.definition.model.Context)4 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)4 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)4 IsLiteralExpression (org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression)4 List (org.kie.workbench.common.dmn.api.definition.model.List)4 Relation (org.kie.workbench.common.dmn.api.definition.model.Relation)4 Before (org.junit.Before)3 TInvocation (org.kie.dmn.model.v1_2.TInvocation)3 HasComponentWidths (org.kie.workbench.common.dmn.api.definition.HasComponentWidths)3 JSITInvocation (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInvocation)3 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)3 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)3 ArrayList (java.util.ArrayList)2 Optional (java.util.Optional)2 QName (javax.xml.namespace.QName)2 TLiteralExpression (org.kie.dmn.model.v1_2.TLiteralExpression)2