Search in sources :

Example 21 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.

the class AddDecisionRuleCommandTest method setup.

@Before
public void setup() {
    this.dtable = new DecisionTable();
    this.rule = new DecisionRule();
    this.uiModel = new DMNGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModelRow = new DMNGridRow();
    this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiInputClauseColumn).getIndex();
    doReturn(2).when(uiOutputClauseColumn).getIndex();
    doReturn(3).when(uiDescriptionColumn).getIndex();
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) DecisionTableUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule) Before(org.junit.Before)

Example 22 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow 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 DMNGridRow();
    this.uiModel.appendRow(uiModelRow);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule) Before(org.junit.Before)

Example 23 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow 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 DMNGridRow();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiNameColumn);
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    this.uiModelMapper = new InvocationUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(invocation), () -> 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.v1_1.Binding) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Invocation(org.kie.workbench.common.dmn.api.definition.v1_1.Invocation) Optional(java.util.Optional) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.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 24 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.

the class AddParameterBindingCommandTest method testCanvasCommandExecuteMultipleEntries.

@Test
public void testCanvasCommandExecuteMultipleEntries() {
    // first row
    final String firstRowText = "p0";
    makeCommand();
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> firstEntryCanvasCommand = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, firstEntryCanvasCommand.execute(handler));
    // second row
    final String secondRowText = "second entry";
    final DMNGridRow uiSecondModelRow = new DMNGridRow();
    makeCommand(1, secondRowText, uiSecondModelRow);
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> secondEntryCanvasCommand = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, secondEntryCanvasCommand.execute(handler));
    // third row
    final String thirdRowText = "third entry";
    final DMNGridRow uiThirdModelRow = new DMNGridRow();
    makeCommand(0, thirdRowText, 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, thirdRowText);
    assertRowValues(1, 2, firstRowText);
    assertRowValues(2, 3, secondRowText);
    verify(canvasOperation, times(3)).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) Test(org.junit.Test)

Example 25 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.

the class AddRelationRowCommandTest method testCanvasCommandExecuteWithColumns.

@Test
public void testCanvasCommandExecuteWithColumns() {
    relation.getRow().add(new List());
    relation.getRow().add(new List());
    relation.getColumn().add(new InformationItem());
    uiModel.appendColumn(uiModelColumn);
    uiModel.appendRow(new DMNGridRow());
    uiModel.appendRow(new DMNGridRow());
    makeCommand(1);
    // Add Graph row first as RelationUIModelMapper relies on the model being first updated
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
    assertEquals(3, uiModel.getRowCount());
    assertEquals(uiModelRow, uiModel.getRows().get(1));
    assertEquals(2, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
    // checking just the row added by command
    assertEquals(uiModelColumn, uiModel.getColumns().get(1));
    assertEquals(2, uiModel.getRows().get(1).getCells().size());
    assertEquals(2, uiModel.getCell(1, 0).getValue().getValue());
    assertEquals("", uiModel.getCell(1, 1).getValue().getValue());
    verify(command).updateRowNumbers();
    verify(command).updateParentInformation();
    verify(canvasOperation).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Test(org.junit.Test)

Aggregations

DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)67 Test (org.junit.Test)32 Before (org.junit.Before)16 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)13 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)12 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)12 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)12 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)11 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)10 Optional (java.util.Optional)9 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)7 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)6 ContextEntry (org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry)6 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)6 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)6 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)6 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)6 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)5 Binding (org.kie.workbench.common.dmn.api.definition.v1_1.Binding)4 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)4