Search in sources :

Example 26 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class DeleteDecisionRuleCommandTest method setup.

@Before
public void setup() {
    this.dtable = new DecisionTable();
    this.rule = new DecisionRule();
    this.dtable.getRule().add(rule);
    this.uiModel = new DMNGridData();
    this.uiModelRow = new BaseGridRow();
    this.uiModel.appendRow(uiModelRow);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Before(org.junit.Before)

Example 27 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class AddParameterBindingCommandTest method testCanvasCommandExecuteMultipleEntries.

@Test
public void testCanvasCommandExecuteMultipleEntries() {
    // first row
    makeCommand();
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> firstEntryCanvasCommand = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, firstEntryCanvasCommand.execute(handler));
    // second row
    final GridRow uiSecondModelRow = new BaseGridRow();
    makeCommand(1, uiSecondModelRow);
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> secondEntryCanvasCommand = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, secondEntryCanvasCommand.execute(handler));
    // third row
    final GridRow uiThirdModelRow = new BaseGridRow();
    makeCommand(0, uiThirdModelRow);
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> thirdEntryCanvasCommand = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, thirdEntryCanvasCommand.execute(handler));
    assertEquals(3, uiModel.getRowCount());
    assertEquals(uiThirdModelRow, uiModel.getRows().get(0));
    assertEquals(uiModelRow, uiModel.getRows().get(1));
    assertEquals(uiSecondModelRow, uiModel.getRows().get(2));
    assertEquals(3, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(ROW_NUMBER_COLUMN_INDEX));
    assertEquals(uiNameColumn, uiModel.getColumns().get(BINDING_PARAMETER_COLUMN_INDEX));
    assertEquals(uiExpressionEditorColumn, uiModel.getColumns().get(BINDING_EXPRESSION_COLUMN_INDEX));
    assertRowValues(0, 1, InvocationDefaultValueUtilities.PREFIX + "3");
    assertRowValues(1, 2, InvocationDefaultValueUtilities.PREFIX + "1");
    assertRowValues(2, 3, InvocationDefaultValueUtilities.PREFIX + "2");
    verify(canvasOperation, times(3)).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) Test(org.junit.Test)

Example 28 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow 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));
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Optional(java.util.Optional) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) InvocationUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.invocation.InvocationUIModelMapper) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Before(org.junit.Before)

Example 29 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow 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();
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) Test(org.junit.Test)

Example 30 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow 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();
}
Also used : Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Aggregations

BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)104 Test (org.junit.Test)57 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)25 Before (org.junit.Before)24 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)19 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)18 GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)18 List (org.kie.workbench.common.dmn.api.definition.model.List)14 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)14 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)11 Optional (java.util.Optional)10 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)10 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)10 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)9 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)9 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)9 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)9 RowNumberColumn (org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn)9 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)8 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)8