use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class FunctionGridTest method testInitialSetupFromDefinition.
@Test
public void testInitialSetupFromDefinition() {
setupGrid(0);
final GridData uiModel = grid.getModel();
assertTrue(uiModel instanceof DMNGridData);
assertEquals(2, uiModel.getColumnCount());
assertTrue(uiModel.getColumns().get(1) instanceof ExpressionEditorColumn);
assertEquals(1, uiModel.getRowCount());
assertTrue(uiModel.getCell(0, 1).getValue() instanceof ExpressionCellValue);
final ExpressionCellValue dcv = (ExpressionCellValue) uiModel.getCell(0, 1).getValue();
assertTrue(dcv.getValue().get() instanceof LiteralExpressionGrid);
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class JavaFunctionSupplementaryGridTest method testInitialSetupFromDefinition.
@Test
public void testInitialSetupFromDefinition() {
setupGrid(0);
final GridData uiModel = grid.getModel();
assertTrue(uiModel instanceof FunctionSupplementaryGridData);
assertEquals(3, uiModel.getColumnCount());
assertTrue(uiModel.getColumns().get(0) instanceof ContextGridRowNumberColumn);
assertTrue(uiModel.getColumns().get(1) instanceof NameColumn);
assertTrue(uiModel.getColumns().get(2) instanceof ExpressionEditorColumn);
assertEquals(2, uiModel.getRowCount());
final String[] expectedNames = getExpectedNames();
for (int i = 0; i < uiModel.getRowCount(); i++) {
assertEquals(i + 1, uiModel.getCell(i, 0).getValue().getValue());
assertEquals(expectedNames[i], ((InformationItemCell.HasNameAndDataTypeCell) uiModel.getCell(i, 1).getValue().getValue()).getName().getValue());
assertTrue(uiModel.getCell(i, 2).getValue() instanceof ExpressionCellValue);
final ExpressionCellValue dcv = (ExpressionCellValue) uiModel.getCell(i, 2).getValue();
assertEquals(literalExpressionEditor, dcv.getValue().get());
}
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class ListUIModelMapperTest method assertFromDMNModelLiteralExpression.
private void assertFromDMNModelLiteralExpression(final boolean isOnlyVisualChangeAllowed) {
assertTrue(uiModel.getCell(0, EXPRESSION_COLUMN_INDEX).getValue() instanceof ExpressionCellValue);
final ExpressionCellValue dcv = (ExpressionCellValue) uiModel.getCell(0, EXPRESSION_COLUMN_INDEX).getValue();
assertEquals(literalExpressionEditor, dcv.getValue().get());
verify(literalExpressionEditorDefinition).getEditor(parentCaptor.capture(), eq(Optional.empty()), eq(list.getExpression().get(0)), eq(Optional.empty()), eq(isOnlyVisualChangeAllowed), eq(1));
final GridCellTuple parent = parentCaptor.getValue();
assertEquals(0, parent.getRowIndex());
assertEquals(EXPRESSION_COLUMN_INDEX, parent.getColumnIndex());
assertEquals(gridWidget, parent.getGridWidget());
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class ListUIModelMapperTest method assertFromDMNModelUndefinedExpression.
private void assertFromDMNModelUndefinedExpression(final boolean isOnlyVisualChangeAllowed) {
assertTrue(uiModel.getCell(0, EXPRESSION_COLUMN_INDEX).getValue() instanceof ExpressionCellValue);
final ExpressionCellValue dcv = (ExpressionCellValue) uiModel.getCell(0, EXPRESSION_COLUMN_INDEX).getValue();
assertEquals(undefinedExpressionEditor, dcv.getValue().get());
verify(undefinedExpressionEditorDefinition).getEditor(parentCaptor.capture(), eq(Optional.empty()), eq(list.getExpression().get(0)), eq(Optional.empty()), eq(isOnlyVisualChangeAllowed), eq(1));
final GridCellTuple parent = parentCaptor.getValue();
assertEquals(0, parent.getRowIndex());
assertEquals(EXPRESSION_COLUMN_INDEX, parent.getColumnIndex());
assertEquals(gridWidget, parent.getGridWidget());
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class ListUIModelMapperTest method testToDMNModelExpressionNull.
@Test
@SuppressWarnings("unchecked")
public void testToDMNModelExpressionNull() {
// Initially non-null value
setup(new LiteralExpression(), false);
cellValueSupplier = () -> Optional.of(new ExpressionCellValue(Optional.of(undefinedExpressionEditor)));
mapper.toDMNModel(0, EXPRESSION_COLUMN_INDEX, cellValueSupplier);
// ..becomes null value once mapped from the cell value
assertNull(list.getExpression().get(0).getExpression());
}
Aggregations