use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class PMMLFunctionEditorDefinitionTest method testModelEnrichment.
@Test
public void testModelEnrichment() {
final Optional<Context> oModel = definition.getModelClass();
definition.enrich(Optional.empty(), hasExpression, oModel);
final Context model = oModel.get();
assertEquals(2, model.getContextEntry().size());
assertEquals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, model.getContextEntry().get(0).getVariable().getName().getValue());
assertTrue(model.getContextEntry().get(0).getExpression() instanceof LiteralExpressionPMMLDocument);
assertEquals(model, model.getContextEntry().get(0).getParent());
assertEquals(LiteralExpressionPMMLDocumentModel.VARIABLE_MODEL, model.getContextEntry().get(1).getVariable().getName().getValue());
assertTrue(model.getContextEntry().get(1).getExpression() instanceof LiteralExpressionPMMLDocumentModel);
assertEquals(model, model.getContextEntry().get(1).getParent());
}
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 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.Context 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.Context 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.Context in project kie-wb-common by kiegroup.
the class PMMLIncludedModelHandlerTest method assertPMMLContextDefinition.
private void assertPMMLContextDefinition(final FunctionDefinition function, final String expectedDocumentValue, final String expectedModelValue) {
assertThat(function.getExpression()).isInstanceOf(Context.class);
final Context context = (Context) function.getExpression();
assertThat(context.getContextEntry().get(0).getExpression()).isInstanceOf(LiteralExpressionPMMLDocument.class);
final LiteralExpressionPMMLDocument functionDocument = (LiteralExpressionPMMLDocument) context.getContextEntry().get(0).getExpression();
assertThat(functionDocument.getText().getValue()).isEqualTo(wrap(expectedDocumentValue));
assertThat(context.getContextEntry().get(1).getExpression()).isInstanceOf(LiteralExpressionPMMLDocumentModel.class);
final LiteralExpressionPMMLDocumentModel functionDocumentModel = (LiteralExpressionPMMLDocumentModel) context.getContextEntry().get(1).getExpression();
assertThat(functionDocumentModel.getText().getValue()).isEqualTo(wrap(expectedModelValue));
}
Aggregations