use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class RelationColumnTest method assertMinimumWidth.
@SafeVarargs
private final void assertMinimumWidth(final double peerWidth, final double relationGridWidth, final double expectedMinimumWidth, final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>>... peers) {
doReturn(peerWidth).when(peerExpressionEditor).getMinimumWidth();
doReturn(relationGridWidth).when(gridWidget).getWidth();
for (int i = 0; i < peers.length; i++) {
parentUiModel.setCellValue(i + 1, 0, new ExpressionCellValue(peers[i]));
}
assertEquals(expectedMinimumWidth, column.getMinimumWidth(), 0.0);
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class UndefinedExpressionUIModelMapperTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.uiModel = new BaseGridData();
this.uiModel.appendColumn(uiColumn);
this.uiModel.appendRow(new BaseGridRow());
this.mapper = new UndefinedExpressionUIModelMapper(() -> uiModel, () -> Optional.ofNullable(expression), listSelector, translationService, hasExpression);
this.cellValueSupplier = () -> Optional.of(new ExpressionCellValue(Optional.of(editor)));
when(hasExpression.asDMNModelInstrumentedBase()).thenReturn(hasExpressionDMNModelInstrumentedBase);
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class DMNGridLayerTest method testSelectNestedGridWidget.
@Test
public void testSelectNestedGridWidget() {
final GridWidget gridWidget = mock(GridWidget.class);
final GridData gridData = new BaseGridData(false);
gridData.appendRow(new BaseGridRow());
gridData.appendColumn(mock(GridColumn.class));
gridData.setCellValue(0, 0, new ExpressionCellValue(Optional.of(expressionGrid)));
gridLayer.register(gridWidget);
gridLayer.register(expressionGrid);
assertThat(gridLayer.getSelectedGridWidget().isPresent()).isFalse();
// Select nested grid
when(gridWidget.getModel()).thenReturn(gridData);
when(expressionGrid.getModel()).thenReturn(new BaseGridData(false));
gridLayer.select(expressionGrid);
assertThat(gridLayer.getSelectedGridWidget().isPresent()).isTrue();
assertThat(gridLayer.getSelectedGridWidget().get()).isEqualTo(expressionGrid);
verify(expressionGrid).select();
verify(gridLayer).batch();
// Select outer grid, deselecting nested grid
reset(gridLayer, gridWidget, expressionGrid);
when(gridWidget.getModel()).thenReturn(gridData);
when(expressionGrid.getModel()).thenReturn(new BaseGridData(false));
when(expressionGrid.isSelected()).thenReturn(true);
gridLayer.select(gridWidget);
assertThat(gridLayer.getSelectedGridWidget().isPresent()).isTrue();
assertThat(gridLayer.getSelectedGridWidget().get()).isEqualTo(gridWidget);
verify(gridWidget).select();
verify(expressionGrid).deselect();
verify(gridLayer).batch();
// Reselect outer grid, there should be no change in selections and the GridLayer should not be redrawn
reset(gridLayer, gridWidget, expressionGrid);
when(gridWidget.getModel()).thenReturn(gridData);
when(gridWidget.isSelected()).thenReturn(true);
when(expressionGrid.getModel()).thenReturn(new BaseGridData(false));
when(expressionGrid.isSelected()).thenReturn(false);
gridLayer.select(gridWidget);
verify(gridWidget, never()).select();
verify(expressionGrid, never()).deselect();
verify(gridLayer, never()).batch();
}
Aggregations