use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class PMMLIncludedModelHandlerTest method makeTopLevelPMMLFunctionDefinition.
private FunctionDefinition makeTopLevelPMMLFunctionDefinition(final String documentName, final String modelName) {
final FunctionDefinition function = new FunctionDefinition();
function.setKind(FunctionDefinition.Kind.PMML);
final Context functionExpression = new Context();
function.setExpression(functionExpression);
final ContextEntry functionContextEntry1 = new ContextEntry();
final InformationItem functionContextEntry1Variable = new InformationItem();
final LiteralExpressionPMMLDocument functionContextEntry1Value = new LiteralExpressionPMMLDocument();
functionContextEntry1Variable.getName().setValue(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT);
functionContextEntry1.setVariable(functionContextEntry1Variable);
functionContextEntry1Value.getText().setValue("\"" + documentName + "\"");
functionContextEntry1.setExpression(functionContextEntry1Value);
final ContextEntry functionContextEntry2 = new ContextEntry();
final InformationItem functionContextEntry2Variable = new InformationItem();
final LiteralExpressionPMMLDocumentModel functionContextEntry2Value = new LiteralExpressionPMMLDocumentModel();
functionContextEntry2Variable.getName().setValue(LiteralExpressionPMMLDocumentModel.VARIABLE_MODEL);
functionContextEntry2.setVariable(functionContextEntry2Variable);
functionContextEntry2Value.getText().setValue("\"" + modelName + "\"");
functionContextEntry2.setExpression(functionContextEntry2Value);
functionExpression.getContextEntry().add(functionContextEntry1);
functionExpression.getContextEntry().add(functionContextEntry2);
return function;
}
use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class PMMLIncludedModelHandlerTest method makeNestedLiteralExpression.
private Context makeNestedLiteralExpression() {
final Context context = new Context();
final ContextEntry contextEntry = new ContextEntry();
final InformationItem variable = new InformationItem();
variable.getName().setValue("variable");
contextEntry.setVariable(variable);
contextEntry.setExpression(new LiteralExpression());
context.getContextEntry().add(contextEntry);
return context;
}
use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class PMMLIncludedModelHandlerTest method assertNestedLiteralExpression.
private void assertNestedLiteralExpression(final Decision decision) {
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(LiteralExpression.class);
assertThat(((LiteralExpression) contextEntry.getExpression()).getText().getValue()).isEmpty();
}
use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class PMMLIncludedModelHandlerTest method assertNestedFunctionDefinition.
private void assertNestedFunctionDefinition(final BusinessKnowledgeModel bkm, final String expectedDocumentValue, final String expectedModelValue) {
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(FunctionDefinition.class);
assertPMMLContextDefinition((FunctionDefinition) contextEntry.getExpression(), expectedDocumentValue, expectedModelValue);
}
Aggregations