use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class PropertiesPanelNotifier method notifyExpressions.
void notifyExpressions(final Node node, final Object definition) {
if (definition instanceof HasExpression) {
final HasExpression hasExpression = asHasExpression(definition);
final List<HasTypeRef> hasTypeRefs = getNotNullHasTypeRefs(hasExpression.getExpression());
for (final HasTypeRef hasTypeRef : hasTypeRefs) {
notifyOutdatedElement(node, hasTypeRef);
}
}
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class ListGridTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
when(parent.getGridWidget()).thenReturn(parentGridWidget);
when(parentGridWidget.getModel()).thenReturn(parentGridData);
when(parentGridData.getColumns()).thenReturn(Collections.singletonList(parentGridColumn));
when(sessionManager.getCurrentSession()).thenReturn(session);
when(session.getGridPanel()).thenReturn(gridPanel);
when(session.getGridLayer()).thenReturn(gridLayer);
when(session.getCellEditorControls()).thenReturn(cellEditorControls);
definition = new ListEditorDefinition(definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, editorSelectedEvent, refreshFormPropertiesEvent, domainObjectSelectionEvent, listSelector, translationService, expressionEditorDefinitionsSupplier, headerEditor, readOnlyProvider);
final Decision decision = new Decision();
decision.setName(new Name(NAME));
hasName = Optional.of(decision);
expression = definition.getModelClass();
definition.enrich(Optional.empty(), hasExpression, expression);
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
when(literalExpressionEditor.getParentInformation()).thenReturn(parent);
when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpression));
when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
when(undefinedExpressionEditor.getParentInformation()).thenReturn(parent);
when(undefinedExpressionEditorDefinition.getModelClass()).thenReturn(Optional.empty());
when(undefinedExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(undefinedExpressionEditor));
when(session.getCanvasHandler()).thenReturn(canvasHandler);
when(canvasHandler.getGraphExecutionContext()).thenReturn(graphCommandExecutionContext);
when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
when(gridLayer.getVisibleBounds()).thenReturn(new BaseBounds(0, 0, 100, 200));
when(gridLayer.getViewport()).thenReturn(viewport);
when(viewport.getTransform()).thenReturn(transform);
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(diagram.getGraph()).thenReturn(graph);
when(graph.nodes()).thenReturn(Collections.singletonList(node));
when(canvasHandler.getGraphIndex()).thenReturn(index);
when(index.get(Mockito.<String>any())).thenReturn(element);
when(element.getContent()).thenReturn(mock(Definition.class));
when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
when(canvasCommandFactory.updatePropertyValue(any(Element.class), Mockito.<String>any(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(Mockito.<String>any());
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).getTranslation(Mockito.<String>any());
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class LiteralExpressionEditorDefinitionTest method testEditor.
@Test
public void testEditor() {
when(hasExpression.getExpression()).thenReturn(definition.getModelClass().get());
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, hasName, false, 0);
assertThat(oEditor).isPresent();
final GridWidget editor = oEditor.get();
assertThat(editor).isInstanceOf(LiteralExpressionGrid.class);
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class DecisionNavigatorNestedItemFactoryTest method testMakeEditExpressionEventWhenIsReadOnly.
@Test
public void testMakeEditExpressionEventWhenIsReadOnly() {
final ClientSession currentSession = mock(ClientSession.class);
final HasName hasName = mock(HasName.class);
final HasExpression hasExpression = mock(HasExpression.class);
final View view = mock(View.class);
final String uuid = "uuid";
when(readOnlyProvider.isReadOnlyDiagram()).thenReturn(true);
when(node.getUUID()).thenReturn(uuid);
when(sessionManager.getCurrentSession()).thenReturn(currentSession);
when(node.getContent()).thenReturn(view);
when(view.getDefinition()).thenReturn(hasName);
when(boxedExpressionHelper.getHasExpression(node)).thenReturn(hasExpression);
final EditExpressionEvent expressionEvent = factory.makeEditExpressionEvent(node);
assertEquals(uuid, expressionEvent.getNodeUUID());
assertEquals(currentSession, expressionEvent.getSession());
assertEquals(Optional.of(hasName), expressionEvent.getHasName());
assertEquals(hasExpression, expressionEvent.getHasExpression());
assertTrue(expressionEvent.isOnlyVisualChangeAllowed());
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class BoxedExpressionHelperTest method testGetOptionalHasExpressionWhenNodeIsBusinessKnowledgeModel.
@Test
public void testGetOptionalHasExpressionWhenNodeIsBusinessKnowledgeModel() {
final View content = mock(View.class);
final BusinessKnowledgeModel businessKnowledgeModel = new BusinessKnowledgeModel();
final FunctionDefinition encapsulatedLogic = mock(FunctionDefinition.class);
businessKnowledgeModel.setEncapsulatedLogic(encapsulatedLogic);
when(node.getContent()).thenReturn(content);
when(content.getDefinition()).thenReturn(businessKnowledgeModel);
final Optional<HasExpression> actualHasExpression = helper.getOptionalHasExpression(node);
assertTrue(actualHasExpression.isPresent());
assertEquals(businessKnowledgeModel, actualHasExpression.get().asDMNModelInstrumentedBase());
assertEquals(encapsulatedLogic, actualHasExpression.get().getExpression());
}
Aggregations