use of org.kie.workbench.common.dmn.api.definition.model.ContextEntry in project kie-wb-common by kiegroup.
the class PMMLIncludedModelHandlerTest method assertNestedLiteralExpression.
private void assertNestedLiteralExpression(final BusinessKnowledgeModel bkm) {
final FunctionDefinition function = bkm.getEncapsulatedLogic();
assertThat(function.getExpression()).isInstanceOf(Context.class);
final Context context = (Context) function.getExpression();
assertThat(context.getContextEntry()).hasSize(1);
final ContextEntry contextEntry = context.getContextEntry().get(0);
assertThat(contextEntry.getExpression()).isInstanceOf(LiteralExpression.class);
assertThat(((LiteralExpression) contextEntry.getExpression()).getText().getValue()).isEmpty();
}
use of org.kie.workbench.common.dmn.api.definition.model.ContextEntry in project kie-wb-common by kiegroup.
the class PMMLIncludedModelHandlerTest method makeNestedPMMLFunctionDefinition.
private Context makeNestedPMMLFunctionDefinition(final String documentName, final String modelName) {
final Context context = new Context();
final ContextEntry contextEntry = new ContextEntry();
final InformationItem variable = new InformationItem();
variable.getName().setValue("variable");
contextEntry.setVariable(variable);
contextEntry.setExpression(makeTopLevelPMMLFunctionDefinition(documentName, modelName));
context.getContextEntry().add(contextEntry);
return context;
}
use of org.kie.workbench.common.dmn.api.definition.model.ContextEntry in project kie-wb-common by kiegroup.
the class PMMLIncludedModelHandlerTest method assertNestedFunctionDefinition.
private void assertNestedFunctionDefinition(final Decision decision, final String expectedDocumentValue, final String expectedModelValue) {
assertThat(decision.getExpression()).isInstanceOf(Context.class);
final Context context = (Context) decision.getExpression();
assertThat(context.getContextEntry()).hasSize(1);
final ContextEntry contextEntry = context.getContextEntry().get(0);
assertThat(contextEntry.getExpression()).isInstanceOf(FunctionDefinition.class);
assertPMMLContextDefinition((FunctionDefinition) contextEntry.getExpression(), expectedDocumentValue, expectedModelValue);
}
use of org.kie.workbench.common.dmn.api.definition.model.ContextEntry in project kie-wb-common by kiegroup.
the class ContextEntryPropertyConverter method wbFromDMN.
public static ContextEntry wbFromDMN(final JSITContextEntry dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
final InformationItem variable = InformationItemPropertyConverter.wbFromDMN(dmn.getVariable());
Expression expression = null;
final JSITExpression jsiWrapped = dmn.getExpression();
if (Objects.nonNull(jsiWrapped)) {
final JSITExpression jsiExpression = Js.uncheckedCast(JsUtils.getUnwrappedElement(jsiWrapped));
expression = ExpressionPropertyConverter.wbFromDMN(jsiExpression, Js.uncheckedCast(dmn), hasComponentWidthsConsumer);
}
final ContextEntry result = new ContextEntry();
if (Objects.nonNull(variable)) {
variable.setParent(result);
result.setVariable(variable);
}
if (Objects.nonNull(expression)) {
expression.setParent(result);
result.setExpression(expression);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.ContextEntry in project kie-wb-common by kiegroup.
the class ContextPropertyConverterTest method setupDMNFromWB.
private Context setupDMNFromWB(final Optional<Expression> defaultExpression) {
final Context wb = new Context();
final ContextEntry contextEntry1 = new ContextEntry();
final ContextEntry contextEntry2 = new ContextEntry();
final InformationItem informationItem = new InformationItem();
literalExpression.getComponentWidths().set(0, 200.0);
literalExpression.getId().setValue(EXPRESSION_UUID);
contextEntry1.setExpression(literalExpression);
contextEntry1.setVariable(informationItem);
defaultExpression.ifPresent(contextEntry2::setExpression);
wb.getContextEntry().add(contextEntry1);
wb.getContextEntry().add(contextEntry2);
return wb;
}
Aggregations