Search in sources :

Example 1 with TContextEntry

use of org.kie.dmn.model.v1_3.TContextEntry in project kie-wb-common by kiegroup.

the class FunctionDefinitionPropertyConverterTest method doTestWBFromDMNWithContextEntry.

private void doTestWBFromDMNWithContextEntry(final FunctionKind kind, final String variableName, final Class<? extends IsLiteralExpression> literalExpressionClass) {
    final org.kie.dmn.model.api.FunctionDefinition dmn = new TFunctionDefinition();
    final org.kie.dmn.model.api.Context contextExpression = new TContext();
    final org.kie.dmn.model.api.ContextEntry contextEntry = new TContextEntry();
    final org.kie.dmn.model.api.InformationItem variable = new TInformationItem();
    variable.setName(variableName);
    contextEntry.setVariable(variable);
    contextEntry.setExpression(new TLiteralExpression());
    contextExpression.getContextEntry().add(contextEntry);
    dmn.setKind(kind);
    dmn.setExpression(contextExpression);
    final FunctionDefinition wb = FunctionDefinitionPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
    assertThat(wb.getExpression()).isInstanceOf(Context.class);
    assertThat(((Context) wb.getExpression()).getContextEntry().get(0).getExpression()).isInstanceOf(literalExpressionClass);
}
Also used : TContext(org.kie.dmn.model.v1_2.TContext) Context(org.kie.workbench.common.dmn.api.definition.model.Context) TFunctionDefinition(org.kie.dmn.model.v1_2.TFunctionDefinition) TContext(org.kie.dmn.model.v1_2.TContext) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) TFunctionDefinition(org.kie.dmn.model.v1_2.TFunctionDefinition) TContextEntry(org.kie.dmn.model.v1_2.TContextEntry)

Example 2 with TContextEntry

use of org.kie.dmn.model.v1_3.TContextEntry in project kie-wb-common by kiegroup.

the class ContextEntryPropertyConverterTest method testWBFromDMN.

@Test
public void testWBFromDMN() {
    final org.kie.dmn.model.api.ContextEntry dmn = new TContextEntry();
    final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
    dmn.setVariable(informationItem);
    final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
    literalExpression.setId(EXPRESSION_UUID);
    dmn.setExpression(literalExpression);
    final ContextEntry wb = ContextEntryPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
    assertThat(wb).isNotNull();
    assertThat(wb.getVariable()).isNotNull();
    assertThat(wb.getExpression()).isNotNull();
    assertThat(wb.getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
    verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
    final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
    assertThat(hasComponentWidths).isNotNull();
    assertThat(hasComponentWidths).isEqualTo(wb.getExpression());
}
Also used : TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) TContextEntry(org.kie.dmn.model.v1_2.TContextEntry) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) TContextEntry(org.kie.dmn.model.v1_2.TContextEntry) Test(org.junit.Test)

Aggregations

TContextEntry (org.kie.dmn.model.v1_2.TContextEntry)2 TInformationItem (org.kie.dmn.model.v1_2.TInformationItem)2 TLiteralExpression (org.kie.dmn.model.v1_2.TLiteralExpression)2 Test (org.junit.Test)1 TContext (org.kie.dmn.model.v1_2.TContext)1 TFunctionDefinition (org.kie.dmn.model.v1_2.TFunctionDefinition)1 HasComponentWidths (org.kie.workbench.common.dmn.api.definition.HasComponentWidths)1 Context (org.kie.workbench.common.dmn.api.definition.model.Context)1 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)1 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)1