Search in sources :

Example 16 with DMNGridRow

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

the class ExpressionEditorColumnTest method testMinimalWidthNoCellsInMiddle.

/**
 * [100]
 * -
 * [50][60]
 */
@Test
public void testMinimalWidthNoCellsInMiddle() throws Exception {
    gridData.appendColumn(column);
    gridData.appendRow(new DMNGridRow());
    gridData.appendRow(new DMNGridRow());
    gridData.appendRow(new DMNGridRow());
    mockCells(0, 0, 100);
    mockCells(1, 0);
    mockCells(2, 0, 50, 60);
    Assertions.assertThat(column.getMinimumWidth()).isEqualTo(110);
}
Also used : DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Test(org.junit.Test)

Example 17 with DMNGridRow

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

the class ExpressionEditorColumnTest method testMinimalWidthThreeCellsSum.

/**
 * [100]
 * [50][60]
 * [50][60][10]
 */
@Test
public void testMinimalWidthThreeCellsSum() throws Exception {
    gridData.appendColumn(column);
    gridData.appendRow(new DMNGridRow());
    gridData.appendRow(new DMNGridRow());
    gridData.appendRow(new DMNGridRow());
    mockCells(0, 0, 100);
    mockCells(1, 0, 50, 60);
    mockCells(2, 0, 50, 60, 10);
    Assertions.assertThat(column.getMinimumWidth()).isEqualTo(120);
}
Also used : DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Test(org.junit.Test)

Example 18 with DMNGridRow

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

the class ExpressionEditorColumnTest method testUpdateInternalWidthNoCellsInMiddle.

@Test
public void testUpdateInternalWidthNoCellsInMiddle() throws Exception {
    gridData.appendColumn(column);
    gridData.appendRow(new DMNGridRow());
    gridData.appendRow(new DMNGridRow());
    gridData.appendRow(new DMNGridRow());
    mockCells(0, 0, 100);
    mockCells(1, 0);
    mockCells(2, 0, 50, 60);
    column.setWidthInternal(200D);
    Assertions.assertThat(getColumnWidth(0, 0, 0)).isEqualTo(200D);
    Assertions.assertThat(getColumnWidth(2, 0, 0)).isEqualTo(50D);
    Assertions.assertThat(getColumnWidth(2, 0, 1)).isEqualTo(150D);
}
Also used : DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Test(org.junit.Test)

Example 19 with DMNGridRow

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

the class InvocationUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.uiModel = new BaseGridData();
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiNameColumn);
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiNameColumn).getIndex();
    doReturn(2).when(uiExpressionEditorColumn).getIndex();
    doReturn(uiModel).when(gridWidget).getModel();
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditor).getExpression();
    doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    final LiteralExpression invocationExpression = new LiteralExpression();
    invocationExpression.setText("invocation-expression");
    final LiteralExpression bindingExpression = new LiteralExpression();
    bindingExpression.setText("binding-expression");
    final Binding binding = new Binding();
    final InformationItem parameter = new InformationItem();
    parameter.setName(new Name("p0"));
    binding.setParameter(parameter);
    binding.setExpression(bindingExpression);
    this.invocation = new Invocation();
    this.invocation.setExpression(invocationExpression);
    this.invocation.getBinding().add(binding);
    this.mapper = new InvocationUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(invocation), expressionEditorDefinitionsSupplier, listSelector, 0);
    this.cellValueSupplier = Optional::empty;
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.v1_1.Binding) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Optional(java.util.Optional) Invocation(org.kie.workbench.common.dmn.api.definition.v1_1.Invocation) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Before(org.junit.Before)

Example 20 with DMNGridRow

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

the class DeleteContextEntryCommandTest method setup.

@Before
public void setup() {
    this.context = new Context();
    this.context.getContextEntry().add(new ContextEntry());
    this.uiModel = new BaseGridData(false);
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendColumn(uiRowNumberColumn);
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiModelColumn).getIndex();
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.v1_1.Context) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) ContextEntry(org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry) Before(org.junit.Before)

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