Search in sources :

Example 31 with LiteralExpression

use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.

the class RelationGridTest method testInitialiseUiModel.

@Test
public void testInitialiseUiModel() throws Exception {
    relation.getColumn().add(new InformationItem() {

        {
            getName().setValue("first column header");
        }
    });
    final String firstRowValue = "first column value 1";
    final String secondRowValue = "first column value 2";
    relation.getRow().add(new List() {

        {
            getExpression().add(new LiteralExpression() {

                {
                    setText(firstRowValue);
                }
            });
        }
    });
    relation.getRow().add(new List() {

        {
            getExpression().add(new LiteralExpression() {

                {
                    setText(secondRowValue);
                }
            });
        }
    });
    expression = Optional.of(relation);
    setupGrid(0);
    assertEquals(2, grid.getModel().getRowCount());
    assertEquals(firstRowValue, grid.getModel().getRow(0).getCells().get(1).getValue().getValue());
    assertEquals(secondRowValue, grid.getModel().getRow(1).getCells().get(1).getValue().getValue());
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 32 with LiteralExpression

use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.

the class RelationUIModelMapperTest method testToDMNModelLiteralExpressionsEmptyValue.

@Test
public void testToDMNModelLiteralExpressionsEmptyValue() {
    for (int uiRowIndex = 0; uiRowIndex < uiModel.getRowCount(); uiRowIndex++) {
        for (int uiColumnIndex = 1; uiColumnIndex < uiModel.getColumnCount(); uiColumnIndex++) {
            mapper.toDMNModel(uiRowIndex, uiColumnIndex, cellValueSupplier);
            final LiteralExpression le = (LiteralExpression) relation.getRow().get(uiRowIndex).getExpression().get(uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
            assertEquals("", le.getText());
        }
    }
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Test(org.junit.Test)

Example 33 with LiteralExpression

use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.

the class UndefinedExpressionColumnTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.column = spy(new UndefinedExpressionColumn(headerMetaData, gridWidget, cellEditorControls, expressionEditorDefinitionsSupplier));
    doReturn(parent).when(gridWidget).getParentInformation();
    doReturn(parentGridWidget).when(parent).getGridWidget();
    doReturn(parentGridData).when(parentGridWidget).getModel();
    doReturn(Collections.singletonList(parentGridColumn)).when(parentGridData).getColumns();
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    doReturn(ExpressionType.LITERAL_EXPRESSION).when(literalExpressionEditorDefinition).getType();
    doReturn(LiteralExpression.class.getSimpleName()).when(literalExpressionEditorDefinition).getName();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    when(context.getRowIndex()).thenReturn(ROW_INDEX);
    when(context.getColumnIndex()).thenReturn(COLUMN_INDEX);
    when(context.getRelativeLocation()).thenReturn(Optional.of(relativeLocation));
    when(context.getAbsoluteCellX()).thenReturn(ABSOLUTE_CELL_X);
    when(context.getAbsoluteCellY()).thenReturn(ABSOLUTE_CELL_Y);
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Before(org.junit.Before)

Example 34 with LiteralExpression

use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.

the class UndefinedExpressionGridTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    definition = new UndefinedExpressionEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, expressionEditorDefinitionsSupplier);
    expression = definition.getModelClass();
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(definition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(ExpressionType.LITERAL_EXPRESSION).when(literalExpressionEditorDefinition).getType();
    doReturn(LiteralExpression.class.getSimpleName()).when(literalExpressionEditorDefinition).getName();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    doReturn(0).when(parent).getRowIndex();
    doReturn(0).when(parent).getColumnIndex();
    doReturn(parentGridWidget).when(parent).getGridWidget();
    doReturn(mock(GridData.class)).when(parentGridWidget).getModel();
    doReturn(session).when(sessionManager).getCurrentSession();
    doReturn(handler).when(session).getCanvasHandler();
    when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
    when(parent.getGridWidget()).thenReturn(parentGridWidget);
    when(parent.getRowIndex()).thenReturn(0);
    when(parent.getColumnIndex()).thenReturn(1);
}
Also used : 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) Optional(java.util.Optional) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) Before(org.junit.Before)

Example 35 with LiteralExpression

use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.

the class BaseExpressionGridRenderingTest method getGrid.

@Override
@SuppressWarnings("unchecked")
public BaseExpressionGrid getGrid() {
    final GridCellTuple parent = new GridCellTuple(0, 0, null);
    final HasExpression hasExpression = mock(HasExpression.class);
    final Optional<LiteralExpression> expression = Optional.of(mock(LiteralExpression.class));
    final Optional<HasName> hasName = Optional.of(mock(HasName.class));
    return new BaseExpressionGrid(parent, Optional.empty(), hasExpression, expression, hasName, gridPanel, gridLayer, new GridDataCache.CacheResult(new DMNGridData(), false), renderer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, 0) {

        @Override
        protected BaseUIModelMapper makeUiModelMapper() {
            return mapper;
        }

        @Override
        protected void initialiseUiColumns() {
        // Nothing for this test
        }

        @Override
        protected void initialiseUiModel() {
        // Nothing for this test
        }

        @Override
        protected boolean isHeaderHidden() {
            return isHeaderHidden;
        }
    };
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) GridDataCache(org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache) HasName(org.kie.workbench.common.dmn.api.definition.HasName) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)

Aggregations

LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)60 Test (org.junit.Test)27 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)18 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)18 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)18 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)13 Before (org.junit.Before)11 Optional (java.util.Optional)10 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)10 UnaryTests (org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)10 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)10 HasName (org.kie.workbench.common.dmn.api.definition.HasName)9 LiteralExpression (org.kie.dmn.model.v1_1.LiteralExpression)8 Context (org.kie.workbench.common.dmn.api.definition.v1_1.Context)8 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)8 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)8 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)7 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)7 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)7 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)7