use of org.kie.workbench.common.dmn.api.definition.v1_1.Invocation in project kie-wb-common by kiegroup.
the class DeleteParameterBindingCommandTest method setup.
@Before
public void setup() {
this.invocation = new Invocation();
this.binding = makeBinding("p" + invocation.getBinding().size());
this.invocation.getBinding().add(binding);
this.uiModel = new BaseGridData(false);
this.uiGridRow = new BaseGridRow();
this.uiModel.appendRow(uiGridRow);
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiNameColumn);
this.uiModel.appendColumn(uiExpressionEditorColumn);
doReturn(ruleManager).when(handler).getRuleManager();
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiNameColumn).getIndex();
doReturn(2).when(uiExpressionEditorColumn).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Invocation 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.Invocation 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.Invocation in project kie-wb-common by kiegroup.
the class InvocationEditorDefinition method getModelClass.
@Override
public Optional<Invocation> getModelClass() {
final Invocation invocation = new Invocation();
invocation.setExpression(new LiteralExpression());
final InformationItem parameter = new InformationItem();
parameter.setName(new Name("p0"));
final Binding binding = new Binding();
binding.setParameter(parameter);
invocation.getBinding().add(binding);
return Optional.of(invocation);
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Invocation in project kie-wb-common by kiegroup.
the class InvocationGrid method addParameterBinding.
void addParameterBinding(final int index) {
expression.ifPresent(invocation -> {
final Binding binding = new Binding();
final InformationItem parameter = new InformationItem();
parameter.setName(new Name("p" + invocation.getBinding().size()));
binding.setParameter(parameter);
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddParameterBindingCommand(invocation, binding, model, new DMNGridRow(), index, uiModelMapper, this::synchroniseView));
});
}
Aggregations