use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.
the class PMMLFunctionEditorDefinitionTest method testModelDefinition.
@Test
public void testModelDefinition() {
final Optional<Context> oModel = definition.getModelClass();
assertTrue(oModel.isPresent());
final Context model = oModel.get();
assertEquals(2, model.getContextEntry().size());
assertEquals(PMMLFunctionEditorDefinition.VARIABLE_DOCUMENT, model.getContextEntry().get(0).getVariable().getName().getValue());
assertTrue(model.getContextEntry().get(0).getExpression() instanceof LiteralExpression);
assertEquals(PMMLFunctionEditorDefinition.VARIABLE_MODEL, model.getContextEntry().get(1).getVariable().getName().getValue());
assertTrue(model.getContextEntry().get(1).getExpression() instanceof LiteralExpression);
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.
the class InvocationEditorDefinitionTest method testModelDefinition.
@Test
public void testModelDefinition() {
final Optional<Invocation> oModel = definition.getModelClass();
assertTrue(oModel.isPresent());
final Invocation model = oModel.get();
assertNotNull(model.getExpression());
assertTrue(model.getExpression() instanceof LiteralExpression);
assertEquals(1, model.getBinding().size());
assertNotNull(model.getBinding().get(0).getParameter());
assertEquals("p0", model.getBinding().get(0).getParameter().getName().getValue());
assertNull(model.getBinding().get(0).getExpression());
assertNotNull(model.getId());
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.
the class InvocationGridTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
tupleWithoutValue = new GridCellTuple(0, 1, gridWidget);
tupleWithValue = new GridCellValueTuple<>(0, 1, gridWidget, new BaseGridCellValue<>("value"));
definition = new InvocationEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, expressionEditorDefinitionsSupplier);
expression = definition.getModelClass();
expression.ifPresent(invocation -> ((LiteralExpression) invocation.getExpression()).setText("invocation-expression"));
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
doReturn(parent).when(undefinedExpressionEditor).getParentInformation();
doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
doReturn(session).when(sessionManager).getCurrentSession();
doReturn(canvasHandler).when(session).getCanvasHandler();
doReturn(graphContext).when(canvasHandler).getGraphExecutionContext();
final Decision decision = new Decision();
decision.setName(new Name("name"));
hasName = Optional.of(decision);
when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
when(canvasHandler.getGraphIndex()).thenReturn(index);
when(index.get(anyString())).thenReturn(element);
when(element.getContent()).thenReturn(mock(Definition.class));
when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
when(canvasCommandFactory.updatePropertyValue(any(Element.class), anyString(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(anyString());
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.
the class LiteralExpressionUIModelMapperTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
uiModel = new BaseGridData();
uiModel.appendRow(new DMNGridRow());
uiModel.appendColumn(uiLiteralExpressionColumn);
doReturn(0).when(uiLiteralExpressionColumn).getIndex();
when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
when(parentGridUiModel.getCell(eq(PARENT_ROW_INDEX), eq(PARENT_COLUMN_INDEX))).thenReturn(parentGridUiCell);
when(parentGridUiCell.getSelectionStrategy()).thenReturn(parentGridUiCellCellSelectionStrategy);
literalExpression = new LiteralExpression();
mapper = new LiteralExpressionUIModelMapper(() -> uiModel, () -> Optional.of(literalExpression), listSelector, new GridCellTuple(PARENT_ROW_INDEX, PARENT_COLUMN_INDEX, parentGridWidget));
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.
the class FunctionEditorDefinition method getModelClass.
@Override
public Optional<FunctionDefinition> getModelClass() {
final FunctionDefinition function = new FunctionDefinition();
KindUtilities.setKind(function, FunctionDefinition.Kind.FEEL);
function.setExpression(new LiteralExpression());
return Optional.of(function);
}
Aggregations