Search in sources :

Example 1 with DecisionTableUIModelMapper

use of org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper in project kie-wb-common by kiegroup.

the class DeleteOutputClauseCommandTest method setup.

@Before
public void setup() {
    this.dtable = new DecisionTable();
    this.outputClause = new OutputClause();
    this.dtable.getOutput().add(outputClause);
    this.uiModel = new DMNGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiOutputClauseColumn);
    this.uiModel.appendColumn(uiRuleAnnotationClauseColumn);
    this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
    makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + dtable.getInput().size());
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiOutputClauseColumn).getIndex();
    doReturn(2).when(uiRuleAnnotationClauseColumn).getIndex();
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) DecisionTableUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Before(org.junit.Before)

Example 2 with DecisionTableUIModelMapper

use of org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper in project kie-wb-common by kiegroup.

the class DeleteRuleAnnotationClauseCommandTest method testNewCanvasCommandUndo.

@Test
public void testNewCanvasCommandUndo() {
    final DeleteRuleAnnotationClauseCommand command = mock(DeleteRuleAnnotationClauseCommand.class);
    final AbstractCanvasHandler handler = mock(AbstractCanvasHandler.class);
    final GridData uiModel = mock(GridData.class);
    final GridColumn oldUiModelColumn = mock(GridColumn.class);
    final int uiColumnIndex = 3;
    final DecisionRule rule1 = mock(DecisionRule.class);
    final DecisionRule rule2 = mock(DecisionRule.class);
    final List<DecisionRule> rules = Arrays.asList(rule1, rule2);
    final org.uberfire.mvp.Command undoCanvasOperation = mock(org.uberfire.mvp.Command.class);
    final DecisionTableUIModelMapper uiModelMapper = mock(DecisionTableUIModelMapper.class);
    doCallRealMethod().when(command).newCanvasCommand(handler);
    when(command.getUiModel()).thenReturn(uiModel);
    when(command.getUiColumnIndex()).thenReturn(uiColumnIndex);
    when(command.getOldUiModelColumn()).thenReturn(oldUiModelColumn);
    when(command.getDecisionTable()).thenReturn(decisionTable);
    when(decisionTable.getRule()).thenReturn(rules);
    when(command.getUiModelMapper()).thenReturn(uiModelMapper);
    when(command.getUndoCanvasOperation()).thenReturn(undoCanvasOperation);
    final Command<AbstractCanvasHandler, CanvasViolation> canvasCommand = command.newCanvasCommand(handler);
    final CommandResult<CanvasViolation> result = canvasCommand.undo(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, result);
    verify(uiModelMapper).fromDMNModel(0, uiColumnIndex);
    verify(uiModelMapper).fromDMNModel(1, uiColumnIndex);
    verify(command).updateParentInformation();
    verify(undoCanvasOperation).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) DecisionTableUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper) Test(org.junit.Test)

Example 3 with DecisionTableUIModelMapper

use of org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper in project kie-wb-common by kiegroup.

the class AddDecisionRuleCommandTest method setup.

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

Example 4 with DecisionTableUIModelMapper

use of org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper in project kie-wb-common by kiegroup.

the class AddOutputClauseCommandTest method setUp.

@Before
public void setUp() throws Exception {
    this.dtable = new DecisionTable();
    this.uiModel = new DMNGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.outputClause = new OutputClause();
    this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiOutputClauseColumn).getIndex();
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) DecisionTableUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Before(org.junit.Before)

Example 5 with DecisionTableUIModelMapper

use of org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper in project kie-wb-common by kiegroup.

the class DeleteInputClauseCommandTest method setup.

@Before
public void setup() {
    this.dtable = new DecisionTable();
    this.inputClause = new InputClause();
    this.dtable.getInput().add(inputClause);
    this.uiModel = new DMNGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiInputClauseColumn);
    this.uiModel.appendColumn(uiAnnotationClauseColumn);
    this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
    makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiInputClauseColumn).getIndex();
    doReturn(2).when(uiAnnotationClauseColumn).getIndex();
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) DecisionTableUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause) Before(org.junit.Before)

Aggregations

DecisionTableUIModelMapper (org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper)6 Before (org.junit.Before)5 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)5 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)5 InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)2 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)2 Test (org.junit.Test)1 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)1 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)1 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)1 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)1 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)1 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)1