use of org.kie.dmn.model.v1_1.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);
}
use of org.kie.dmn.model.v1_1.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());
}
Aggregations