use of org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition in project kie-wb-common by kiegroup.
the class ExpressionPropertyConverterTest method testDMNFromWB_FunctionDefinitionConversion.
@Test
public void testDMNFromWB_FunctionDefinitionConversion() {
final FunctionDefinition wb = new FunctionDefinition();
final List<Double> wbComponentWidths = wb.getComponentWidths();
wbComponentWidths.set(0, 100.0);
wbComponentWidths.set(1, 200.0);
wb.getId().setValue(EXPRESSION_UUID);
assertDMNFromWBConversion(wb, TFunctionDefinition.class, 100.0, 200.0);
}
use of org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition in project kie-wb-common by kiegroup.
the class FunctionColumnParametersHeaderMetaDataTest method setup.
@Before
public void setup() {
this.function = new FunctionDefinition();
this.functionSupplier = () -> Optional.ofNullable(function);
this.header = new FunctionColumnParametersHeaderMetaData(functionSupplier, translationService, cellEditorControls, parametersEditor, gridWidget);
when(translationService.getTranslation(Mockito.<String>any())).thenAnswer((i) -> i.getArguments()[0]);
}
use of org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricherTest method testModelEnrichmentWhenParentIsBKM.
@Test
public void testModelEnrichmentWhenParentIsBKM() {
final FunctionDefinition functionDefinition = mock(FunctionDefinition.class);
final DMNModelInstrumentedBase dmnModelInstrumentedBase = mock(DMNModelInstrumentedBase.class);
final BusinessKnowledgeModel businessKnowledgeModel = new BusinessKnowledgeModel();
businessKnowledgeModel.setVariable(new InformationItemPrimary(new Id(), new Name(), OUTPUT_DATA_QNAME));
businessKnowledgeModel.setEncapsulatedLogic(functionDefinition);
final Optional<DecisionTable> oModel = definition.getModelClass();
oModel.get().setParent(functionDefinition);
when(functionDefinition.asDMNModelInstrumentedBase()).thenReturn(dmnModelInstrumentedBase);
when(dmnModelInstrumentedBase.getParent()).thenReturn(businessKnowledgeModel);
definition.enrich(Optional.empty(), functionDefinition, oModel);
final DecisionTable model = oModel.get();
assertBasicEnrichment(model);
assertStandardInputClauseEnrichment(model);
final List<OutputClause> output = model.getOutput();
assertThat(output.size()).isEqualTo(1);
assertThat(output.get(0).getName()).isEqualTo(DEFAULT_OUTPUT_NAME);
assertThat(output.get(0).getTypeRef()).isEqualTo(OUTPUT_DATA_QNAME);
assertStandardDecisionRuleEnrichment(model);
assertParentHierarchyEnrichment(model);
}
use of org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition in project kie-wb-common by kiegroup.
the class FunctionGrid method doSetKind.
void doSetKind(final FunctionDefinition.Kind kind, final FunctionDefinition function, final Optional<ExpressionEditorDefinition<Expression>> oDefinition) {
oDefinition.ifPresent(definition -> {
final GridCellTuple parent = new GridCellTuple(0, 1, FunctionGrid.this);
final Optional<Expression> expression = definition.getModelClass();
definition.enrich(nodeUUID, hasExpression, expression);
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new SetKindCommand(parent, function, kind, expression, (editor) -> {
editor.ifPresent(e -> {
e.resize(BaseExpressionGrid.RESIZE_EXISTING);
e.selectFirstCell();
});
}, () -> {
resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
selectFirstCell();
}, () -> {
Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = Optional.empty();
editor = definition.getEditor(parent, Optional.empty(), getExpression().get().get(), hasName, isOnlyVisualChangeAllowed, nesting + 1);
return editor;
}));
});
}
use of org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition in project kie-wb-common by kiegroup.
the class FunctionEditorDefinitionTest method testModelEnrichment.
@Test
public void testModelEnrichment() {
final Optional<FunctionDefinition> oModel = definition.getModelClass();
definition.enrich(Optional.empty(), hasExpression, oModel);
final FunctionDefinition model = oModel.get();
assertEquals(FunctionDefinition.Kind.FEEL.code(), model.getKind().code());
assertTrue(model.getExpression() instanceof LiteralExpression);
}
Aggregations