use of org.kie.workbench.common.dmn.api.definition.model.Binding in project kie-wb-common by kiegroup.
the class AddParameterBindingCommandTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.invocation = new Invocation();
this.binding = new Binding();
final InformationItem parameter = new InformationItem();
parameter.setName(new Name("p" + invocation.getBinding().size()));
this.binding.setParameter(parameter);
this.uiModel = new BaseGridData(false);
this.uiModelRow = new BaseGridRow();
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiNameColumn);
this.uiModel.appendColumn(uiExpressionEditorColumn);
this.uiModelMapper = new InvocationUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(invocation), () -> false, () -> expressionEditorDefinitions, listSelector, 0);
doReturn(ruleManager).when(handler).getRuleManager();
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiNameColumn).getIndex();
doReturn(2).when(uiExpressionEditorColumn).getIndex();
doReturn(uiModel).when(gridWidget).getModel();
doReturn(Optional.empty()).when(expressionEditorDefinitions).getExpressionEditorDefinition(any(Optional.class));
}
use of org.kie.workbench.common.dmn.api.definition.model.Binding in project kie-wb-common by kiegroup.
the class DeleteParameterBindingCommandTest method testCanvasCommandExecuteDeleteOneOfThree.
@Test
public void testCanvasCommandExecuteDeleteOneOfThree() {
final Binding secondBinding = new Binding();
final Binding thirdBinding = new Binding();
invocation.getBinding().add(secondBinding);
invocation.getBinding().add(thirdBinding);
final BaseGridRow secondRow = new BaseGridRow();
final BaseGridRow thirdRow = new BaseGridRow();
uiModel.appendRow(secondRow);
uiModel.appendRow(thirdRow);
makeCommand(1);
final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
assertEquals(2, uiModel.getRowCount());
assertEquals(uiGridRow, uiModel.getRow(0));
assertEquals(thirdRow, uiModel.getRow(1));
assertEquals(3, uiModel.getColumnCount());
assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
assertEquals(uiNameColumn, uiModel.getColumns().get(1));
assertEquals(uiExpressionEditorColumn, uiModel.getColumns().get(2));
verify(command).updateRowNumbers();
verify(command).updateParentInformation();
verify(canvasOperation).execute();
}
use of org.kie.workbench.common.dmn.api.definition.model.Binding in project kie-wb-common by kiegroup.
the class BindingPropertyConverterTest method testWBFromDMN.
@Test
public void testWBFromDMN() {
final org.kie.dmn.model.api.Binding dmn = new TBinding();
final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
dmn.setParameter(informationItem);
final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
literalExpression.setId(EXPRESSION_UUID);
dmn.setExpression(literalExpression);
final Binding wb = BindingPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
assertThat(wb).isNotNull();
assertThat(wb.getParameter()).isNotNull();
assertThat(wb.getExpression()).isNotNull();
assertThat(wb.getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
assertThat(hasComponentWidths).isNotNull();
assertThat(hasComponentWidths).isEqualTo(wb.getExpression());
}
use of org.kie.workbench.common.dmn.api.definition.model.Binding in project kie-wb-common by kiegroup.
the class BindingPropertyConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
final Binding wb = new Binding();
final InformationItem informationItem = new InformationItem();
wb.setParameter(informationItem);
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.getComponentWidths().set(0, 200.0);
literalExpression.getId().setValue(EXPRESSION_UUID);
wb.setExpression(literalExpression);
final org.kie.dmn.model.api.Binding dmn = BindingPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
assertThat(dmn).isNotNull();
assertThat(dmn.getParameter()).isNotNull();
assertThat(dmn.getExpression()).isNotNull();
assertThat(dmn.getExpression().getId()).isEqualTo(EXPRESSION_UUID);
verify(componentWidthsConsumer).accept(componentWidthsCaptor.capture());
final ComponentWidths componentWidths = componentWidthsCaptor.getValue();
assertThat(componentWidths).isNotNull();
assertThat(componentWidths.getDmnElementRef().getLocalPart()).isEqualTo(EXPRESSION_UUID);
assertThat(componentWidths.getWidths().size()).isEqualTo(literalExpression.getRequiredComponentWidthCount());
assertThat(componentWidths.getWidths().get(0)).isEqualTo(200.0);
}
use of org.kie.workbench.common.dmn.api.definition.model.Binding in project kie-wb-common by kiegroup.
the class InvocationEditorDefinition method enrich.
@Override
public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<Invocation> expression) {
expression.ifPresent(invocation -> {
final LiteralExpression literalExpression = new LiteralExpression();
invocation.setExpression(literalExpression);
final InformationItem parameter = new InformationItem();
parameter.getName().setValue(InvocationDefaultValueUtilities.getNewParameterName(invocation));
final Binding binding = new Binding();
binding.setParameter(parameter);
invocation.getBinding().add(binding);
// Setup parent relationships
literalExpression.setParent(invocation);
binding.setParent(invocation);
parameter.setParent(binding);
});
}
Aggregations