use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class GridCellTuple method getRequiredParentColumnWidth.
private double getRequiredParentColumnWidth(final double proposedWidth, final Function<BaseExpressionGrid, Double> requiredWidthSupplier) {
double width = proposedWidth;
final GridData uiModel = gridWidget.getModel();
for (GridRow row : uiModel.getRows()) {
final GridCell<?> cell = row.getCells().get(columnIndex);
if (cell != null) {
final GridCellValue<?> value = cell.getValue();
if (value instanceof ExpressionCellValue) {
final ExpressionCellValue ecv = (ExpressionCellValue) value;
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ecv.getValue();
if (editor.isPresent()) {
final BaseExpressionGrid beg = editor.get();
width = Math.max(width, requiredWidthSupplier.apply(beg));
}
}
}
}
return width;
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class PropertiesPanelNotifierTest method testNotifyExpressions.
@Test
public void testNotifyExpressions() {
final Node node = mock(Node.class);
final HasExpression hasExpression = mock(HasExpression.class);
final Expression expression = mock(Expression.class);
final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class);
final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class);
when(expression.getHasTypeRefs()).thenReturn(asList(hasTypeRef1, hasTypeRef2));
when(hasExpression.getExpression()).thenReturn(expression);
doNothing().when(notifier).notifyOutdatedElement(any(), any());
notifier.notifyExpressions(node, hasExpression);
verify(notifier).notifyOutdatedElement(node, hasTypeRef1);
verify(notifier).notifyOutdatedElement(node, hasTypeRef2);
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class DMNElementsSynchronizerTest method testSynchronizeDecisionNodeNode.
@Test
public void testSynchronizeDecisionNodeNode() {
final Decision from = mock(Decision.class);
final Decision to = mock(Decision.class);
final Question question = mock(Question.class);
final AllowedAnswers allowedAnswers = mock(AllowedAnswers.class);
final Expression expression = mock(Expression.class);
final InformationItemPrimary variable = mock(InformationItemPrimary.class);
when(from.getQuestion()).thenReturn(question);
when(from.getAllowedAnswers()).thenReturn(allowedAnswers);
when(from.getExpression()).thenReturn(expression);
when(from.getVariable()).thenReturn(variable);
synchronizer.synchronizeDecisionNode(from, to);
verify(to).setQuestion(question);
verify(to).setAllowedAnswers(allowedAnswers);
verify(to).setExpression(expression);
verify(to).setVariable(variable);
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class DMNMarshallerStandaloneTest method checkDecisionWithContextWithoutDefaultResult.
private void checkDecisionWithContextWithoutDefaultResult(Graph<?, Node<?, ?>> g) {
Node<?, ?> decisionNode = g.getNode("_30810b88-8416-4c02-8ed1-8c19b7606243");
assertNodeContentDefinitionIs(decisionNode, Decision.class);
Context context = (Context) ((Decision) ((View<?>) decisionNode.getContent()).getDefinition()).getExpression();
InformationItem defaultResultVariable = context.getContextEntry().get(1).getVariable();
assertNull("Default result variable", defaultResultVariable);
Expression defaultResultExpression = context.getContextEntry().get(1).getExpression();
assertNull("Default result expression", defaultResultExpression);
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class DMNMarshallerStandaloneTest method checkDecisionExpression.
private static void checkDecisionExpression(final Graph<?, Node<View, ?>> unmarshalledGraph, final Expression expression) {
final Node<View, ?> decisionNode = nodeOfDefinition(unmarshalledGraph.nodes().iterator(), Decision.class);
final Expression decisionNodeExpression = ((Decision) DefinitionUtils.getElementDefinition(decisionNode)).getExpression();
// The process of marshalling an Expression that has been programmatically instantiated (vs created in the UI)
// leads to the _source_ Expression ComponentWidths being initialised. Therefore to ensure a like-for-like equality
// comparison ensure the unmarshalled _target_ Expression has had it's ComponentWidths initialised too.
decisionNodeExpression.getComponentWidths();
((Context) decisionNodeExpression).getContextEntry().get(0).getExpression().getComponentWidths();
assertThat(decisionNodeExpression).isEqualTo(expression);
}
Aggregations