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());
}
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());
}
}
}
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);
}
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);
}
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;
}
};
}
Aggregations