Search in sources :

Example 6 with GridCellTuple

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

the class RelationGridTest method setUp.

@Before
public void setUp() throws Exception {
    tupleWithoutValue = new GridCellTuple(0, 1, gridWidget);
    tupleWithValue = new GridCellValueTuple<>(0, 1, gridWidget, new BaseGridCellValue<>("value"));
    definition = new RelationEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService);
    final Decision decision = new Decision();
    decision.setName(new Name("name"));
    hasName = Optional.of(decision);
    expression = definition.getModelClass();
    doReturn(canvasHandler).when(dmnClientFullSession).getCanvasHandler();
    doReturn(dmnClientFullSession).when(sessionManager).getCurrentSession();
    doReturn(parentGridData).when(parentGridWidget).getModel();
    doReturn(Collections.singletonList(parentGridColumn)).when(parentGridData).getColumns();
    parent = spy(new GridCellTuple(0, 0, parentGridWidget));
    when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(anyString());
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Before(org.junit.Before)

Example 7 with GridCellTuple

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

the class DMNGridLayerTest method testGhostRenderingLiteralExpression.

@Test
public void testGhostRenderingLiteralExpression() {
    final LiteralExpressionGrid literalExpressionGrid = mock(LiteralExpressionGrid.class);
    final GridCellTuple parentGridCellTuple = new GridCellTuple(0, 0, container);
    GwtMockito.useProviderForType(Group.class, clazz -> ghostGroup);
    doReturn(new HashSet<>(Arrays.asList(container, literalExpressionGrid))).when(gridLayer).getGridWidgets();
    doReturn(ghostRectangle).when(gridLayer).getGhostRectangle();
    doReturn(parentGridCellTuple).when(literalExpressionGrid).getParentInformation();
    gridLayer.select(literalExpressionGrid);
    gridLayer.doBatch();
    assertGhostRendering();
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) LiteralExpressionGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.literal.LiteralExpressionGrid) Test(org.junit.Test)

Example 8 with GridCellTuple

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

the class DMNGridLayerTest method testGhostRenderingUndefinedExpression.

@Test
public void testGhostRenderingUndefinedExpression() {
    final UndefinedExpressionGrid undefinedExpressionGrid = mock(UndefinedExpressionGrid.class);
    final GridCellTuple parentGridCellTuple = new GridCellTuple(0, 0, container);
    GwtMockito.useProviderForType(Group.class, clazz -> ghostGroup);
    doReturn(new HashSet<>(Arrays.asList(container, undefinedExpressionGrid))).when(gridLayer).getGridWidgets();
    doReturn(ghostRectangle).when(gridLayer).getGhostRectangle();
    doReturn(parentGridCellTuple).when(undefinedExpressionGrid).getParentInformation();
    gridLayer.select(undefinedExpressionGrid);
    gridLayer.doBatch();
    assertGhostRendering();
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) UndefinedExpressionGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid) Test(org.junit.Test)

Example 9 with GridCellTuple

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

the class BaseContextUIModelMapperTest method testFromDMNModelUndefinedExpression.

@Test
public void testFromDMNModelUndefinedExpression() {
    mapper.fromDMNModel(0, 2);
    assertTrue(uiModel.getCell(0, 2).getValue() instanceof ExpressionCellValue);
    final ExpressionCellValue dcv0 = (ExpressionCellValue) uiModel.getCell(0, 2).getValue();
    assertEquals(undefinedExpressionEditor, dcv0.getValue().get());
    verify(undefinedExpressionEditorDefinition).getEditor(parentCaptor.capture(), eq(Optional.empty()), eq(context.getContextEntry().get(0)), eq(Optional.empty()), eq(Optional.of(context.getContextEntry().get(0).getVariable())), eq(1));
    final GridCellTuple parent = parentCaptor.getValue();
    assertEquals(0, parent.getRowIndex());
    assertEquals(2, parent.getColumnIndex());
    assertEquals(gridWidget, parent.getGridWidget());
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Test(org.junit.Test)

Example 10 with GridCellTuple

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

the class BaseContextUIModelMapperTest method testFromDMNModelLiteralExpression.

@Test
@SuppressWarnings("unchecked")
public void testFromDMNModelLiteralExpression() {
    mapper.fromDMNModel(1, 2);
    assertTrue(uiModel.getCell(1, 2).getValue() instanceof ExpressionCellValue);
    final ExpressionCellValue dcv1 = (ExpressionCellValue) uiModel.getCell(1, 2).getValue();
    assertEquals(literalExpressionEditor, dcv1.getValue().get());
    verify(literalExpressionEditorDefinition).getEditor(parentCaptor.capture(), eq(Optional.empty()), eq(context.getContextEntry().get(1)), eq(Optional.of(context.getContextEntry().get(1).getExpression())), eq(Optional.empty()), eq(1));
    final GridCellTuple parent = parentCaptor.getValue();
    assertEquals(1, parent.getRowIndex());
    assertEquals(2, parent.getColumnIndex());
    assertEquals(gridWidget, parent.getGridWidget());
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Test(org.junit.Test)

Aggregations

GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)39 Test (org.junit.Test)19 Before (org.junit.Before)11 GridCellValueTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellValueTuple)10 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)10 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)9 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)9 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)8 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)8 TextBoxSingletonDOMElementFactory (org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.TextBoxSingletonDOMElementFactory)8 Optional (java.util.Optional)6 HasName (org.kie.workbench.common.dmn.api.definition.HasName)6 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)6 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)6 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)5 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)5 Decision (org.kie.workbench.common.dmn.api.definition.v1_1.Decision)4 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)4 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)4 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)4